News for hackers. Stuff that matters.
Re:ES6: The features I'm most excited about by nodesocket on Sunday July 05, 2015 @09:37PM (#9836119)
I was just talking to my friend who works at NetFlix on the frontend team about ES6, he is most excited about destructuring `let { name, age, gender } = user;`. I however advocate that the new class syntax is the best part of ES6. Take the following trivial OOP example, which I think reads so much easier a lot like PHP.

    "use strict";

    class Vehicle {
        constructor(name) {
            this.kind = 'Vehicle';
            this.name = name;
        }

        printName() {
            console.log(this.name);
        }
    }

    class Car extends Vehicle {
        constructor(name) {
            super(name); //call the parent method with super
            this.kind = 'Car';
        }
    }

    let myCar = new Vehicle('Mercedes');
    console.log(myCar);
Re:ES6: The features I'm most excited about by mkozlows on Sunday July 05, 2015 @10:17PM (#9836299)
I think it's fair to say that people who want to write object-oriented Javascript are very excited by class. Those of us who have found that the non-OO nature of Javascript is part of what makes it so productive are... much less excited.
Re:ES6: The features I'm most excited about by jonpress on Sunday July 05, 2015 @11:10PM (#9836515)
JavaScript is object oriented just like any other language. The difference is that it is prototype-based OO instead of class-based OO.

I would say that JavaScript's OO is actually more powerful/flexible than other languages but it is less readable and more error prone if you're not careful - For example, the fact that objects can 'borrow' a method from other object an apply it to themselves is a common source of issues for beginners.

Re:ES6: The features I'm most excited about by smt88 on Monday July 06, 2015 @01:08AM (#9836926)
It's possible to get power without flexibility. Flexibility is bad -- it creates code that is idiomatic to the person who wrote it.

Rust and Go are so exciting because they've intentionally rejected flexibility without compromising power.

Re:ES6: The features I'm most excited about by tragic on Monday July 06, 2015 @04:09AM (#9837548)
Flexibility is not 'bad' - it's a tradeoff. More flexible languages are better for writing DSLs, etc; but using them means a lot of self discipline regarding code style.

One thing I wish JS had is a PEP8-style canonical style document. I would find that more useful than classes.

On classes, I am among the less excited about them; however, we are in a ridiculous situation where there are about 500 different library implementations of class inheritance. Backbone has one. Ember has one. Node has util.inherits. Various transpile-to-JS languages (CS, TS) all have their own slightly-different implementations of the resulting prototype code. There is plainly a need for classes in JS, felt by some of the leading projects in JS land.

ES6 classes at least gives all these disparate implementations a refactoring target. How many of them will get there is another matter.

Re:ES6: The features I'm most excited about by tel on Monday July 06, 2015 @09:18AM (#9838870)
> More flexible languages are better for writing DSLs, etc;

Citation needed, or, I'm not quite sure I agree with you there. In fact, I think I believe the exact opposite (to a degree).

Re:ES6: The features I'm most excited about by smt88 on Monday July 06, 2015 @04:19AM (#9837576)
> using them means a lot of self discipline regarding code style.

That's bad. Few developers have self-discipline. The ones who do still have different rules than you do. That makes reading, understanding, and modifying their code harder. Sounds bad, doesn't it?

There's a reason the most experienced devs rage against extremely flexible languages like PHP and JavaScript and are excited about new, ultra-rigid languages.

Re:ES6: The features I'm most excited about by jbergens on Monday July 06, 2015 @03:36AM (#9837430)
A lot of other languages makes you write a lot more code for some things that js can express very shortly. I usually find that the js version is more readable. The problem, I think, is that most programmers are used to class-based inheritance and not prototypical inheritance.
Re:ES6: The features I'm most excited about by TazeTSchnitzel on Sunday July 05, 2015 @10:34PM (#9836367)
`class` trades the flexibility of prototypes for the familiarity of other languages. :(
Re:ES6: The features I'm most excited about by domenicd on Monday July 06, 2015 @04:37AM (#9837646)
This is just false. `class` is sugar over prototypes. Nothing is lost.
Re:ES6: The features I'm most excited about by TazeTSchnitzel on Monday July 06, 2015 @10:39AM (#9839405)
Yes, it is just "sugar", but it cements one way of doing things.
Re:ES6: The features I'm most excited about by akilism on Monday July 06, 2015 @09:29AM (#9838925)
yep. personally I've taken a much more functional approach to my javascript development that barely relies on oop.
Re:ES6: The features I'm most excited about by phoenixmatrix on Monday July 06, 2015 @10:43AM (#9839429)
Yup. The class keyword is a huge step backward, and it was only put it because of a very different world several years ago when all this was put into motion. It is just a wrapper around prototypal inheritance, but hides a lot of the features in favor of making things look like other OOP languages, even though it isn't.

It is also very debatable if classic OOP is even good at all. JS was heading in the right direction, with more functional approaches, factory based object creation, etc... and now it's all back to square one.

Fortunately I work on a product where most devs have functional programming backgrounds, so the argument isn't too hard to make. But I fear for the community in general.

Re:ES6: The features I'm most excited about by thwarted on Sunday July 05, 2015 @11:42PM (#9836623)
Why can all this new syntax be added, but the "use strict" pragma is still specified by a string? It made sense to send messages to the interpreter in a backwards compatible way, but now it just seems odd.
Re:ES6: The features I'm most excited about by v413 on Monday July 06, 2015 @02:38AM (#9837201)
All code in modules is in the context of "use strict" by default so it won't be necessary to use this pragma explicitly.
Re:ES6: The features I'm most excited about by nodesocket on Sunday July 05, 2015 @11:51PM (#9836645)
Not entirely sure if browsers require "use strict;", but io.js (node) does.
Re:ES6: The features I'm most excited about by silverwind on Monday July 06, 2015 @05:42AM (#9837870)
In iojs/node, you can force v8 strict mode through the --use_strict flag, saving you from writing in every file.
Re:ES6: The features I'm most excited about by Kiro on Monday July 06, 2015 @04:44AM (#9837680)
> he is most excited about destructuring `let { name, age, gender } = user;`.

Why is this a big deal? Seems pretty trivial.

Re:ES6: The features I'm most excited about by robinson7d on Monday July 06, 2015 @08:59AM (#9838763)
One of the reasons that it's a big deal is because of what it means for functions. It helps make named-parameters more attractive, which can help a lot with code maintainability.

Example code: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Additionally, it's nice sugar for module loading, for modules that export multiple values.

Re:ES6: The features I'm most excited about by akilism on Monday July 06, 2015 @09:30AM (#9838931)
I'm with him, I'm pretty excited about destructing coming to JS. If it's half as powerful as it is in clojure it'll be great.