Live data from Hacker News

Making the Most of the JavaScript Language (2016)

thenorthcode.net

21–30 of 47 posts

Re: Making the Most of the JavaScript Language (2016)

#21
post #2

As someone who works with this every day, I'd say this is pretty solid advice. The "use a more functional approach" and "take advantage of ES6" are by far the biggest for me. ES6 added so much good stuff, I wouldn't consider it optional. It's better than incremental upgrades, feels almost like a different language to me. Every language has its quirks, and while I'll keep on hating Javascript's, I'll never lose sight…

What do you like about ES6? It just looks like syntactic sugar to me, but I'm always interested in re-evaluating. Writing [1,2,3].map(function(x) { return x+10 }) really doesn't bother me. I don't see what the benefit is of an arrow function. Are there other things that you like? As the OP mentions, the inheritance stuff is just likely to cause architecture headaches. I like JavaScript's concurrency model (single thr…

sure, if I would write code like that it wouldn't bother me too.

    const add = x => y => x +y;
    ...
    [1,2,3,4].map(add(1));
now we are talking ;)

Re: Making the Most of the JavaScript Language (2016)

#22
post #2

As someone who works with this every day, I'd say this is pretty solid advice. The "use a more functional approach" and "take advantage of ES6" are by far the biggest for me. ES6 added so much good stuff, I wouldn't consider it optional. It's better than incremental upgrades, feels almost like a different language to me. Every language has its quirks, and while I'll keep on hating Javascript's, I'll never lose sight…

