Was I wrong about JavaScript?

 

Yes, I was. Recently, I’ve taken a good hard look at JavaScript. I’ve used it before but mostly in the capacity of web design. Using JQuery to make your web page do cool stuff is different than really creating a JavaScript application using all of the language constructs. What I’m finding as I use it more is that I may have been wrong about my assumptions about it. Let me explain.

 

I enjoyed doing cool stuff with JQuery but the limited experience with JavaScript as a language coupled with the bad things that I heard about it led me to not have any real interest in it. However, JavaScript is ubiquitous on the web and if I want to do any web development, which I do, I need to learn it. So here I am, diving deep into the language with the help of the JavaScript Fundamentals training course at Pluralsight (great training for a low price) and the JavaScript: The Good Parts book by Douglas Crockford.

 

Now, there are certainly parts of JavaScript that are bad. I think these are well known by any developer that uses it. The parts that I feel are especially egregious are the following:

  • The global object
  • null vs. undefined
  • truthy and falsy
  • limited (nearly nonexistent) scoping
  • ‘==’ and ‘===’ (I just don’t get the reason for coercion)

 

However, what I am finding hiding under the covers of the bad things is a good language. I am finding that I am legitimately enjoying JavaScript. This I was not expecting. I’m not going to go into a huge dissertation on what I like about it, but some things include:

  • Object literal notation
  • dynamic typing
  • functional style (JavaScript: The Good Parts describes it as LISP in C clothing)
  • JSON (better than XML)

There are parts of JavaScript that seem strange to OOP developers like myself. However, just because it is different or seems strange does not mean it is bad. Some differences are quite interesting and useful.

 

I feel that it is important for developers to challenge their assumptions and also to be able to admit when they are wrong on a topic. Many different situations can arise that lead to this, such as choosing the wrong technology for a problem’s solution, misunderstanding the requirements, etc. I decided to challenge my assumptions about JavaScript instead of moving straight into CoffeeScript or Dart. After exploring it, I find that I am beginning to enjoy it the more I use it. As long as there are those like Crockford to help guide me in the right way to code in JavaScript, I can create elegant and efficient solutions to problems and add another ‘arrow’ to the ‘quiver’, so to speak. I do still intend to learn CoffeeScript to see what the hub-bub is about, but now I no longer have to be afraid of JavaScript as a legitimate programming language.

 

Has something similar ever happened to you? Tell me about it in the comments below.

Print | posted on Tuesday, November 8, 2011 9:45 PM

Feedback

# re: Was I wrong about JavaScript?

Left by Michael Washington at 11/9/2011 2:14 PM
Gravatar I just want it to compile.I need a compiler. Too much to ask? :) :)

# re: Was I wrong about JavaScript?

Left by Ryan at 11/9/2011 10:59 PM
Gravatar I've come to the same conclusion over the past two years or so. I've always been the "javascript guy" (begrudgingly) at my office, but once I sat down and really learned how to use it well I'm really loving it. We've adopted mongo for our database, ASP.NET MVC as our web tier, and KnockoutJS as our rich client side framework. Now that I can use javascript everywhere except the C# areas, I actually feel that the strong typing in C# is limiting.

# re: Was I wrong about JavaScript?

Left by Ryan at 11/9/2011 11:03 PM
Gravatar ps I see you've worked with WPF. I highly recommend checking out Knockout. It's MVVM in javascript.

http://www.knockoutjs.com/
http://www.knockmeout.net/

# re: Was I wrong about JavaScript?

Left by Justin at 11/10/2011 10:23 AM
Gravatar @Ryan,

Thanks for the links for Knockout. It looks really cool and we are just starting a new ASP.NET site at my company. It might come in useful. Good looking out.

Your comment:





 

Copyright © jboyer

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski