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.
Pingback: Twitted by drspockbr
Pingback: Tweets that mention Technophile Blog » Why Java Developers Hate JavaScript -- Topsy.com
Pingback: Por qué los programadores Java odian Javascript | EtnasSoft
Pingback: JavaScript, Compreenda-o ou Odei-o | JornalJava
Pingback: Por qué los programadores Java odian Javascript | ciberdix
Pingback: Why Java Developers Hate JavaScript « Jelastic — Rock-Solid Java in the Cloud, Java Server Hosting, Java Cloud Computing
Pingback: Why Java developers hate Javascript « Un poco de Java