contracts.coffee

Mozilla Research intern Tim Disney has has just released contracts.coffee, a dialect of CoffeeScript with a sweet syntax for wrapping JavaScript objects with contracts that are automatically checked at runtime (“assert on steroids”). Tim’s got a great tutorial with lots of examples, so I won’t try to reproduce it here. Just check it out!

Contracts.coffee is a great demonstrator of the power of JavaScript proxies, which are coming in the ES6 standard, have been shipping in SpiderMonkey since Firefox 4, and are in the works for V8. Contracts.coffee uses proxies to create wrapper objects that do all the proper checking to enforce your contracts.

It’s also a nice experiment in language design (using ideas from Eiffel and Scheme), which we’ll be paying attention to along the road to ES7 and beyond.

Comments are closed.