8 ms·
"Should I still learn Java?" Answered: Yes.
- retube 16y agoIt's nice to see a positive java posting on HN for a change!
- sjs 16y agoDon't worry, we seem to be voting up all the negative comments to balance things out. :p
- jinushaun 16y agoI can't say I disagree with the author. Even with all its troubles, there's simply too much legacy Java code to abandon. Much like Cobol and Perl, there will always be a need for Java programmers to--at the very least--maintain existing code. If you're a complete newb, learning Java will also introduce you to the C-like family of languages. (Although I say everyone should learn C first in order to appreciate memory management)
- Garbage 16y ago> learning Java will also introduce you to the C-like family of languages Aren't Java and C, different family of languages?
- masklinn 16y agoJava is part of the C family of languages, you can draw a pretty straight line between C++ and most of Java's features (or non-features, or lacks of features).
- uriel 16y agoMany C programmers would argue that C++ does not belong to the C family of languages.
- wtallis 16y agoThe basic grammar and syntax are pretty much the same, as are most of the fundamental data types and their behaviors, and many other things. There are obviously a lot of differences, but if you know one language it usually isn't hard to read well-written code in the other language.
- leon_ 16y ago> as are most of the fundamental data types and their behaviors Don't ever tell that any C-novice coming from Java. Or you will have fun with interesting array constructs or functions returning pointers to variables created on the stack, etc.
- JoachimSchipper 16y agoAlthough a Java translation of a C program still looks C-ish, I agree; idiomatic Java is very different from idiomatic C. (This is not surprising; Java is intended to be "C++ done right", and idiomatic C++ is rather different from idiomatic C.)
- pedanticfreak 16y agoI think he means C-style syntax rather than C family of languages. Java certainly is made to read like C and C++ more than anything else even if it is very different under the hood.
- masklinn 16y ago> Much like Cobol and Perl, there will always be a need for Java programmers to--at the very least--maintain existing code. Sure, if your goal is to get a job maintaining mainframe systems in banks for the next 30 years Cobol or Java are very good ideas. On the other hand, there are already huge heaps of mediocre java programmers available for cheap, so it's not like the demand is that high.
- pedanticfreak 16y agoIt depends on what you think is cheap. But Java developers that even know a little are doing fairly well right now. Java developers that know a lot can demand top dollar and there are tons more opportunities to earn that amount than with pretty much any technology.
- yason 16y agoJava will certainly not teach you anything else from C but how to put statements in braces and a couple of constructs with similar syntax. And if someone thinks that is C, he doesn't know C.
- axod 16y agoCompletely agree. I'll be teaching my kids Java first, if they want to learn programming.
- nailer 16y agoMy kids, like their dad, won't have the patience to create a singleton main object, with a print method, just to run "print 'hello world'".
- axod 16y agopublic static void main(String[] a) { System.out.println("Hello world");} Yeah you're right. That's an insane amount of typing which would take any kid hours. I had to muster up all of my patience just to type all that code out. You're right! Java is so verbose! Your "argument" if you can call it that, is like people saying lisp is crap because it uses too many brackets.
- Xk 16y agoSo let me say first that Java was my first language, and I don't believe I've been corrupted in any nasty ways. I was 10 when I learned Java, and it always threw me off having to copy those first two magic lines which I never understood. What is 'public class'? Why 'static'? What even does the word 'void' mean? 'String[]'?! Sure, after a few months I figured out the meaning of all of those words -- but it wasn't nice having to do that "open up last file I wrote / copy magic header to new file". I don't think it's wrong to teach Java as a first language, but I think that there are better first languages which show what real computer science is faster than Java does. Less coercion of a language to do what you want and more free-flowing ideas.
- Homunculiheaded 16y agoFirst off, even removing line breaks it is still verbose. I can't think of another language that's even close. Even C++ would give you a shorter version. Far more important though is how much stuff is in that one line of code that needs to be understood in order for what you are typing to be more than just arcane magic words. Pedagogically speaking that is an awful way to get started, so I think the claim that that is not a great way to teach kids is pretty valid. To be fair I fully agree that 'Hello world' is not a good way to assess the worth of a language in general, but the ease of getting started is a valid concern when using a language to introduce programming
- smanek 16y agoAs someone who rather dislikes Java, I'd still tell others to learn it (but certainly not as their first or even second language - it teaches too many bad habits). The main reason would simply be that a lot of interesting problems require tools/libs written in Java (Hadoop and family, Lucene, etc) if you want to get off the ground quickly and efficiently. Eventually, you're going to need to tweak your tools - so learn Java. Furthermore, a lot of far better languages run on the JVM and have Java interop (Clojure, Scala, etc). Strictly speaking you don't have to know Java to use Clojure. But in practice, it's going to make your life miserable if you don't know the Java libs reasonably well.
- axod 16y agoAs someone who programs Java a fair bit, what bad habits do you believe it teaches?
- wladimir 16y agoI'd like to know as well. IMO, one of the few things Java is actually good for is to learn object oriented programming. - It has a pretty simple syntax, as it doesn't have too many strange or unintuitive language constructs. - Its verboseness forces the learner to understand what is going on and be thankful for the magic that more dynamic languages provide. - It's statically typed so it forces the learner to think about types. - It's hard to shoot yourself in the foot with beginner mistakes like with C++/C. Still, it's a good preparation for learning C/C++ later. - Clear compile-time and run-time error reporting. And so on...
- smanek 16y ago- It is just barely object oriented (and Alan Kay agrees with me on this). Checkout CLOS and the MOP or Smalltalk sometime for a good object system. - No. Java has a complex syntax. Take a look at the grammar sometime. It's 10s of times longer than Scheme's (see: http://java.sun.com/docs/books/jls/second_edition/html/syntax.doc.html http://java.sun.com/docs/books/jls/second_edition/html/synta...). You just like it because it's almost, kind of, a little, like C and C++. - It is, in large part pointless verbosity. Explain to me how: Map<String, Pair<Integer, Set<String>>> data = new HashMap<String, Pair<Integer, Set<String>>>(); is useful. Explain how 20 lines for a strategy pattern or a visitor pattern is better than just having built in first order functions and multiple dispatch. - The type system is abysmal (and not sound). Runtime Erasure of generic types? Casts? Nulls? - I do agree it is better than C++ for most purposes though ;-)
- yason 16y agoLearning Java itself is simple. As a language it doesn't offer particularly anything that isn't already found in other languages, given you know other languages. The biggest effort would be to learn the libraries and you basically can't do that unless you're regularly writing code that interfaces them. But that you can do from Clojure or Scala or whatever language that runs on JVM.
- swah 16y agoFor someone that didn't grew with Java, what is hard is finding your way on the ecosystem. If you're a newcomer, and you're going to do a website in Python, you soon find out Django, which recommends you to use, lets say, Apache and PostgreSQL. You feel good because you got a sense, immediately, of what you need to know and install to run a website. Compare that with Java... I'm using Clojure with Jetty now, I haven't launched yet, and I'm afraid of things like application servers and doing everything with enormous amounts of XML.
- rb2k_ 16y agoMy main problem with Java isn't the language itself. I think it's a pretty ok language as far as statically typed ones go. My problem with Java is the way it's currently being used. E.g. using annotations to fix things that the language won't let you do elegantly. There's a lot of horrible overengineering for relatively simple problems (you don't HAVE to use GOF patterns, they're just a suggestion for a solution. If you don't have the problem, don't use the solution!). While there are a few nice libraries (e.g. http://jsoup.org/ http://jsoup.org/ ), even those usually don't have examples. Especially when you don't know the library yet, it's wonderful to get a few minimalist examples how to use it. Just compare: Java: http://jsoup.org/ http://jsoup.org/ Ruby: https://github.com/hpricot/hpricot/wiki/ https://github.com/hpricot/hpricot/wiki/ or http://nokogiri.org/ http://nokogiri.org/ While both Ruby HTML parsers have a simple example right on the starting page, I have to make at least 6-7 targeted clicks for Jsoup. The same even goes for the core libraries. Just look at Ruby's String class: http://www.ruby-doc.org/core/classes/String.html http://www.ruby-doc.org/core/classes/String.html And then look at Java's String class: http://download.oracle.com/javase/6/docs/api/java/lang/String.html http://download.oracle.com/javase/6/docs/api/java/lang/Strin... In Ruby, almost any method has a small example. The Java doc only has an example for the constructor...
- Nitramp 16y agoMy main problem with Java isn't the language itself. [...] My problem with Java is the way it's currently being used. Absolutely agreed. Java has some weak spots, but the really bad things (and the most criticized things) are not in the language per se. E.g. the complete over- and abuse of XML for anything. Complex Ant build scripts. The whole EJB disaster (the older versions, that is). Bad APIs (though in all honesty, most of the really bad ones are 3rd party and not from Sun). The over-use of dependency injection, beans, etc. without a justifiable reason. Many of these things are just stuff we learned to do better by now, for example JSON and/or Yaml over XML configuration, and convention over configuration. That lower overhead and higher understandability are more important than some would be architect's dreams. On some things the jury is still out (e.g. more or less functionality in basic classes like String, List, ...). Overall, I think some people are overlooking the many benefits Java has made available to the main stream. It's entirely possible to write beautiful Java code, you just have to go the extra mile of leaving the convention sometimes.
- fierarul 16y agoI would say learn Java not because there is a lot of existing Java code (using legacy code as the main argument is a bit presumptuous) but because the JVM is a versatile and powerful foundation for your code: profiling, debugging, hot class-swapping, monitoring are really well done. Then there's the ton of libraries for everything and good tooling. Of course, the language itself might be a bit too verbose for some people but I'd rather take Java and the JVM then another language where I'm missing some of this. I guess most people don't differentiate Java the language from the Java Virtual Machine and that's a shame. I could be doing JRuby on the JVM and be happy then drop into Java for some optimized code. Thus, Java just happens to be the "C" programming language of the JVM.
- wlievens 16y agoI think a great way to learn programming is to start with the simplest languages. Start with Scheme. It doesn't even have proper objects and classes, so you'll be forced (guided, actually, if you go the SICP route) to implement them yourselves. This teaches you in an elegant way about essential concepts in programming, but manages to keep your head clear and unbiased about the many different ways to do things, whereas a language with a strong fundamental paradigm (i.e. Java) may bias you forever. Then learn C. It couldn't be more different from Scheme, but that's a good thing. It forces you to think about things you thought you didn't reaaly have to think about - such as memory allocation. With a solid basis in these two languages, you've covered just about every paradigm or building block of programming languages you can imagine. Learning another language then becomes trivial, and for bonus points, you'll be a lot better programmer at those languages too.
- johnayres 16y agoMight be worth checking out Kenya (a subset of Java for beginners, comes with a nice IDE) http://www.doc.ic.ac.uk/kenya/ http://www.doc.ic.ac.uk/kenya/
- RodgerTheGreat 16y agoAfter a brief skim, it reminds me of Processing. (http://www.processing.org http://www.processing.org)
- kls 16y agoWhile I agree with the authors summation, Java will be here forever and a day, the real question one has to ask one's self is will Java continue to receive the developer mind-share in the future? this generally translates to all the cool problems are being worked in the mind-share language. The second question is will Oracle further drive away developer mind-share? I think the answer to both of those are self-evident and when analyzed in that light learning Java looks a lot like learning COBOL around the time Java hit 1.2. The cool stuff was happening over in Java which was now stable enough to take off. I would say the big difference at this juncture is there is no clearly evident replacement at this point. As their was with Java and COBOL, but I do believe the mind-share shift has happened and we are all looking for the next king amount the court.
- rbanffy 16y agoLearning Java the language is not a big problem. Preventing a young Java programmer from becoming an architecture astronaut is. Most Java frameworks I have played with seem made by and for them (it's like they have been playing design-pattern bingo) and exposing young programmers to architecture astronautics may damage them irreversibly. By the time they start talking about real-life stuff like they are method invocations, they are lost.
- PaddyCorry 16y agoNice article. Good to see a positive Java piece. I'm formerly a COBOL developer, now working with Java. Did anyone else think that his main argument for learning Java could also work for learning COBOL? (substitute COBOL for Java in the quote below) <quote> It's not going to go away any time soon. There's too much momentum. There's no need to worry. Ever since the launch of Java I've heard that it's going to be gone or unusable tomorrow. History shows that just doesn't happen to popular programming languages. If you learn Java now, you may still be using it 20 years from now. Or 30. </quote>
- rbanffy 16y agoJava is the COBOL of the 21st century. It's every bit as elegant and exciting.
- axiak 16y agoLike others here have said, my main issue with Java is not the Java language itself, but rather with the culture of overcomplexity. As an example, every web framework has the issue of abstracting pieces of templates in a consistent manner. Django solved this by writing their own (simple) template language that supports template inheritance. The java ecosystem seems to have solved this with Sitemesh, a library that implicitly decorates xhtml for you, based on another XML configuration. I see a few things wrong with this approach. For one, it presupposes all of this nice template work is only ever going to be needed for xml/html. Need to send a text email? Need to make a latex document? Second, it's entirely implicit. This is a common theme with java libraries-- if the usual task is too verbose, usually implicit is the solution. I don't think there's a good reason Java can't be concise and explicit. It just isn't the thing to do.
- regularfry 16y agoYour point is absolutely correct, but I think your example is a little unfair. There are a ton of template libraries that handle inheritance or code sharing in both Python and Java, some restricted to XML, others freeform. Saying that any one on either side has "solved" it ignores the others that have approached the problem from another direction. For my money, a better example is the comparison between http://www.oracle.com/technetwork/java/index-jsp-135475.html http://www.oracle.com/technetwork/java/index-jsp-135475.html and http://www.python.org/dev/peps/pep-0333/ http://www.python.org/dev/peps/pep-0333/. Or http://rack.rubyforge.org/doc/SPEC.html http://rack.rubyforge.org/doc/SPEC.html, for that matter.
- lelele 16y agoYou should always understand the programming language your platform of choice is built upon. That means Java if you are going to use the JVM in some way, just like it means C if you are going to develop native applications on Windows or Linux. I have always been astonished at VB6 programmers which ignored what a Variant was, when they were using such datatype all the time.