Strong, Dark, and Scripted
CoffeeScript as a replacement for Node.js
CoffeeScript (aka “Unfancy JavaScript) is a framework that compiles into JavaScript using a more simplified ruleset and reduced syntax compared to vanilla JS. The “golden rule”, as stated on the official website, is: “It’s just JavaScript.” CoffeeScript layers on syntactic sugar to JS with the goal of compiling one-to-one.
CoffeeScript currently only runs with Node.js, which can allow for more clean code when setting up a backend or handling the client-server response cycle.
Get Noah Berman’s stories in your inbox
Join Medium for free to get updates from this writer.
Some of the key differences between CoffeeScript and vanilla JS:
- Everything is an expression (
if,switch, andforall have implicit returns) - Conditionals can be chained together and are, in general, much cleaner
- Every function is an arrow function, and declaration/invocation can occur inline. CoffeeScript function syntax is:
functionName = (optionalArgument) -> [code block]- Objects may be created using indentation instead of explicit braces:
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9- Interpolation is styled as
#{}instead of#{} - Combining both declaration and invocation processes removes the need for the declarative keywords (
var,let,const) and automates lexical scope:
The lack of declarative keywords makes shadowing impossible (only possible to reference variables outside of scope).
Development and support for this framework is ongoing, and is primarily focused on maintaining support for the most updated versions of JavaScript. CoffeeScript provides a powerful way to code JS like a Rubyist! Beautiful code (and coffee) for all!
Sources:
CoffeeScript official website: https://coffeescript.org/#conditionals







