Computer Science Canada

A Beginner

Author:  TheFerret [ Wed Jul 28, 2004 10:52 am ]
Post subject:  A Beginner

I am completely new to programming in Java but I will be taking CompSci in grade 11 first thing, first semister and am trying to learn some Java now so I can get a little bit of a head start but I am not sure where to start out... I do have an editor, Netbeans IDE ver. 3.6...

Author:  wtd [ Wed Jul 28, 2004 12:01 pm ]
Post subject: 

Try Sun's Java tutorial.

Author:  Kingnoz [ Wed Jul 28, 2004 12:20 pm ]
Post subject: 

You could also try using the Tutorials section. There is some stuff on the basics such as arrays, datafiles, strings, etc.

Author:  wtd [ Wed Jul 28, 2004 12:37 pm ]
Post subject: 

And it never hurts to give other programming languages a try. Java can be a bit much syntactically.

Author:  TheFerret [ Wed Jul 28, 2004 1:35 pm ]
Post subject: 

Yeah, I forgot one thing in my first post, I know Turing a lot and am pretty good at it...

Author:  wtd [ Wed Jul 28, 2004 5:00 pm ]
Post subject: 

Good. Now what do you know about object-oriented programming?

Author:  TheFerret [ Wed Jul 28, 2004 5:45 pm ]
Post subject: 

That the more you do, the better you get at it...

(If you are saying that it sucks, then it does... But, if you are not saying that, then it does not suck...)

Author:  Tony [ Wed Jul 28, 2004 5:57 pm ]
Post subject: 

Confused
I think he has no idea what OOP is Thinking

Author:  TheFerret [ Wed Jul 28, 2004 6:26 pm ]
Post subject: 

I know what it is but I don't get what the question is asking for, too general...

(OOP is easy and Java is not OOP and is not easy)

Author:  Tony [ Wed Jul 28, 2004 6:35 pm ]
Post subject: 

TheFerret wrote:
Java is not OOP and is not easy

Eh
I am disgusted
I'm with stupid
do you know what java is?? ROFL

Author:  wtd [ Wed Jul 28, 2004 6:44 pm ]
Post subject: 

Object-oriented programming involves concepts like:

Encapsulation
Interfaces
Composition
Inheritance (single and multiple)
Delegation
Polymorphism
Modularity

If you feel confident that you know what these terms mean, how they're significant, and how to properly apply them, than you probably have a firm grasp of object-oriented programming.

Author:  TheFerret [ Wed Jul 28, 2004 10:51 pm ]
Post subject: 

What I want to know is why are you asking that question(s)...

Author:  wtd [ Wed Jul 28, 2004 10:57 pm ]
Post subject: 

To be an effective Java programmer, you'll have to understand those concepts.

Author:  wtd [ Wed Jul 28, 2004 11:06 pm ]
Post subject: 

TheFerret wrote:
(If you are saying that it sucks, then it does... But, if you are not saying that, then it does not suck...)


All programming languages suck. The more languages you learn, the more you'll realize that. Smile

Java is one of the ones that sucks more than others. It mindlessly copied the syntax and in many cases the semantics of C (probably because of all the old school C hackers at Sun) rather than realizing that there's no deep syntactic or semantic compatibility and taking the opportunity to abandon the old cruft and create a better language with a better syntax.

For instance, in a language with polymorphism and introspection/reflection, why should I be limited to using "switch" on ints? Using the same tools in Ruby I can use its equivalent to "switch" in vastly more powerful ways.

code:
case "hello"
   when "world"
      "foo"
   when "foo", "bar"
      "foo bar!"
   when /yo/
      "oy..."
   else
      "wooble"
end

Author:  rizzix [ Thu Jul 29, 2004 10:45 am ]
Post subject: 

A language is good if it enforces standards and is not too flexible. It is good if it enforces a good consistant style of programming. It is good if it simplifies coding, brings about an ease in maintainance and extensibility. Java does all this and hence i say java is great. Although there are a few things here and there that could be improved for sure, but backward compatibility will always keep languages as such from being modified too quickly. So far i find java pretty good. 1.5 definately will do a better job in simplifying a lot of coding and i recommend learning all thats new in 1.5 and incorporate it into ur projects.