What do you like about ES6? It just looks like syntactic sugar to me, but I'm always interested in re-evaluating. Writing [1,2,3].map(function(x) { return x+10 }) really doesn't bother me. I don't see what the benefit is of an arrow function. Are there other things that you like? As the OP mentions, the inheritance stuff is just likely to cause architecture headaches. I like JavaScript's concurrency model (single thr…

The big deal of an arrow function, brevity aside, is that it inherits the value of 'this' from the scope that creates it. Regular functions do not, so to use them as first-class functions you often have to bind before passing, pass around thisObjs for rebinding, do a 'that = this' type trick, etc.

Same goes for 'arguments', though that comes up less. Basically, they're much more representative of a simple lambda than a classical function.

Re: Making the Most of the JavaScript Language (2016)

#23

Earlier quoted context omitted.

What do you like about ES6? It just looks like syntactic sugar to me, but I'm always interested in re-evaluating. Writing [1,2,3].map(function(x) { return x+10 }) really doesn't bother me. I don't see what the benefit is of an arrow function. Are there other things that you like? As the OP mentions, the inheritance stuff is just likely to cause architecture headaches. I like JavaScript's concurrency model (single thr…

The big deal of an arrow function, brevity aside, is that it inherits the value of 'this' from the scope that creates it. Regular functions do not, so to use them as first-class functions you often have to bind before passing, pass around thisObjs for rebinding, do a 'that = this' type trick, etc. Same goes for 'arguments', though that comes up less. Basically, they're much more representative of a simple lambda than…

What's wrong with explicitly binding the scope? I really like that in JavaScript you have to be explicit about that kind of thing.

Re: Making the Most of the JavaScript Language (2016)

#24
post #2

As someone who works with this every day, I'd say this is pretty solid advice. The "use a more functional approach" and "take advantage of ES6" are by far the biggest for me. ES6 added so much good stuff, I wouldn't consider it optional. It's better than incremental upgrades, feels almost like a different language to me. Every language has its quirks, and while I'll keep on hating Javascript's, I'll never lose sight…

What do you like about ES6? It just looks like syntactic sugar to me, but I'm always interested in re-evaluating. Writing [1,2,3].map(function(x) { return x+10 }) really doesn't bother me. I don't see what the benefit is of an arrow function. Are there other things that you like? As the OP mentions, the inheritance stuff is just likely to cause architecture headaches. I like JavaScript's concurrency model (single thr…

ES6 is not just syntactic sugar, in fact arrow functions themselves are not only syntactic sugar- they bind `this` lexically, which is different to how `function() {}` works. Symbols, generators... the list goes on.

I won't disagree about the added complexity.

Re: Making the Most of the JavaScript Language (2016)

#25
post #2

As someone who works with this every day, I'd say this is pretty solid advice. The "use a more functional approach" and "take advantage of ES6" are by far the biggest for me. ES6 added so much good stuff, I wouldn't consider it optional. It's better than incremental upgrades, feels almost like a different language to me. Every language has its quirks, and while I'll keep on hating Javascript's, I'll never lose sight…

What do you like about ES6? It just looks like syntactic sugar to me, but I'm always interested in re-evaluating. Writing [1,2,3].map(function(x) { return x+10 }) really doesn't bother me. I don't see what the benefit is of an arrow function. Are there other things that you like? As the OP mentions, the inheritance stuff is just likely to cause architecture headaches. I like JavaScript's concurrency model (single thr…

> It just seems like people added a ton of complexity to give up a few keystrokes.

It's either "only syntactic sugar" or it "added a ton of complexity". To be honest, you sound like someone who's bitter because all the hard stuff you had to learn to deal with is now super simple and intuitive.

> I like JavaScript's concurrency model (single threaded with callbacks) so I don't see any benefit to the async stuff.

This sentence also demonstrates you either don't understand the concurrency model or async/await (async/await doesn't change the concurrency model).

The syntactic sugar isn't only there to save keystrokes, it also makes code easier to read and is less prone to errors.

Re: Making the Most of the JavaScript Language (2016)

#26
post #2

As someone who works with this every day, I'd say this is pretty solid advice. The "use a more functional approach" and "take advantage of ES6" are by far the biggest for me. ES6 added so much good stuff, I wouldn't consider it optional. It's better than incremental upgrades, feels almost like a different language to me. Every language has its quirks, and while I'll keep on hating Javascript's, I'll never lose sight…

TypeScript does to me (and technically I suppose it is a different language), where it gets interesting is that TS made me a better JS programmer since I could express stuff the way I wanted to and then look at the output. The only transpiler I've seen that gets close in terms of quality of output is BuckleScript, that thing is damn near magic but TS has the momentum and adoption. TypeScript has been so good and caus…

Typescript with TsLint is a godsend on larger codebases. It makes JavaScript into a pretty solid language for big projects.

Without it you frequently run into objects passed to you after going through 10k lines of code and it becomes a wicked game to figure out which properties the object actually has at that point.

JavaScript, even ES6, is IMO crap for large codebases.

Does this object have the property I'm looking for? Did somebody overwrite it with the wrong type 5000 lines ago? Why is the prototype chain broken? Where's my damn inline documentation.

My company has abandoned JavaScript wholesale with great relief. If it was a physical object we would have tossed it off the balcony.

Re: Making the Most of the JavaScript Language (2016)

#27

Earlier quoted context omitted.

TypeScript does to me (and technically I suppose it is a different language), where it gets interesting is that TS made me a better JS programmer since I could express stuff the way I wanted to and then look at the output. The only transpiler I've seen that gets close in terms of quality of output is BuckleScript, that thing is damn near magic but TS has the momentum and adoption. TypeScript has been so good and caus…

Typescript with TsLint is a godsend on larger codebases. It makes JavaScript into a pretty solid language for big projects. Without it you frequently run into objects passed to you after going through 10k lines of code and it becomes a wicked game to figure out which properties the object actually has at that point. JavaScript, even ES6, is IMO crap for large codebases. Does this object have the property I'm looking…

Typescript is essential for large codebases / many devs.

> My company has abandoned JavaScript wholesale with great relief. If it was a physical object we would have tossed it off the balcony.

I would like to do the same with our gigantic SPA-ghetti.

Re: Making the Most of the JavaScript Language (2016)

#28

Classical inheritance is useful in JS sometimes, but I agree with the sentiment of "don't use it unless you have a reason to".

Ya, that part I don't agree with. Especially since he also says to use ES6 features, which includes the new class syntax, making it a lot more straightforward to use classes + inheritance (even if it's still prototypical under the hood).

Re: Making the Most of the JavaScript Language (2016)

#29

Earlier quoted context omitted.

The big deal of an arrow function, brevity aside, is that it inherits the value of 'this' from the scope that creates it. Regular functions do not, so to use them as first-class functions you often have to bind before passing, pass around thisObjs for rebinding, do a 'that = this' type trick, etc. Same goes for 'arguments', though that comes up less. Basically, they're much more representative of a simple lambda than…

What's wrong with explicitly binding the scope? I really like that in JavaScript you have to be explicit about that kind of thing.

I think the problem with "this" is that you are trying to recreate classes instead of passing it as a parameter, or using currying. Arrow functions might be slightly more intuitive to intention, but the problem is still there. The implicit nature of "this" in JS is always worse than any explicitly controlled alternative.

Re: Making the Most of the JavaScript Language (2016)

#30

Earlier quoted context omitted.

TypeScript does to me (and technically I suppose it is a different language), where it gets interesting is that TS made me a better JS programmer since I could express stuff the way I wanted to and then look at the output. The only transpiler I've seen that gets close in terms of quality of output is BuckleScript, that thing is damn near magic but TS has the momentum and adoption. TypeScript has been so good and caus…

Typescript with TsLint is a godsend on larger codebases. It makes JavaScript into a pretty solid language for big projects. Without it you frequently run into objects passed to you after going through 10k lines of code and it becomes a wicked game to figure out which properties the object actually has at that point. JavaScript, even ES6, is IMO crap for large codebases. Does this object have the property I'm looking…

The true source of your problems there are mutation, which in my opinion is the primary source of issues. Immutable data structures being the most benefit.

I also believe dynamic language tooling has regressed.

Post reply on HN