Traceur: Google’s JS.next to JS transpiler
Posted by Dion Almaer about a year ago on javascript google traceur compiler transpiler
“Language design is library design and library design is language design”
Google has released a cool new transpiler (transcoding compiler, coined by Brendan Eich) called Traceur.
The V8 team has always been conservative when it comes to the version of JavaScript that they support. They tend to keep in line with the WebKit team.
In 2011 though, JavaScripters want more. We have brave new versions of JavaScript being specified and we want to play now. The success of CoffeeScript also shows how we want to play in the new world.
So, a bunch of awesome Googlers, featuring Open Web heros such as Alex Russell and Erik Arvidsson have got a new device that lets us play with JS.next…. today.
They presented on the rational, and how we got here, today at JSConf.
There are a bunch of exciting language features available such as:
- Classes – Strawman
- Traits – Strawman
- Modules (in progress)
- Iterators and For Each
- Generators
- Deferred Functions – Strawman
- Block Scoped Bindings
- Destructuring Assignment
- Default Parameters
- Rest Parameters
- Spread Operator
Fun to see code such as:
trait ComparableTrait {
requires lessThan;
requires equals;
function lessThanOrEquals(other) {
return this.lessThan(other) || this.equals(other);
}
function greaterThan(other) {
return other.lessThan(this);
}
function greaterThanOrEquals(other) {
return other.lessThan(this) || this.equals(other);
}
function notEquals(other) {
return !(this.equals(other));
}
}
class Interval {
mixin ComparableTrait;
new(min, max) {
this.start = min;
this.end = max;
this.size = max - min - 1;
}
function lessThan(ival) {
return this.end <= ival.start;
}
function equals(ival) {
return this.start == ival.start && this.end == ival.end;
}
}
var i1 = new Interval(0, 5);
var i2 = new Interval(7, 12);
alert(i1 + ' == ' + i2 + ': ' + i1.notEquals(i2)); // true
alert(i1 + ' < ' + i2 + ': ' + i1.greaterThan(i2)); // false
Want to play? Get Started.
It is very exciting to see a world in which we are coming together. Great work has been done on jQueryland, Dojova, Prototypia, and many others. It is a crying shame that we have been speaking different languages (even if they are all latin based).
We have a chance to start again, learn from the past, and come together. Hopefully we won’t end up with Esperanto eh?