There are a surprising number of programming languages named after coffee, including Java, JavaScript, and Mocha. Is there one you haven’t heard of before? CoffeeScript.
The first stable version of CoffeeScript was published by Jeremy Ashkenas in 2010. It started as a small side project and grew quickly. Even JavaScript creator Brendan Eich said that CoffeeScript was a great idea that would be the template for the future of JavaScript. And he was right.
Today, CoffeeScript is not as popular as it once was, but it has had a huge influence on JavaScript, TypeScript, and many front-end development processes that it still uses today.
Learn something new for free
Why was CoffeeScript created?
When the first stable version of CoffeeScript was released in 2010, JavaScript development wasn’t the same as it is today. JavaScript was just JavaScript. There was no TypeScript, no ES6, and nothing that compiled to JavaScript from another language. There were no front-end frameworks, either, until the same developers who wrote CoffeeScript also wrote Backbone in 2010. (There was jQuery, but it’s not really a framework.)
The truth is that JavaScript was never taken seriously and was mainly used to create dynamic effects on web pages: front-end developers made things pretty with CSS and added effects with JavaScript, usually using jQuery.
Jeremy Ashkenas thought the language had great features and a lot to offer, and that with a few changes he could make it better. He created CoffeeScript to bring the great features of JavaScript to the forefront and hide the more complex and confusing features by adding “syntactic sugar” – syntax used in programming languages to make them easier to read and use. He also created CoffeeScript so that it could be compiled to plain old JavaScript. This wasn’t a new concept, but CoffeeScript brought it to the mainstream.
What was CoffeeScript used for?
CoffeeScript was used everywhere JavaScript was used, by developers and companies who preferred its syntax. It was primarily used for back-end development initially, and many of the articles you’ll find online will say it was only for back-end development. This isn’t entirely true; once developers set up the right workflow to compile the code for the browser, it worked well for front-end development as well.
One of the biggest companies to adopt CoffeeScript is Dropbox. All front-end code rewritten in CoffeeScript CoffeeScript was released in a week in 2012. They thought they fixed a lot of JavaScript’s syntax problems. After all, Brendan Eich had written the original version of the language in just 10 days in 1995, and very few changes had been made to the language at that time. JavaScript had evolved too slowly, and CoffeeScript added a lot of useful features.
The development team Atom text editorThey also adopted CoffeeScript, a tool used by many developers to write code, and made it the official language of their codebase.
Is CoffeeScript obsolete?
CoffeeScript is not a dead language. The latest version is 2.6.1, which was released in October 2021, so it is still being developed and is a great language to learn. You can learn a lot about what you can do with a language that compiles to JavaScript and how you can build any project with JavaScript. You might end up liking the syntax and preferring to use it.
But the problem is that learning this language won’t get you much in the job market, as not many developers know or use the language. Even if you do find a job that requires knowledge of CoffeeScript, you’ll most likely end up working with legacy code or converting CoffeeScript to TypeScript or JavaScript.
There are currently a few job postings on LinkedIn, primarily from Dropbox, that mention this. But even those Converting CoffeeScript to TypeScriptThe Atom team also converted their codebase to ES6 JavaScript around the same time.
How JavaScript and TypeScript Caught Up
The first version of TypeScript was released in October 2012. The language was a superset of JavaScript developed by Microsoft, with very few changes to JavaScript, only the addition of types, which made it easy for JavaScript developers to pick up TypeScript quickly and write code that was less error-prone.
Even Dropbox, one of CoffeeScript’s biggest advocates, has noticed the benefits of TypeScript. By the end of 2015, TypeScript is starting to get more attention than CoffeeScript.
In 2015, the ES6 version of JavaScript appeared. Although the ES6 version did not adopt CoffeeScript’s unique syntax, it did adopt many of the language’s developer-favorite features. Some common features between JavaScript and early versions of CoffeeScript include:
- Use true classes instead of non-standard prototype objects.
- Arrow functions to reduce function redundancy.
- use
let
Define the variables.
- Class inheritance.
- of
in
Comparison operator.
- Declare an array over multiple lines.
- String interpolation.
At that time, browsers ran JavaScript in different ways, so what worked in one browser didn’t work in another, and very few browsers supported the new ES6 version. But another thing JavaScript developers learned from CoffeeScript was the ability to compile another language into JavaScript.
of Babel JavaScript libraries were released around the same time. Babel was a JavaScript compiler that allowed you to write code in ES6 version and have it compiled to JavaScript compatible with all browsers. And developers were already familiar with compiling JavaScript from using CoffeeScript and TypeScript. This was a breakthrough.
These changes in the JavaScript ecosystem made CoffeeScript a thing of the past and its adoption began to decline.
What is the difference between CoffeeScript and JavaScript?
Jeremy Ashkenas took inspiration from Python, Ruby and Haskell when developing CoffeeScript. Here are the current differences:
- Variable names can be specified with just the equals sign,
var
, const
or let
.
- Do not use a semicolon at the end of the line.
- You don’t use curly braces to define code blocks, instead you use whitespace (tabs or spaces) like in Python.
- You can also use words instead of symbols in your comparison:
isnt
Workplace !==
is
Workplace ===
not
Workplace !
and
Workplace &&
There are some other differences, but over time JavaScript has absorbed many of the features that make CoffeeScript new and unique.
What to learn instead of CoffeeScript
Learning CoffeeScript for your own projects might be useful, but if you want to learn a language that’s in demand, stick with JavaScript. Even if you don’t know anything about coding, a Learn JavaScript course will take you from beginner to JavaScript developer in no time. What about TypeScript? TypeScript is in demand and is worth learning because it adds type capabilities to JavaScript, allowing you to write structured code that’s less error-prone. Once you understand JavaScript, TypeScript is easy to pick up. A Learn TypeScript course will teach you what you need to know to master the language.
This blog was originally published in February 2023 and has been updated to clarify JavaScript feature details.
Subscribe for news, tips and more