Never? I wouldn’t go that far.

OK, programmer geek time.

I subscribe to a newsletter that mentioned an article saying “It *never* made sense to learn Java“.

I agree, and I disagree.

First, I generally agree with the guy because yes, just about anything you can do in Java you can do in C++, and perhaps better. I say perhaps because in all my years of using many programming languages I have found that people think C++ is a great object-oriented programming language, but it’s not. It’s a language where you can write OO-like code but there are lots of little idiosyncrasies involved that can make true OO difficult. C++ is a fantastic generic language tho, witnessed by templates.

I remember when I worked at Metrowerks, a developer tools company. Java had just come out. I was hired in their developer tech support group, and myself and another guy started on the same day. I was going to do Mac support and they gave him a bunch of “Learn Java” books and he became the Java guy. Java was all new, exciting, held the promise of “write once, run anywhere” but of course we all quickly learned that didn’t really work out well and over the years Java fell from grace tho it found a niche. When I worked on the Tango product, Java Beans was becoming a big enterprise thing so that’s the first time I got to actually do some Java dabbling, and while I thought it did a few things right and cool over C++, I still didn’t see the big deal. Ever since NeXT bought Apple, while it took me a moment to grok the syntax of Objective-C, I’ve loved it ever since because between that language and a good library like Cocoa (along with good tools to complete the development chain), I’m empowered to do true object-oriented programming and geez… I really haven’t had any desire to use C++. Sure, I did in a lower-level framework of a past project but when I had to use C++ and Objective-C side-by-side, there was no question that, especially with the framework support Apple provided, that ObjC was a far better language tool and you could really see the shortcomings of C++ as an OO tool. I’ve used a lot of other languages over the years, and well… while C++ is still a good language, it’s not the be-all-end-all.

But never made sense to learn Java? I think the problem with that premise is we’re looking at languages first. Most people do this, and IMHO it’s backwards.

We shouldn’t pick a language then forge ahead to solve a problem. We need to look at the problem, then utilize the best tools to solve that problem. The problem will dictate what languages, what libraries, what tools we choose. If you want to write Android apps, you’re going to have to learn Java. If you want some enterprise job, they may require Java because that’s what their backend uses. A project I’m working on now is separated into two main components: a background daemon that does the heavy lifting, which then communicates with a GUI app for the user to interact with. We are doing the GUI in Cocoa because that makes the most sense for writing GUI apps on the Mac. We write the background daemon in C++ using mostly generic libraries (e.g. standard lib, POSIX, BSD, some company-internal libraries) so the daemon can be easily reused on both Mac and Linux. The problem requirements dictates the tools and languages used, not the other way around.

But hey… if I want to answer his question, I’d say learning C++ is probably an evolutionary dead-end as well. If I was going to teach my kids programming today? I’d probably start with Python or maybe Ruby, along with web-based languages like HTML and XML. That will allow them to learn basic language structure without a lot of the complexities of C/C++/ObjC (e.g. pointers, memory management, etc.) but also giving them a lot of default power to do useful work because of robust library support. After that, see where they wanted to go. If they wanted to write desktop or mobile GUI apps, it’ll depend upon the platform: Mac OS X or iOS? learn ObjC and Cocoa (Touch). Android? learn Java. If they wanted to write web apps, JavaScript, CSS, AJAX, and all that. It just all depends upon what they want to do, what problem they want to solve.

So yes, I can understand and accept the author’s criticism of Java, but I do believe he’s answering the wrong question. We must look at the requirements of the problem to solve and let that shape what tools we choose, including language choice.