Blog

 There is one thing i love about Ecmascript besides ptototypes and first-class functions. A small core.

This has been like this for all this time but with the release of Ecmascript 6 I feel that is no longer going to be true. There are new types, classes, syntax, and "what i dont like" aliases. Aliases are different ways to do the same thing and i dont like them because we have a very complex environment and millions of code lines that are garbage, to put more complexity on top of it.

I am going to try to illustrate this with one example from Axel Rauschmayer (1). Defining a property on an object whose value is a function.

Before Ecma5

var obj = {
  property : function () {}
};

obj.property2 = function () {};

var Obj = function () {};
Obj.prototype.property = function () {};
var obj = new Obj();

Now.

var obj = {
 property : function () {}
};

obj.property2 = function () {}

let obj = {
  property : function () {}
};

let obj = {
  property(){}
};

let obj = {
  set property() {},
  get property() {}
};

let obj = {
  * generator() {}
};

let obj = {
  generator: function* () {}
};

let property = function () {};
let obj = { property };

let obj = {
  ['property'] : function () {}
};

let propertyName = 'property'
let obj = {
  [propertyName] : function () {}
};

Object.create(
  {},
  {
    property :  {
      value : function () {}
    }
  }
);

Object.assign(
  {},
  {
    property : function () {}
  }
);

class Obj {
  property : function () {}
}
let obj = new Obj()

var Obj = function () {}
Obj.prototype.property = function () {};
let obj = new Obj();

I we had troubles getting people to write good code, get the number of combinations fo all the possbble valid code that this aliases can produce, and lets not talk about "=>", so my question here is, i see some use case for this, but why satisfy all use cases? What is the goal behind all of this, let everyone create more mess, or who is going to be responsible for the millions of dollars that will be spent debugging and fixing bad code?

The point is aliases create more combinations, so they create more complexity. want cool syntax, go and build your transpiler or use the macro system, or tell me where i can send the billing invoices.

References

1. Axel Rauschmayer. "ECMAScript 6: new OOP features besides classes". http://www.2ality.com/2014/12/es6-oop.html