CoffeeScript
v2.5.1
CoffeeScript
v2.5.1
CoffeeScript is a small programming language that compiles into JavaScript, created by Jeremy Ashkenas and first released in 2009. It offers a cleaner, more concise syntax inspired by Ruby and Python, removing curly braces and semicolons in favor of significant whitespace. Its motto is that it is 'just JavaScript,' so every CoffeeScript program maps directly to readable JavaScript output while adding conveniences like comprehensions and the existential operator.
On CompileBytes, CoffeeScript is processed with the compiler reported as version 2.5.1, which targets modern JavaScript. Although the language has declined in popularity since the rise of ES6 and TypeScript, it remains useful for learning, for legacy codebases, and for writing terse scripts. CoffeeScript code runs in Node.js after compilation, so it has full access to the JavaScript runtime and ecosystem.
console.log 'Hello, World!'square = (n) -> n * n
console.log square 5cubes = (x * x * x for x in [1..5])
console.log cubesperson =
name: 'Ada'
age: 36
for key, value of person
console.log "#{key}: #{value}"factorial = (n) ->
if n <= 1 then 1 else n * factorial n - 1
console.log factorial 6nums = [1..10]
evens = (n for n in nums when n % 2 is 0)
console.log evensclass Animal
constructor: (@name) ->
speak: -> "#{@name} makes a sound"
dog = new Animal 'Rex'
console.log dog.speak()[a, b, c] = [1, 2, 3]
console.log a + b + c
{name, age} = {name: 'Tom', age: 42}
console.log "#{name} is #{age}"grade = (n) ->
switch
when n >= 90 then 'A'
when n >= 80 then 'B'
else 'C'
console.log grade 85Yes. CompileBytes compiles your CoffeeScript to JavaScript and runs it in the browser, with no local install required.
It uses the CoffeeScript compiler reported as version 2.5.1, which targets modern JavaScript and runs the result on Node.js.
Yes. Since it compiles to JavaScript on Node.js, you can read stdin via process.stdin, and supply data through the input box.
Yes, it is completely free, and CoffeeScript is open-source software released under the MIT license.
Yes. CoffeeScript uses significant whitespace to define blocks instead of curly braces, so consistent indentation is required.