4 ms·
FYI, http://disnetdev.com/contracts.coffee/ http://disnetdev.com/contracts.coffee/ is built on ES6 proxies and CoffeeScript. I agree on circling a local maximu
by BrendanEich 15y ago
FYI, http://disnetdev.com/contracts.coffee/ http://disnetdev.com/contracts.coffee/ is built on ES6 proxies and CoffeeScript.
I agree on circling a local maximum, but some of this is just JS catching up to Ruby and Python. Syntactic affordances for usability that desugar to only lightly extended kernel semantics.
The big ticket items are modules, proxies, weak maps, binary data, and the like.
When I liken JS to x86, I'm not comparing it to assembly so much as to a ubiquitous target for compilation. JS is even stickier and longer-lived than x86 -- witness ARM's rise on mobile while the web evolves mostly-compatibly, including JS content and the JS language.
Contracts and macros are on the Harmony agenda, further out.
- Andi 15y agoI came across contracts some time ago and found it very appealing and inspiring, but for all my professional projects I am successfully using my own library schema.js ( https://github.com/akidee/schema.js https://github.com/akidee/schema.js ) - you can use it in pure JavaScript, too. (Usually I do not validate forms on the client-side, since the data must be validated on the server-side anyway. And with schema.js, you can add custom localized error messages.) Furthermore, schema.js has several modes that allow tolerant adaptation of values, so that they can be casted. "5", for example, is casted to 5. But you can switch to strict validation mode as well. You can do everything, that contracts allows, with schema.js, too. The best is that, with JSON schema, 1) you define secure validations, since with the default properties you do not forget important constraints, and 2) you do not need to test your validators any more. Conclusion: I agree that such features must make it to the core of a language. Probably you can find some useful ideas in JSON schema and schema.js. I found the JSON vocabulary to be very useful to validate JS data.
- raganwald 15y agoThanks, I like Design By Contract(tm) and this looks very interesting.