Why Java Developers Hate JavaScript

by Guest 1/20/2011 6:21:00 PM
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.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Related posts

Comments

Comments are closed

Add/Search Topic

Post a new topic!



Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

About IT Pepper

IT Pepper is the Official Indian IT & ITES Employee blog! Share your experience, thoughts, feelings or emotions anonymously.

Click here to post your story.

E-mail us Send mail