Jump to content

The final blow vs. Java

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
Ok, I've had enough. Java is not the best language for teaching programming. Here's why:
The first program you write is customarily the Hello World message. Here's C:
#include "stdio.h"
int main(){
        puts("Hello, world!");
}
4 lines. Easy. You just have to explain the main function, how to include a library, and the way the puts function works.
Next, C++:
#include "iostream"
int main(){
	std::cout << "Hello, world!\n";
}
Once again 4 lines. Pretty much the same things to explain, except you're using the output operator << instead.
Here's Python, Perl, BASIC, and Ruby:
print "Hello, world!"
1 line. That's the minimum, and it says what it does. Really easy.
Now, here's Java:
class Hello {
	public static void main() {
		System.out.println("Hello World!");
	}
}
A class. You have to define a class, and then...
public static void. What the hell. I don't know what that means, but it shouldn't be necessary for the first program. And what's with the name of the puts-alike function? Why is it inside two of what I assume are packages? And, it's 5 lines.
Java sucks.
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#2
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
On posts like these, be sure to put a
(IMHO) In my humble opinion or something similar. :)

I personally like scripting, but I've seen some truly
AWESOME java applications. My personal opinion or
IMHO, I judge a language on its output as opposed to
ease of use. In other words, a large sampling of finished
applications gives me a better opinion of a language,
than I could ever determine by writing things myself.
Java has proven itself time and time again, so
if you have a problem with structures or syntax, there
are many other options.
I believe in the right tool for the job, which means everything
taken into account (users, time spent, interfaces, platform, portability,
life cycle, etc...) In my situation, time spent is fairly significant
as is platform which usually steers me toward higher level languages.

It's all about what's right for you and your situation.
All in all, I've found C/C++ and Java to be difficult to use as it requires
much more knowledge than I have, to use it effectively.

NOTE:
I have no opinion on teaching a language, as I've only taught my
daughter...
and she seems to pick up most everything I show her.

Edited by debtboy, 11 October 2009 - 01:16 PM.


#3
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
Your counting the ending brackets as lines?! What a crock!

Aereshaa said:

Java is not the best language for teaching programming.
I don't think anyone was saying that, Aereshaa. By far the best language to teach people programming in is Python (or an equivalent scripting language, don't hit me!). Done and done, and I don't think there's any argument you're going to get from people on that point. However, I think what you're trying to demonstrate is it's easier to teach someone C++ than it is Java, and I wholeheartedly disagree.

