Aug
19
2010

Giving JavaScript a Fair Evaluation

Here’s the Enterprise Developer’s typical introduction to JavaScript:

  • Developer is assigned a task that requires JavaScript. Developer already knows Java and decides that this is more than enough background to dig into JavaScript.
  • Developer searches for a code snippet that performs the desired task.
  • Developer finds code snippet and understands 60% of it. Developer does not care about the 40% that looks weird. Developer copies snippet and pastes it into their web page.
  • Code snippet doesn’t work. Or worse, code snippet only works in Firefox.
  • Developer hacks on snippet for an hour.
  • Developer may or may not ultimately succeed. Either way, Developer dismisses JavaScript as a steaming pile of turds.

Sound familiar?

We developers sure are passionate about technology. We have our favorite programming languages, frameworks, and tools. We are also highly susceptible to forming a long-lasting impression about a particular technology based solely on our first experience. If our first attempt at using a technology works, we get a nice tingly feeling and that technology becomes a life-long friend. But if we struggle, get frustrated, or fail, we have the tendency to dismiss the technology as junk. And once something is on the junk pile, it is almost impossible for it to get a second look.

Photo Source Used under Creative Commons Attribution 2.0 Generic License

Hence the all-to-familiar attitude towards JavaScript: ‘You burned me once JavaScript; you are dead to me’. I ask though, did you really give JavaScript a fair shake? JavaScript guru Douglas Crockford elegantly sums up this attitude:

“JavaScript is the only language that I’m aware of that people feel that they don’t need to learn it before they start using it.”
– Douglas Crockford

Because of its familiar syntax and ubiquitous use across the internet, JavaScript is almost begging us to dive right in. But when you also consider that most JavaScript programs focus on manipulating DOM elements, and that these DOM APIs are awkward, inconsistent across browsers, and buggy, a developer’s first experience with JavaScript is all-but-guaranteed to be a nightmare.

So, what does it take to succeed with JavaScript? It’s simple. You must approach JavaScript with the proper attitude. You need to become a JavaScript Scholar. You will never succeed if you don’t take a step back and learn the fundamentals of the language. JavaScript is *nothing* like Java, C#, or any other strongly typed language that you may be used to. Its syntax is familiar, but that’s it. JavaScript is a functional language with prototypal inheritance that has far more in common with Lisp or Scheme than it does Java. You will continue to be frustrated if you think you can ‘get by’ based on your existing skill set with Java or C#. While learning JavaScript, accept that you will have to learn new programming concepts along the way. And recognize that this is OK. Actually, it’s fun!

If you are brand new to JavaScript, here is my advice for getting started.

  • Learn the language itself. Don’t start with a specific task like ‘HTML Form Validation’. Don’t start with a popular JavaScript library like Dojo or jQuery. Start learning JavaScript by learning JavaScript. (I know, it sounds crazy!).
  • Buy David Flanagan’s ‘JavaScript: The Definitive Guide’. If your department won’t splurge on education materials, buy it with your own money. It is well worth the investment. Open up to page 1 of this book and start reading. You’ll be tempted to skim over the parts that look familiar, but don’t. Remember, only the syntax is familiar, nothing else is. This book is one of the very few JavaScript books that I recommend. For the experienced developer that is looking to learn JavaScript, it is perfection.
  • Set up a ‘playground’ to try out quick snippets of JavaScript and immediately run them. A great way to do this is with the Console View of the Firefox add-on Firebug.

But before you do any of that, your first step in becoming a JavaScript Scholar will be to take a few lunch-breaks and watch the ‘Crockford On JavaScript’ series of videos. You may find these a bit dry, but they are an excellent introduction to the history of JavaScript, as well as the fundamental concepts of the language.

We will soon dive into Dojo, but I consider knowing the basics of JavaScript to be a prerequisite. If you understand JavaScript, learning Dojo will be a breeze. If you don’t take the time to do it, Dojo too will end up on the junk pile, and that is just sad.

Related Posts

About the Author: Dan Lee

Dan Lee is a Software Developer and Dojo enthusiast. He is the creator and co-developer of the ReminderFox Firefox add-on and the addictive iOS game, Rhymo. Find him on Twitter here. Any opinions expressed on this blog are his own, and not of his employer.

7 Comments + Add Comment

  • Nice quote, “Don’t start with a popular JavaScript library like Dojo or jQuery. Start learning JavaScript by learning JavaScript. (I know, it sounds crazy!).”

    Look forward to your future posts!

  • Nice post! Your typical introduction of an enterprise developer is true to my own experiences. Enterprise users are almost never introduced to JavaScript through some large front-end framework. Somehow the term enterprise has come to mean large apps recently. You certainly present that it is much more than that.

    Looking forward to future posts! Keep up the good work.

  • Nice site. Look forward to seeing what you have to say about my toolkit and language of choice.

  • Dan, great article! I really like how you are able to take a step back and remember or perceive how lost others feel when they are starting out. Remembering what it felt like *before* you understood a language is really important. After you understand it, its easy to assume everyone does.

    Great post, and I am looking forward to your future posts!

  • Great article! That’s what I’ve been telling my colleagues, ” Start learning JavaScript by learning JavaScript”. The problem is they were stuck to search-copy-paste plugins, that they even doesn’t know how to “alert” (seriously). Looking forward to your future posts!

  • This is exactly how I started out :D

  • I wonder, how do you well know about “us”? :)
    This article,http://www.enterprisedojo.com/2010/09/09/the-four-stages-of-javascript-grief/, also struck me…

    Thanks!

Leave a comment