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.

About Gordon

Technology enthusiast primarily focused on Java and Open Source projects. Spring Certified Professional and Trainer. http://twitter.com/gdickens http://linkedin.com/in/gordondickens http://github.com/gordonad
This entry was posted in Java, JavaScript and tagged , , , . Bookmark the permalink.

7 Responses to Why Java Developers Hate JavaScript

  1. Pingback: Twitted by drspockbr

  2. Pingback: Tweets that mention Technophile Blog » Why Java Developers Hate JavaScript -- Topsy.com

  3. Pingback: Por qué los programadores Java odian Javascript | EtnasSoft

  4. Pingback: JavaScript, Compreenda-o ou Odei-o | JornalJava

  5. Pingback: Por qué los programadores Java odian Javascript | ciberdix

  6. Pingback: Why Java Developers Hate JavaScript « Jelastic — Rock-Solid Java in the Cloud, Java Server Hosting, Java Cloud Computing

  7. Pingback: Why Java developers hate Javascript « Un poco de Java

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>