Why Java Developers Hate JavaScript

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

This article comes from Dzone’s selection of top articles from this last year, and it’s written by our friend Gordon Dickens, a Jelastic user and the first person to present Jelastic in Philly.

Why Java Developers Hate JavaScript

As a Java developer, I used to hate JavaScript. At one time I used to say “friends don’t let friends use JavaScript”. In recent years, JavaScript has become required for a flexible & feature rich user experience. WIth the advent of tools such as JQuery and GWT many of these issues have been minimized. Also, I took the time to read more about JavaScript. The book that really opened my eyes is JavaScript: The Good Parts. So… What do Java developers hate?

  • JavaScript may look like Java, smell like Java and even taste a little like Java, but it does not behave like Java
  • Variables are global in scope
  • “this” has different meaning based on the invocation type (learn this for your own sake)
  • Braces do NOT guarantee scope
  • Functions are first class citizens, not classes (avoid classes, you will set yourself up for disappointment)
  • Functions are objects, not simply methods to a class
  • Variables are dynamically typed objects
  • JavaScript often fails silently (this is for user experience)
  • Difficult to debug (use FireFox & Firebug addon)
  • Semicolons are optional (bad idea, put them where you want them)
  • Functions always return values, a value or “undefined”
  • “new” has some specific assumptions, not simply creating an Object
  • Cross browser compatibility (use jQuery or GWT to address most issues)

What should you understand about JavaScript?

  • Functions – First class citizens, the primary object in JavaScript
  • prototype system – Object.prototoype, object linkage, delegation, hasOwnProperty() method, etc.
  • closures
  • currying
  • the 4 invocation types: method, function, constructor & apply
  • dynamic languages such as groovy, ruby, etc. they share many similarities

What should you forget when using JavaScript?

  • Classes
  • Scope using braces
  • Strong typing

In summary, it is an entirely different language with many syntactical similarities. JavaScript is very power and flexible once you understand how it behaves. I highly recommend the O’Reilly book (mentioned above), its a short read and packed with awesome facts.

Source: Why Java Developers Hate Java Script (gordondickens.com)

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone


Leave a Reply

Subscribe to get the latest updates