Dapeng Li

Hungry, foolish and passionate – yet another software developer.

Just Enough JavaScript – Introduction

5 comments

For years I’ve been finding execuses for not learning JavaScript, until I realize that whether you love or hate JavaScript, it can’t be ignored. It’s the language of the web.

During my journey of learning JavaScript this month, I would like to write some notes about this language (a series of posts, more on that later). Preparing these notes helped me understanding JavaScript, and hopeful it might help other developers who are new to JavaScript, or if you’re like me, from a C-based object-oriented programming language.

Just enough

The title of this post is “Just Enough JavaScript”, but why “just enough”? How much is “just enough”?

Here’s the thing: I want to be able to read and write JavaScript code confidently, but not planning to be a JavaScript ninja.

A new language called CoffeeScript got popular since its inception in 2009. CoffeeScript is a small language with Ruby-like syntaxes and compiles into JavaScript. CoffeeScript is simple, elegant, and “it’s just JavaScript”.

I set the scope/goal of learning JavaScript (call it iteration #1) as this:

Learn “just enough” JavaScript so that I can understand the JavaScript compiled by CoffeeScript.

I choose that scope and learn CoffeeScript along the way based on the following considerations:

  • Developers use CoffeeScript for production projects, which means CoffeeScript and the JavaScript it compiles to will cover enough features in JavaScript to get your work done.
  • To use CoffeeScript effectively one should understand the compiled JavaScript code from the CoffeeScript code. Abstraction is great, but abstraction leaks.
  • JavaScript has some quirks, the JavaScript code compiled from CoffeeScript are idiomatic JavaScript – means they’re good JavaScript code. One can learn to write JavaScript from reading those good code.
  • There’s a very small learning curve for CoffeeScript so it’s not a big commitment. Spend some time learning CoffeeScript and enjoy the productivity boost; even if CoffeeScript is not relevant in the future, what I’ve got is knowledge on JavaScript. Either way, that sounds like a good investment to me.

Plan

At this moment I’m planning to write three posts, most of them are from the books and resources I found helpful, the topics are:

  1. Variable Scope and Object
  2. Function
  3. Prototype and Inheritance

This series will not cover all language features of JavaScript used by CoffeeScript, but should be a good start.

The latest version of CoffeeScript as of this writing is 1.3.2.

A note on books and resources:

I started with JavaScript: The Good Parts 1 and about 1/3 into the book I realized it’s not a book for developers who just started learning JavaScript; next I followed Eloquent JavaScript 2 as a tutorial, some documentations on MDN; then I found JavaScript: The Definitive Guide 3 to be a good reference and detailed explanation on many concepts; at that moment revisiting JavaScript: The Good Parts made more sense.

PragProg’s CoffeeScript book 4 is the one I followed for learning CoffeeScript, and of course, CoffeeScript.org.

A note on the content I borrowed:

When I was trying to assemble the content for the posts based on various resources I read, I end up referring to David Flanagan’s book JavaScript: The Definitive Guide, and what you will see is just a rehash of some sections from David’s book.

I felt bad about this blatant copying approach, on the other hand I felt equally bad if I tried to mix my words with excerpts from the book, or some my own examples only cosmetically different. That is a book of quality: concepts are well explained, examples are concise and clear. If you’re looking for a good JavaScript resource, I highly recommend purchasing JavaScript: The Definitive Guide.

All examples are updated to conform more with Douglas Crockford’s JSLint recommendations, except the ones illustrating language features, such as variable hoisting and closure in a loop.

OK, the ground is set, let’s begin. JavaScript!


1. JavaScript: The Good Parts by Douglas Crockford, Amazon Link

2. Eloquent JavaScript: A Modern Introduction to Programming by Marijn Haverbeke, Amazon Link

3. JavaScript: The Definitive Guide, 6th Edition by David Flanagan, Amazon Link

4. CoffeeScript: Accelerated JavaScript Development by Trevor Burnham, PragProg Link

Written by Dapeng

May 15th, 2012 at 8:27 pm

Posted in Programming

Tagged with

  • If your keen on trying a fun and effective way of learning JavaScript you should try out Code Avengers at 
    http://www.codeavengers.com/
    We would be really interested on any feedback you have

  • Peternl

    like your post. relate to it as being in a similar situation as a developer. tend towards the use of google app script in webapps. especially since the latest additions as presented in google i/o 2012. what is your take on these kind of developments and opportunities for developers?

    • luislee818

      I haven’t worked with Google App scripts before.

      Generally when considering if a technology worth my effort to learn (if I can choose), three things come to my mind (some of them come from Chad Fowler’s book):
      1. In which point of the life cycle is this technology? Bleeding edge, mature, dying? 
      2. Who owns the technology? Who’s in control of the future of it?
      3. How would learning this technology contribute to my skill set and my competence in the the market I intend to compete in?

      To extend a little bit from technology to tools, here are two small examples:
      Because I still have a lot to learn to be a well-grounded developer, I would rather choose learning Bash than PowerShell, Vim over ReShaper and Visual Studio since the formers would be better invest of time for me.

      • Bloemgracht12

        These are certainly important and valid points from one’s own developers perspective. In addition to that I also tend to look towards the ‘pain points’ in the business communities and the attractiveness of software-apps to help relieve these.
        This for me is also a way to get less fearfull about my developer’s future, and one’s contribution is more broadly focused and complete. 

        • luislee818

          Very well said, I agree.