CoffeeScript: Performance and Benchmarks
However, as I began writing more and more complex applications in the language, I realized the syntax was just not cutting the deadline. The need for awkward commas, bad object expression and the inconsistent English vs. symbol equality checks were bogging the language down. So I wondered: why was I using CoffeeScript in the first place? Was it still the answer?
It does add some cool and useful features, such as forcing the use of strict equality operands (
==) and automatically-filling arrays (
[1..50]), but I figured only one thing would make the difference to me: speed.
So, I did what anyone with an inquisitive mind would do: I wrote code and ran benchmarks.
I decided to run tests between three program files against three different tasks commonly done in Node. I wrote equivalent files for each task: a
.coffee file, a compiled from CoffeeScript
.js file, and an equivalent, custom-written
.js file – for control. I wanted to see how these three variations of the same code compared:
- Interpretation via the
- Compiled CoffeeScript, run via
I tested against the following tasks:
- Simple addition loop (add all numbers between 1 and 5000)
- HTTP server (using
node’s HTTP module)
- File I/O (simple
coffee command line interpreter only does one thing: slow down your program. If you are using the interpreter in production, you’ve clearly done something wrong.
In essence, it is best to entirely avoid running the