Where and How to learn Java and/or C++.

One day I want to learn Java and C++ but I hate reading...oh one day my laziness will come to an end.
 
this is a good page to learn programing www.learn-programming.za.net it includes java, c++, pascal, d, c, c#, and vb and very well wrote instructions how to use and learn those programming languages

Very well wrote instructions? Hmm... that sets the tone correctly!

Sorry, but I'm going to pick the above apart a bit as an example of the type of guide that's the sort I WOULDN'T follow because it's not well written and most information in it is just wrong and/or confusing. Just on the first page:

All class names must start with a capital letter.
No they don't. They SHOULD do, but they don't have to, there's no compiler rule enforcing it like it seems to be implying here - this is a very big difference and should really be explained!

static means that it is unique.
Nonsense. Static means that a member belongs to a class, not instances of that class (objects.) Nothing to do with being unique in the slightest. Jumping over to the C# tutorial, we've got a completely different explanation for a static method (also utter tosh!)
static means that the function must stay in memory.
Static CLASSES stay in memory for the lifetime of the application, but this isn't what we're talking about here, and anyway - this is a side product determined by the way the class loader works, not the reason for using it in the first place.

The semi-colon is used to show that it is the end of your line of code. You must put semi-colons after every line like this.
Again, confusing at best and plain wrong at worst. Put a semi colon after something like:

Code:
for(int i=0 ; i<10 ; i++);

...and the compiler will let it through fine, the loop that's executed will just be blank - and the likely block of code following it will have nothing to do with the loop. You can't just say you need to put semi colons after every line of code!

Page 2 is even worse.
There are 3 different types of data that can be stored in variables.
Rubbish. There's endless different object types that can be stored. There's a huge amount in the API, and since you can write your own... how does that make 3?

...it then goes on to give a table of the full primitive types (which is NOT the way to start someone off, that's just confusing and unnecessary not clever) and if that wasn't bad enough, it mixes String in the same table which is not a primitive type at all, and VERY different from the others. This is one of the key fundamentals of OO programming (and therefore Java) and should be explained at this stage pretty thoroughly. There's also no talk about the accuracy differences between float and double, which are arguably far more important than the range differences. And that's before it gets into the bulk of what the page is trying to say...

We've then got examples of code like this:
Code:
int myInteger;
      myInteger = 5;
I mean, what is the point?

Oh and I completely disagree with your examples of a constant - if someone told me to declare a constant that'd mean putting a static final field in a class, not declaring a local variable final. Yes, there are times when you should make local variables final, but your example isn't what most people would think of when they hear the term.

I had a bit more of a browse - I'm afraid it's pretty much all bad, but the "data type and input conversions" page really did make me laugh.

To read a single character from the user you must use the System.in.read() method. This will return and integer value of the key pressed which must be converted to a character. We use (char) in front of System.in.read() to convert the integer to a character. After the user has pressed the key they must press enter and we must put a second System.in.read() to catch this second key press.
Code:
public class ReadChar
{
   public static void main(String[] args) throws Exception
   {
      char c;
      System.out.println("Enter a character");
      c = (char)System.in.read();
      System.in.read();
      System.out.println("You entered " + c);
   }
}
You will see that it says "throws Exception" at the end of the main method declaration. An exception is an error and "throws Exception" tells java to pass the error to the operating system for handling. Your program will not compile if you don't put this in.

First off, what's the point of declaring the variable separate from instantiating it in the above example? Secondly, your "throws Exception" explanation clearly shows you've got no knowledge of what exception is being thrown (it's an IOException, just putting that would've been far better) and probably no knowledge of try / catch blocks. You should only use the throws clause when you're actually developing a method that legitimately should throw an exception - not just tagging it onto everything when the compiler complains.

Lastly on this point, I was wondering why on earth we're dealing with individual character input instead of strings. I've been programming in Java in one form or another extensively for some years now and I can still count the number of times I've felt the need to do that as oppose to string input on one hand. Then I saw the next title, "reading strings." Then I saw we were using JOptionPanes and then it hit me - the author probably doesn't know!! True the initialisation code is relatively complex for a beginner:
Code:
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
...but that's no excuse to suddenly start talking about swing stuff. Perhaps provide a helper class, or even just a method until the student understands the above?

Oh, and stuff like this:
Code:
import javax.swing.*;
Really bugs me, especially for beginners. That's not good practice, you should be much more specific about what you're importing.
Stuff like this:
Code:
      if (i == 5)
         System.out.println("i is equal to 5");
      else
         System.out.println("i is not equal to 5");
Also really bugs me - again while it works, it's bad practice and not something that should be taught as an acceptable method of layout.

Oh and as an object oriented language, the whole point of Java is that you use it to create, um, objects and work with them. I didn't dare look at that page, but not covering it until the second to last topic in the tutorial is really missing the point somewhat. Your whole approach is wrong on that front.

I'm going to stop there (there's LOTS more wrong with it I could talk about) but in short this is one of the worst tutorials I've seen written on Java... I didn't dare look at the others. It's precisely the reason why I advise against googling for random tutorials online when you want to learn a programming language, and recommend going with trusted sources or reading a good book instead.


I'm sure it won't be, but said tutorials really need to be taken offline until the author can go away and learn how to program properly, then rewrite the whole thing. I entirely accept people make mistakes every so often, but this isn't a mistype or 2, it's misleading and clearly written by someone with a very poor understanding of the subject. And even if the content was correct, there's no exercises to work through, nothing we're working towards - just a whole load of stuff cobbled together. Whilst I genuinely applaud the enthusiasm shown for teaching others and passing on knowledge, this needs to be done in a correct and logical manner - either properly, making sure you know your material thoroughly or not at all.
 
Did you hear about the Sun Academic Initiative for students? I am doing a course in J2SE, J2EE and J2ME with them and I must say that it is one of the best. It's online and you have at your disposal hundreds of lessons. If your university has signed a collaboration agreement with SUN I can tell you are lucky and you have to take advantage of it.
 
Just to correct the above to avoid confusion, Dev C++ is actually an IDE, not a compiler. There's a huge difference! It uses MinGW as its compiler, which is the windows port of the standard GCC compilation used on unix (GCC really is the de-facto standard in terms of C/C++ compilation.)

What's the difference between a compiler and an IDE then?

An IDE (integrated develoment environment) is an application you use to write your code. It usually comprises of an editor with code highlighting, panes to manage all your source files and sometimes things like refactoring options. It also usually includes functionality to call a compiler externally and sometimes it includes other things like chat functionality, code libraries - that sort of thing.

A compiler on the other hand is usually just a tiny command line program. You pass it a plain text file (which is your source code) and it compiles your code, giving you a machine executable program to run.
 
Back
Top Bottom