MadJS February 2012 - How CoffeeScript & Jasmine Made Me a Better JavaScript Developer

Recently, I spoke at the MadJS group about CoffeeScript & Jasmine. My slides appear below. Since Slideshare doesn’t show my notes, you can either download the keynote file above, or you can read the notes below, which I’ve pulled out of the slides. I feel that the notes are necessary to know what I’m talking about, and I hate reading slide decks where there’s no context or notes. This isn’t going to be as helpful as having seen my talk in person, but hopefully you get some value out of my talk and the notes together:

CoffeeScript & Jasmine - MadJS February 2012

View more presentations from Matt Gauger.

How CoffeeScript & Jasmine made me a better JS developer

First, an introduction:

I work at Bendyworks

Which leads me to my dilemma

I felt like an impostor when it came to JavaScript.

So, what does this have to do with CoffeeScript?

CoffeeScript History


CoffeeScript has Good Parts?

So why use CoffeeScript? What are its good parts?

This might be the most important part of the talk, and reason to use CoffeeScript

Criticisms of CoffeeScript:

That isn’t to say that CoffeeScript eliminates all bugs

Some examples of CoffeeScript helping you with bugs:

Coercing the wrong types


a ?= b

Lastly, wrapping up your code.

(function() {
  console.log "hello world!";

Simpler Looping

Jeremy Ashkenas’s Example

for item in list
  process item

Intention gets obscured by managing the loop, in JS:

for (var i = 0, l = list.length; i < l; i++) {
  var item = list[i];

In Review: CoffeeScript will help you:


(My) History (with Jasmine)

Why Jasmine?

The example on the Jasmine site:

describe("Jasmine", function() {
  it("makes testing awesome!", function() {
describe ('addition', function() {
  it('adds two numbers', function() {
    expect(1 + 2).toEqual(3);

How should we test JS?

Easier to test = better code

Follow TDD/BDD:

red, green, refactor

Jasmine is designed to be standalone

Some really cool features of Jasmine:


Setup and teardown:


Spies: built-in mocking & stubbing

But what about legacy codebases?

Start simple.

Fix one bug. (red, green, refactor)

Rewrite the affected code in CoffeeScript.

Start grouping in files / modules.

Keep improving the codebase.

Lessons Learned:


Resources to learn more: