AboutBlogContact
TechnologyDecember 15, 2009 2 min read 47Updated: May 3, 2026

CoffeeScript: JavaScript with Class Sugar (2009)

AunimedaAunimeda
📋 Table of Contents

CoffeeScript: JavaScript with Class Sugar

It's late 2009, and Jeremy Ashkenas has just given us a gift: CoffeeScript. If you're coming from Ruby or Python, you've probably spent the last year squinting at JavaScript's function keyword and struggling with this context.

CoffeeScript fixes all of that. "It's just JavaScript," but prettier.

The class Keyword

Finally! No more MyClass.prototype.myMethod = function() { ... }. In CoffeeScript, classes feel natural.

class Animal
  constructor: (@name) ->

  move: (meters) ->
    console.log "#{@name} moved #{meters}m."

class Snake extends Animal
  move: ->
    console.log "Slithering..."
    super 5

sam = new Snake "Sammy the Python"
sam.move()

The Fat Arrow =>

How many times have you typed var self = this; inside a setTimeout or an event handler this year? CoffeeScript's fat arrow => automatically binds the function to the current context.

class Counter
  constructor: ->
    @count = 0
    # The fat arrow binds 'this' to the Counter instance
    setInterval (=> 
      @count++
      console.log @count
    ), 1000

Significant Whitespace

No more curly braces. No more semicolons. CoffeeScript uses indentation to define blocks. It makes your code look clean, readable, and-dare I say-elegant.

In 2009, CoffeeScript is proving that we don't have to settle for the "Good Parts" of JavaScript. We can make the whole language better by transpiling it.

The future is here, and it smells like freshly brewed coffee.

Read Also

Netscape Navigator 4.0: The Messy Arrival of CSSaunimeda
Technology

Netscape Navigator 4.0: The Messy Arrival of CSS

Netscape 4.0 is out, and it's locked in a death match with IE4. Both have 'CSS' support, but they seem to be speaking completely different languages.

JavaScript: The 10-Day Prototype at Netscapeaunimeda
Technology

JavaScript: The 10-Day Prototype at Netscape

Brendan Eich just created 'Mocha' in ten days for Netscape Navigator. It's a tiny scripting language that might just change the Web.

Mojo: AI-Native Programming and Language Features (2024)aunimeda
Technology

Mojo: AI-Native Programming and Language Features (2024)

Is Python finally being replaced? Mojo combines the usability of Python with the performance of C++. Let's explore its unique ownership system.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

Get Consultation All articles