r/javascript • • Jul 10 '16

The JavaScript language reboot is done

https://medium.com/@velmu/the-javascript-language-reboot-is-done-7bcec4be2cb6#.dy2fyy9j1
41 Upvotes

98 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Jul 10 '16

Yeah, despite working with arrow functions for nearly a year, I still find them infinitely more difficult to understand and comprehend than the non-arrow version. The syntax is just so poor.

12

u/hyperhopper Jul 10 '16

Alright, I really hate to be that asshole on the internet, but if you are working with them for a year, and can't figure it out, programming might not be for you.

let that = this;
function (a) {
    return a + that.b;
}

is the same as

a => a + this.b

It's really not difficult or novel at all.

2

u/WorkshopX Jul 10 '16

upvote for a simple example of arrow functions effect on this binding. Well done.

1

u/[deleted] Jul 10 '16 edited Jul 10 '16

I've been a programmer for 20 years. I have no problem figuring them out. It's just the syntax I have a problem with. And by problem I don't mean I don't understand it, I mean the syntax was poorly thought out and all around sucks. And yes, I know that the syntax was borrowed from other languages, but that doesn't mean the syntax didn't suck in those other languages too.

1

u/SuperFLEB Jul 10 '16

The place I find it more readable is in functions like map, where something like...

arr.map(thing => thing * 1000);

reads as "map thing to thing * 1000". I do agree that it can be less immediately readable or intuitive in other cases like object methods or general-use callbacks, for instance.

0

u/Asmor Jul 10 '16

And that's super handy for some common transformations, like picking values of an object:

Object.keys(obj).map(key => obj[key])

-1

u/Tysonzero Jul 10 '16

I think it is awesome that JS is slowly but surely adding more functional programming features, eventually it might start to approach the elegance of Haskell: map (* 1000) arr.

-1

u/[deleted] Jul 10 '16

The syntax is just so poor.

It doesn't help that the functional / academic coders keep coming out of the woodwork to say that the syntax is more natural because it looks like calculus.

I fucking hated calculus!