Author:  wtd [ Thu Jul 29, 2004 7:36 pm ]
Post subject: 

Just for the purpose of education, the example I provided is syntactic sugar for:

code:
if "world" === "hello"
   "foo"
elsif "foo" === "hello" or "bar" === "hello"
   "foo bar!"
elsif /yo/ === "hello"
   "oy..."
else
   "wooble"
end


So long as the thing that follows "when" defines an === operator (which you could roughly compare to compareTo in Java) which can deal with the value following "case", it can be used in the switch-style expression. If such an operator isn't provided, it defaults to false.

That's simple, yet flexible. It eases maintanence and extensibility. It's also easier to type. The equivalent Java would be:

code:
if ("world".compareTo("hello") == 0) {
        return "foo";
} else if ("foo".compareTo("hello") == 0 || "bar".compareTo("hello") == 0) {
        return "foo bar!";
} else if (Pattern.matches("yo", "hello")) {
        return "oy...";
} else {
        return "wooble";
}

Author:  wtd [ Thu Jul 29, 2004 7:47 pm ]
Post subject: 

Perhaps better than demonstrating how easy this is in Ruby, is demonstrating it in Groovy, which compiles to Java bytecode (there's no, "but the Ruby interpreter was built for that" argument, even though that argument would be invalid).

It's all just syntactic sugar. It's about getting people to write good code without thinking about it. Good code should be easier to write than bad code, and that's a problem Java doesn't address terribly well.

code:
switch ("hello") {
   case "world":
      return "foo"
   case ["foo", "bar"]:
      return "foo bar!"
   case ~"yo":
      return "oy..."
   default:
      return "wooble"
}

Author:  rizzix [ Thu Jul 29, 2004 8:11 pm ]
Post subject: 

hmm comparing ur example i rather prefer the java's version of it. why do u ask? well all those other example posted up ther have unnecessarly additional syntax for somthing that can be done this one way. it may be easier to type stuff quickly using those other languages.. but u can do that same stuff 10 different ways.

java on the other hand is consistant.. when ur projects are huge.. i mean seriously huge.. u want consistancy.. another good thing about java.. lets say u decide to program on another project developed by some completly different group and that stuff is absolutly new to u, but since its a java project.. ur not too lost. (and i can tell u this by experience)

C++ programmers on the other hand (which is an extreme i agree) "could" be completly lost.. cuz there's no consistancy in c++ code.

a well defined languages is one in which a small base syntax can be used to accomplish everything and each keyword defined in that language has a unique function. c likewise was a very well defined language.

NOTE: a language is not good just cuz it has a cool syntax.. its overall design has to be great, for it to be considered great.

if u rather compare syntax then Perl6 would rule all!

Author:  rizzix [ Thu Jul 29, 2004 8:21 pm ]
Post subject: 

but about the "switch"s i do agree java is too limiting there..

Author:  wtd [ Thu Jul 29, 2004 8:24 pm ]
Post subject: 

Why is it "unnecessary additional syntax"?

Is it really harder, when reading someone else's code, to understand:

code:
switch ("hello") {
   case "world":
      return "foo"
   case ["foo", "bar"]:
      return "foo bar!"
   case ~"yo":
      return "oy..."
   default:
      return "wooble"
}


than it is to understand the following?

code:
if ("world".compareTo("hello") == 0) {
   return "foo";
} else if ("foo".compareTo("hello") == 0 || "bar".compareTo("hello") == 0) {
   return "foo bar!";
} else if (Pattern.matches("yo", "hello")) {
   return "oy...";
} else {
   return "wooble";
}


Isn't the first easier to read, understand, maintain, and extend?

And really, if something makes programming easier, shouldn't it be embraced? The time spent learning a new technology is usually outweighed many times by the time spent using it. so an investment in the former is both trivial and incredibly important.

Good programmers work really hard at being lazy (along with hubris and impatience... the other virtues of a good programmer). Smile

Author:  rizzix [ Thu Jul 29, 2004 8:43 pm ]
Post subject: 

no i dont find it harder.. to read one over the other.. as a matter of fact, the java version of it is a lot more descriptive.

but definatly the java's version of it is a lot more verbose.


: