News for hackers. Stuff that matters.
Re:It ain't about the callbacks, it's about the flow control by majke on Thursday September 05, 2013 @05:32PM (#6337201)
If I understand correctly you're saying that JavaScript is a neutral language. It's only a coincidence that in Browsers and in Node.js it heavily relies on the callback style. As a language itself, it could be synchronous.

Well, my friend, with this logic I claim that C is purely functional (it's only a coincidence that some implementations use rw memory) and there's nothing stopping Lisp from having mutable data.

Re:It ain't about the callbacks, it's about the flow control by nonchalance on Thursday September 05, 2013 @06:18PM (#6337483)
You can claim that there exists a subset of C that can be considered purely functional, and others have argued that (http://conal.net/blog/posts/the-c-language-is-purely-functio...), but the existence of standard library functions like strtok makes the general statement false.

You can claim that nodejs HTTP module forces a callback style, and that is true given the implementation, but javascript spec doesn't force you to implement an HTTP server in that fashion. As I stated in both responses, the article claims that javascript forces you to use a callback style, which is not the case. It is Node that forces you to use callbacks.

Re:It ain't about the callbacks, it's about the flow control by saraid216 on Thursday September 05, 2013 @07:14PM (#6337750)
> If I understand correctly you're saying that JavaScript is a neutral language. It's only a coincidence that in Browsers and in Node.js it heavily relies on the callback style. As a language itself, it could be synchronous.

I remember that I once wrote a JS library that loaded another page in an iframe and simply polled it to see if it had the data I wanted soon. These days, I probably would have written the server to respond with 202 Accept and then just timeout and poll again in X milliseconds. Block until it was ready, if need be.

It's not hard, and it's not even particularly frowned upon.

Re:It ain't about the callbacks, it's about the flow control by qwer on Thursday September 05, 2013 @10:51PM (#6338426)
There are javascript implementations that don't go asynchronous though. Take rhino for example: http://stackoverflow.com/questions/7249252/read-file-with-rh... . Or check out the commonjs spec: http://wiki.commonjs.org/wiki/Filesystem/A#Files .
Re:It ain't about the callbacks, it's about the flow control by kevingadd on Thursday September 05, 2013 @10:03PM (#6338287)
Unfortunately such a claim is false. The event loop and callback oriented asynchrony model is baked into the ES spec itself; future ES features rely on it explicitly.
Re:It ain't about the callbacks, it's about the flow control by esailija on Thursday September 05, 2013 @11:27PM (#6338522)
You are probably confusing ES spec with DOM spec, if not, at least I cannot find anything in ES spec even remotely related to how anything built on top would have to be asynchronous.
Re:It ain't about the callbacks, it's about the flow control by kevingadd on Friday September 06, 2013 @12:17AM (#6338632)
The concept of an event loop and event loop 'turns' is backed into ES promises the last time I read the draft spec and kept up with the spec discussions. It's not something you can polyfill in older versions of JS, it's a platform feature designed around how browsers work.
Re:It ain't about the callbacks, it's about the flow control by mook on Friday September 06, 2013 @01:25AM (#6338836)
Hmm, do you recall where the ES promises spec lives? I can't find it in the ES6 draft ( http://people.mozilla.org/~jorendorff/es6-draft.html ), but it's in the DOM spec ( http://dom.spec.whatwg.org/#promises ). ES6 does end up having iterators, which does look useful for promises, though... see task.js.