Clutch is an expression-oriented and object-oriented modern programming that compiles to JavaScript.
// fib(n) -> if n < 2 then n else fib(n - 1) + fib(n - 2)
function fib(n) {
return n < 2 ? n : fib(n - 1) + fib(n - 2);
}Clutch's goals:
- Make functional programming a delight but keep aproachable to traditional use
- Defaults that prefer immutability and optimizations
- Low overhead compilation and interpoability to and with JavaScript
STATUS: Highly experimental. Currently is a CoffeScript-like tool that does a 1:1 transpilation of most of Clutch's syntax to the equivalent in JavaScript. The goal, of course, is to become a complete static language, so we are pretty far from that!
There is a simple script, npm run clc, which supports an experimental CLI:
# Compiles and outputs path/to/file.cl.js
$ npm run clc -- path/to/file.clTo print the debug AST tree instead of JavaScript, add --parse or -p:
# Prints to stdout
$ npm run clc -- path/to/file.cl -pTo run in worker-mode, i.e. run the CLI and continously receive input:
# Write on stdin. Two newline characters triggers a compile
$ npm run clc -- -w