Certainly the "Hello World!" Java program introduces OOP, but that's because Java is almost strictly an OOP language. Telling someone "This class thing on the top, just remember that the name after 'class' and the name of the file have to be the same" isn't that hard, and most newbies will be able to grasp that basic fact rather quickly. Then "public static void main", sure, that on the surface may sound complex (and in fact you have no idea what it means, which I'd be glad to explain), but it's also very easy to summarily say "This is how you always start the main function" and get around to explaining every detail of what that says later. Unlike in C++, where you have to "unteach" people void main, this method in Java is always right. Finally, "System.out.println()" has nothing to do with packages. System is an object that represents the computer itself, out is a PrintStream object System has, and println is a function. If you had known anything about Java (something you should probably do before criticizing it), then you'd know that. There, was that really that hard to understand?

Whereas let's look at the C++ example, and apply your logic. Surely there are fewer words, but in these fewer words there are greater explanations. What the devil is that "std::" thing, anyway? Oh, you're going to introduce namespaces to a new programmer who hasn't even learned about classes?! What is cout, anyway? Why do you need to "#include <iostream>", and what does that mean? Do you also want to give the student a crash course in operator overloading ("<<")? And what's that "\n" thing? Do you want to have to explain all of this to someone who's never programmed before?

I didn't think so.

Instead, you just say "this is how it works, you'll understand why after you've understood more basic stuff", and it's really that simple. Both of these languages expose quite a bit of complexity for even the most basic of programs. That's not a bad thing, it's simply how a programming language in most cases works. I also know that JCoder has shown an image of a crazy C++ hater, but to say that his antics are representative of all Java programmers is preposterous. If you've got a problem with Java programmers, then you've got a problem with me.

Now, the easiest thing, in my opinion, to explain is this:
[highlight=Python]print("Hello World!")[/highlight]
So, I agree with your statement that Java isn't the easiest language to teach, but it is most definitely easier than C++, because teaching someone how to program is not teaching them Hello World. Not by a long shot.
Wow I changed my sig!

#4
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
that's because Java is almost strictly an OOP language
Ruby is pure OOP. Its hello world is above.

Quote

However, I think what you're trying to demonstrate is it's easier to teach someone C++ than it is Java, and I wholeheartedly disagree.
My point was that Perl and lookalikes are the best followed by C, and that Java is the worst, due the boilerplate. C++ comes in around the lower section, sure. If I was defending C++ specifically, I would be a hardcore C++ programmer whom I'm not.

Quote

Unlike in C++, where you have to "unteach" people void main
That's only because of Java's choice! If Java used "float main" there would be people doing that.

Quote

it's simply how a programming language in most cases works
Absolutely false. I can name quite a few very popular languages in which the complexity is proportionate to how complex the purpose is. Java simply does have too much boilerplate.
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I tend to agree with you. Tossing a beginner directly into an OOP language like Java will probably only serve to confuse them at first (and for a while). Yet, in colleges, universities and schools alike, Java is being taught very often. However, I believe a "programming theory" type class is often required first. I had to take one which actually used C++ to demonstrate key concepts.

Quote

On posts like these, be sure to put a
(IMHO) In my humble opinion or something similar
Don't we already know it is his opinion? I mean, he is posting it. He wouldn't be posting someone else's opinion, eh? :P

#6
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
I love the passion :thumbup:

Great thread...

Aereshaa, what would you choose to replace Java??

ZekeDragon. how awesome it was for you to
come in defense of Java. I think you truly believe in this
language and from what I've seen of the output, you picked
a winner.

I wonder what this thread would have looked like if
hello world
had to be a GUI?? :rolleyes:

#7
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts

Quote

Aereshaa, what would you choose to replace Java??
Python, Perl or Ruby. Many programmers started with BASIC, but that's hasn't aged well. C is of course my favorite language, but pointers come into it a bit too fast. I personally started with Perl. It's simple, intuitive, and very permissive.

Quote

I wonder what this thread would have looked like if
hello world had to be a GUI??
#include "allegro.h"

int main(){

	allegro_init();

	set_gfx_mode(GFX_AUTODETECT_WINDOWED,150,50,0,0);

	install_mouse();

	textout_centre_ex(screen,font,"Hello, World!",50,20,makecol(255,255,255),-1);

	while(!mouse_b);

}END_OF_MAIN();
8 lines of C! Show me Java!
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Personally, I like Pascal/Lazarus as a beginner language. I'm also partial to C. In some ways, I think making people face low-level code early on is a good thing.

Java is very nice and has a place. Some of my favorite programs are Java programs! However, I also find that trying to code in Java is unpleasant. I've done it, and the libraries are pretty decent, but I dislike the style that tends to emerge of an object's object's object's property/method. In my mind, that makes for ugly code.

Obviously, I'm a fan of C++, and I use Delphi/Lazarus in places where others would use Java/VB. I suspect the sign of a mature programmer may be the ability to recognize a language's place in the programming toolbox, and assess its usefulness in that context. Java is useful. It has its place. It is not everything. The same is true of all other languages.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts

Aereshaa said:

8 lines of C! Show me Java!
Alright then... sorry I refuse to try and compact it. I like readability.
[highlight=Java]import javax.swing.*;

public class HelloWorldSwing
{
public static void main(String[] args)
{
JFrame frame = new JFrame("HelloWorld");
frame.getContentPane().add(new JLabel("Hello World!"));

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}[/highlight]
Comes with the standard library, I happen to know that getting Allegro to work isn't always the easiest thing out there...

Aereshaa said:

Quote

Aereshaa, what would you choose to replace Java??
Python, Perl or Ruby. Many programmers started with BASIC, but that's hasn't aged well.
I agree with Aereshaa here. By far Python, Perl or Ruby would be better choices than Java for a first language. I personally started with Python, and my favorite language is C++. Despite this, I still believe programming with Java is easier than with C++, while maintaining an abstraction C has difficulty maintaining. C is an extremely verbose language, in comparison.

debtboy said:

ZekeDragon. how awesome it was for you to
come in defense of Java. I think you truly believe in this
language and from what I've seen of the output, you picked
a winner.
I don't have to believe in a language, I just enjoy programming with it, and my experience has been it's not terribly difficult to pick up. I'm still learning all of the nuances to C++, of which there are many, and of those Java has mostly eliminated.

WingedPanther said:

Java is useful. It has its place. It is not everything. The same is true of all other languages.
I think that's what I've been trying to say... it's not the end all, nor is it worthless. Thank you, WingedPanther.
Wow I changed my sig!

#10
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
Good Thread...
Not a language war, but a differences post.

Each language has it's advantages and disadvantages,
and more importantly, each programmer sees things differently.
It comes down to...
Individual people, their thoughts and beliefs. :laugh:

#11
oliver.rush

oliver.rush

    Newbie

  • Members
  • PipPip
  • 24 posts
WingedPanther has a point which I have to agree. The best thing to start is Pascal. The language will not allow newbies to do anything really stupid, and will also teach the basics of programming. Besides, it's not good enough to keep someone programming on this language for the rest of their lives (ok, with a few exceptions here).

I wouldn't start with python, ruby, or any other high level language. In my view, it's bad for creating good programmers: first they must understand what are they doing in the low level, they must learn how to create the basics structures, and even suffer a little bit managing memory, memory leaks and segmentation faults.

Now, teach someone in a high level language, and you're binding this person to this language forever (again, exceptions...), and I saw it happening countless times.

#12
JCoder

JCoder

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 245 posts

Quote

I wouldn't start with python, ruby, or any other high level language. In my view, it's bad for creating good programmers: first they must understand what are they doing in the low level, they must learn how to create the basics structures, and even suffer a little bit managing memory, memory leaks and segmentation faults.

I could not agree more. God save us from Java programmers that only know Java (put any high level language here).

On the other hand it depends on what level do you wish to teach programming - is it just for their fun, or they want to actually get some real job. If students are expected to get MSc in CS, teaching pointers, recursion, concurrency, lambda calculus, hardware architecture and all the "hard" topics is mandatory as early as possible - just to filter out the ones that don't have the kind of brain to be a real programmer. This is why ONE language to rule them all is not enough.