Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Java is not the new COBOL

  craig        2011-11-10 10:40:56       2,426        0    

If you Google “Java is the new COBOL” you’ll find a glut of articles proliferating this mantra. I don’t know its origins, however I’m inclined to think it’s mostly repeated (and believed) by the Ruby community. Ruby, from a developer’s perspective is a low-friction language. A developer can just sit down at a text editor and start banging out code without really thinking about such superflous things as types. Java on the other hand, well, you have to think a lot about types. Java is a statically typed language after all, and it makes the developer do all the heavy lifting.  That alone may answer your question as to why us Java devs think IDEs are so important.

Back when a lot of Java developers switched over to Ruby, Java was a bit stagnant. We hadn’t really seen much happen with the language, and anyone who has written a Swing application can tell you: Anonymous inner classes make your code 5x bigger than it should be. The point being: there’s a lot of boilerplate code present in a typical Java application and this type of code has nothing to do with the application/business logic you’re trying to implement.  It’s just language cruft.

So, I can see why one would have been inclined to say that Java is like a modern COBOL. It had the following characteristics in common with COBOL:

  1. The language is verbose
  2. The language is stagnant
  3. Only big stodgy Enterprises use it

Well, I’m happy to report that these are no longer the case.  Let’s address the issues at hand one-by-one shall we?

Verbose & Stagnant

The cure for these problems lie within a combination of the features found in Java7 & Java8.  Java7 addresses a lot of issues with verbosity, while Java8 pushes the language forward into adopting new paradigms (namely Functional Programming)

Java8 is really a turning point for Java, and shows that Oracle is actually serious about evolving the language while championing it’s proliferation while maintaining backward compatibility. Oracle can’t just gut the language and then post a meme to github to justify itself.  It’s a bit more mature than that.

Java7 addresses verbosity

As Mark Reinhold, chief architect of the Java platform said: Java7 is evolutionary, Java8 is revolutionary. With Java7 we gain some nifty features from Project Coin, a project which  set out to determine what language features could be added to improve developer friction and language readability without being all too complicated to add. Here are some of the features I’m looking forward to:

A switch statement that I’ll actually use

Yes, finally my Java brethren we have a switch statement that actually works on Strings!

switch (lang) {
   case "Java" :
      out.println("I like frameworks!");
      break;
   case "Ruby" :
      out.println("I like Pabst Blue Ribbon!");
      break;
   case "PHP" :
      out.println("I like WordPress!");
      break;
}

My God this has been a long time coming.

Type Inference: Yes, I REALLY DO MEAN Map<String, List<String>>

One of the reasons I like Scala is it’s ability to infer types.  This is such a pain-point in Java, when you use a highly complex parameterized type, both your carpal tunnel flares up and you’re eyeballs want to bleed.

So this:

Map<String, List<String>> peopleByDept = new HashMap<String, List<String>>();

Becomes:

Map<String, List<String>> peopleByDept = new HashMap<>();

They call this enhancement the “diamond syntax” as you are leaving out the types on the RHS of the expression and replacing them with a diamond <>.

I won’t go over all the nice little character-reducing features of Java7, Dustin’s Inspired by Actual Events JavaOne 2011 keynote post does an excellent job, there’s nothing more I could add really.

Java8 Moves the Language Forward

What do we get with Java8?  The two major features are:

  1. Lambdas / Closures
  2. A proper module system (aka Jigsaw)

I’ll only address Lambdas here because the module system is more an “in behind the scenes” feature. In my opening paragraph I spoke about how Anonymous Inner Classes cause so much bloat in a Java application.  Lambdas pave the way out of that mess.
For example…

Component button = new Button("Click me!");
button.onClick(new EventHandler() {
   public onEvent(Event e) {
      out.println("I was clicked!");
   }
}

We’d write, using Lambdas (look ma! no types!):

button.onClick(e => out.println("I was clicked!"));

I like!

Cool Companies use Java too!

Is Java used in the Enterprise? Absolutely.  However AppleTwitterLinkedIn,SquareSpace are all committed to it too. These companies are the antithesis of the stodgy Enterprise.  Through JRuby, Jython, Scala and Clojure companies like these plus countless startups can both directly and indirectly use Java by means of leveraging the vast open source ecosystem written in Java.

Stereotypes…

Given the above facts I think you’ll agree, Java is not stagnant, it’s getting much better on the eyes and fingers and it has been adopted by cool, non-stodgy companies. Then perhaps you’ll also agree it’s wrong to say Java is the new COBOL, just as wrong as saying Ruby is the new Java.

Source:http://tataryn.net/2011/11/java-is-not-the-new-cobol/

JAVA  COMPARISON  RUBY  TYPE  COBOL 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.