r/programming • • Jul 25 '13

CoffeeScript's Scoping is Madness

http://donatstudios.com/CoffeeScript-Madness
207 Upvotes

315 comments sorted by

View all comments

Show parent comment

26

u/flying-sheep Jul 25 '13

ECMA 6:

[1,2,3].map(x => x*2)

try it in a firefox near you!

21

u/tmetler Jul 25 '13

Absolutely, but harmony was actually influenced by C# and coffeescript. It'll be great when it's widely supported. Definitely a big step in the right direction.

2

u/flying-sheep Jul 25 '13

and python, i know :)

they are refreshingly blunt on where they took the features from.

6

u/[deleted] Jul 26 '13

And Scala.

4

u/nachsicht Jul 27 '13

To be truly inspired by scala it should be [1,2,3].map(_ * 2)

2

u/[deleted] Jul 27 '13

Point free lambda applications? Isn't that a bit pointless?

3

u/nachsicht Jul 27 '13

Yes, that's why it's called point free :)

Seriously though, the point free style is nice for these because x => x * 2 doesn't really confer much more meaning than _ * 2, and if you're chaining a bunch of lambda applications together it reduces the size of your code without reducing its readability.

0

u/balefrost Jul 26 '13

And my axe.

4

u/[deleted] Jul 25 '13

See the difference is we can start writing shorter code now rather than waiting for Half Life 3 to be announced.

6

u/elder_george Jul 25 '13

Same syntax works in Typescript (along with many other niceties from ECMA 6), so it's possible to start using it right now.

2

u/flying-sheep Jul 25 '13

if you’re writing firefox extensions, you can have that right now.

but i getcha. i was just giving perspective.

-11

u/MedicatedDeveloper Jul 25 '13
6 / 2 = 3

HALF LIFE 3 CONFIRMED!