Live data from Hacker News

ECMAScript 6 looks promising

kishorelive.com

11–20 of 94 posts

Re: ECMAScript 6 looks promising

#11
The most interesting part to me is the "generator function", which basically allows for cooperative scheduling.

This would put an end to spaghetti callbacks when doing blocking I/O operations. Very similar to EM-Synchrony for EventMachine/Ruby and (I guess) Inline Callbacks in Twisted/Python.

This and the new module would be a blast for Node.JS !

Re: ECMAScript 6 looks promising

#12

Nice to see many of CoffeeScript's constructs coming to ECMAScript.

True-- but it's frustrating that there's so much resistance to the idea of making the syntax prettier and more concise, which is one of the primary benefits of CoffeeScript.

(Almost?) all of these features can be added to JavaScript with libraries-- that's exactly what CoffeeScript demonstrates. The only thing missing is a contemporary syntax.

Re: ECMAScript 6 looks promising

#13
post #9

Earlier quoted context omitted.

I don't know much about PHP, what's wrong with it regarding templating?

Automatic interpolation of variables into string literals is a bad idea IMHO. Couple that with variable hoisting (function scope) and hilarity can ensue when variables defined further down a function influence the value of another variable that looks like it just contains a string literal.

Every time I try Ruby, this features seems odd, yet I never see much discussion of it. It feels unnatural to me, coming from a python background, and the only real advantage I can see is the fact that you do not have to type `.format(foo")` after the string, or some similar construct.

What advantages did I miss? I doubt that the creators of ruby did not put any thought into this, and I'd be interested in their justification.

Re: ECMAScript 6 looks promising

#14

The most interesting part to me is the "generator function", which basically allows for cooperative scheduling. This would put an end to spaghetti callbacks when doing blocking I/O operations. Very similar to EM-Synchrony for EventMachine/Ruby and (I guess) Inline Callbacks in Twisted/Python. This and the new module would be a blast for Node.JS !

and (I guess) Inline Callbacks in Twisted/Python

Python has had real generators (using the yield keyword) for a long time... See http://www.python.org/dev/peps/pep-0255/ .

Re: ECMAScript 6 looks promising

#16
post #9

Earlier quoted context omitted.

Automatic interpolation of variables into string literals is a bad idea IMHO. Couple that with variable hoisting (function scope) and hilarity can ensue when variables defined further down a function influence the value of another variable that looks like it just contains a string literal.

Every time I try Ruby, this features seems odd, yet I never see much discussion of it. It feels unnatural to me, coming from a python background, and the only real advantage I can see is the fact that you do not have to type `.format(foo")` after the string, or some similar construct. What advantages did I miss? I doubt that the creators of ruby did not put any thought into this, and I'd be interested in their justif…

>> I doubt that the creators of ruby did not put any thought into this, and I'd be interested in their justification.

I don't know what Matz's thinking was, but it may just be that Ruby owes a great deal to Perl. Interpolation in double-quoted strings is present in Perl (and used constantly).

Re: ECMAScript 6 looks promising

#17
post #3

Let keyword: good. The function scoping of vars is gruesome. Default arguments: good. Clearly useful and already used a lot with the if (foo === undefined) foo = 'default' pattern. Non-strict destructuring: bad. It's neither destructuring-bind nor pattern matching... If I destructure a 3-list to 2 vars, I want it to fail , dammit! Multi-line strings: good, obviously. Templating: hello, PHP! I thought we already know…

I think it would be slightly more consistent to re-use the multi-line quite like Python does:

var foo = /* Hello there How are you? */;

But less typing is good too.

Re: ECMAScript 6 looks promising

#18
post #9

Earlier quoted context omitted.

I don't know much about PHP, what's wrong with it regarding templating?

Automatic interpolation of variables into string literals is a bad idea IMHO. Couple that with variable hoisting (function scope) and hilarity can ensue when variables defined further down a function influence the value of another variable that looks like it just contains a string literal.

Does anyone know what the rationale was for choosing this instead of printf or python3-style interpolation (where you explicitly specify the variables to be interpolated)?

Re: ECMAScript 6 looks promising

#19
post #9

Earlier quoted context omitted.

I don't know much about PHP, what's wrong with it regarding templating?

Automatic interpolation of variables into string literals is a bad idea IMHO. Couple that with variable hoisting (function scope) and hilarity can ensue when variables defined further down a function influence the value of another variable that looks like it just contains a string literal.

It's syntactic sugar for string concatenation. The same bugs would happen today if you were concatenating strings. I don't see the problem, honestly.

Re: ECMAScript 6 looks promising

#20
post #7
post #5

Earlier quoted context omitted.

Yes, and David actually mentioned openly in that talk that they try to borrow good ideas from other languages if possible! There are templates from PHP too :)

Don't know much about PHP, but the templates also exist in Python.

Python's string formatting is different though– it doesn't automatically have access to the variables in the current scope. You have to explicitly pass in the variables that you want to include, which seems to me like a cleaner way of doing things.
Post reply on HN