Earlier quoted context omitted.
> allows for the single-threaded non-blocking I/O in a way that no other popular language does. C# Async and Await - http://msdn.microsoft.com/en-us/library/vstudio/hh191443.asp...
Twisted (Python) and EventMachine (Ruby) don't all of these do the same thing?
An Absolute Beginner's Guide to Node.js
51–60 of 71 posts
Re: An Absolute Beginner's Guide to Node.js
#52> Basically you're telling it to do something and when it's done it will call your function (callback). This is because Node is single-threaded . Do you mean multi-threaded?
No, Javascript has no notion of threads. Rather than true concurrency and a synchronization mechanism, it has callbacks (upon callbacks upon callbacks).
Re: An Absolute Beginner's Guide to Node.js
#53Re: An Absolute Beginner's Guide to Node.js
#54Earlier quoted context omitted.
Node was created to make scripting fast servers easy. Nothing more, nothing less. Because JS (as implemented in the browser and known by many programmers) didn't carry the baggage of blocking IO calls, Ryan thought it would be a good language for an event-loop based server. History of Node.js: http://www.youtube.com/watch?v=SAc0vQCC6UQ
Fast Web servers. There is absolutely nothing there that I could use to make, say, a fast database server.
Re: An Absolute Beginner's Guide to Node.js
#55Earlier quoted context omitted.
> allows for the single-threaded non-blocking I/O in a way that no other popular language does. C# Async and Await - http://msdn.microsoft.com/en-us/library/vstudio/hh191443.asp...
were those in the language before or after node came out?
Re: An Absolute Beginner's Guide to Node.js
#56Earlier quoted context omitted.
were those in the language before or after node came out?
async/await are just sugar over the much older asynchronous delegate pattern that has been in the language since day one. So yes, they were.
Re: An Absolute Beginner's Guide to Node.js
#57Re: An Absolute Beginner's Guide to Node.js
#58Earlier quoted context omitted.
> allows for the single-threaded non-blocking I/O in a way that no other popular language does. C# Async and Await - http://msdn.microsoft.com/en-us/library/vstudio/hh191443.asp...
Twisted (Python) and EventMachine (Ruby) don't all of these do the same thing?
Re: An Absolute Beginner's Guide to Node.js
#59Earlier quoted context omitted.
While that's true, I don't believe it's applicable to node.js, so it's a bit out of scope for this article.
People coming from multi-threaded server environments should be aware that multi-threading does in fact exist in Node (scope of parent comment), but it's rather different from other more common concurrent event handling schemes. I.e., you cannot have shared mutable variables across threads (scope of article and ongoing async discussion). For examples, see https://npmjs.org/package/webworker-threads and https://github…
Re: An Absolute Beginner's Guide to Node.js
#60Earlier quoted context omitted.
> "relative absence of blocking IO calls." Do not confuse "language" with "standard library".
The whole event loop idea, which is core to javascript, allows for the single-threaded non-blocking I/O in a way that no other popular language does. Because of this, javascript has features that make this type of programming easy - first-class functions, anonymous functions, etc. So, yes. Non-blocking I/O is a standard library feature, but it works because of language features.
Event loops are not a property of JavaScript of any other programming language: Every single GUI Win32 application ever written in C directly calling the WinAPI contains an explicit event loop.
> "(...) in a way that no other popular language does. Because of this, javascript has features that make this type of programming easy - first-class functions, anonymous functions, etc."
JavaScript is hardly the only language, or even the only popular language, to ever have first-class procedures or anonymous procedures. You know what (at some point in time) widely taught language has a procedure data type[1]? Pascal. So why not Node.pas instead?
> "So, yes. Non-blocking I/O is a standard library feature, but it works because of language features."
That countless other languages have. Most of them a lot better designer than JavaScript.
===
[1] Edit: I originally suggested Pascal has anonymous procedures, which it does not.