News for hackers. Stuff that matters.
Re:An Absolute Beginner's Guide to Node.js by dsego on Tuesday August 20, 2013 @08:15PM (#6247448)
For being such a flawed language, it does get one thing right. That one thing made Ryan Dahl pick javascript and it is the relative absence of blocking IO calls. Instead you use events and callbacks.
Re:An Absolute Beginner's Guide to Node.js by catnaroek on Tuesday August 20, 2013 @08:25PM (#6247475)
> "relative absence of blocking IO calls."

Do not confuse "language" with "standard library".

Re:An Absolute Beginner's Guide to Node.js by thedufer on Wednesday August 21, 2013 @12:45AM (#6248237)
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.

Re:An Absolute Beginner's Guide to Node.js by catnaroek on Wednesday August 21, 2013 @09:54AM (#6250249)
> "The whole event loop idea, which is core to javascript, allows for the single-threaded non-blocking I/O (...)"

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.

Re:An Absolute Beginner's Guide to Node.js by jussij on Wednesday August 21, 2013 @02:30AM (#6248532)
> 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...

Re:An Absolute Beginner's Guide to Node.js by hackerboos on Wednesday August 21, 2013 @04:25AM (#6248841)
Twisted (Python) and EventMachine (Ruby) don't all of these do the same thing?
Re:An Absolute Beginner's Guide to Node.js by thedufer on Wednesday August 21, 2013 @09:27AM (#6250072)
Yes. But they are tacked on to the language after the fact rather than built in from the beginning. My experience is that both language and libraries support that kind of pattern better in node than in Python (no Ruby experience with async).
Re:An Absolute Beginner's Guide to Node.js by dsego on Wednesday August 21, 2013 @06:40AM (#6249234)
I believe twisted was an inspiration for node.
Re:An Absolute Beginner's Guide to Node.js by dsego on Wednesday August 21, 2013 @06:39AM (#6249232)
were those in the language before or after node came out?
Re:An Absolute Beginner's Guide to Node.js by bitwalker on Wednesday August 21, 2013 @07:50AM (#6249507)
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 by dsego on Wednesday August 21, 2013 @08:04AM (#6249568)
are they widely used in APIs to e.g. send a query to the sql database or open a file?
Re:An Absolute Beginner's Guide to Node.js by jussij on Wednesday August 21, 2013 @10:22PM (#6254725)
Yes.

In .Net 4.5 there are Async versions of the web, file, stream, image and SQL category of functions.

It's also making its way into ASP.Net layer.

Re:An Absolute Beginner's Guide to Node.js by dsego on Tuesday August 20, 2013 @08:39PM (#6247516)
Well, the browser implementation I guess. The point being the correct mindset.
Re:An Absolute Beginner's Guide to Node.js by catnaroek on Tuesday August 20, 2013 @09:02PM (#6247571)
"Mindset" is not a property of programming languages. "Semantics" is. And JavaScript's semantics is, by any reasonable assessment, a huge pile of crap.
Re:An Absolute Beginner's Guide to Node.js by DrJokepu on Tuesday August 20, 2013 @09:15PM (#6247614)
Meh, whatever. I can’t believe people still have flamewars about programming languages on the Internet like it was still 1996.
Re:An Absolute Beginner's Guide to Node.js by catnaroek on Tuesday August 20, 2013 @10:07PM (#6247752)
I was not trying to ignite a flamewar. I was just correcting the mistaken idea that JavaScript's "relative absence of blocking IO calls" is somehow a property of the language itself.

In any case, the real issue at stake is whether there is anything about Node.js that makes it particularly good for writing server-side applications. As far as I can tell, the only thing Node.js brings to the table is an event loop. Event loops are not a particularly earth-shattering concept: Anyone who has written a graphical Win32 application by directly using the WinAPI has written an event loop (message loop in Win32 parlance). I do appreciate not having to write the loop myself, but:

1. An event loop can only handle concurrent I/O. Furthermore, because the event loop is hardcoded into every single Node.js instance, there are two legitimate choices that are nevertheless unavailable to a Node.js programmer: a) disabling the loop, if he does not need it, b) spawning multiple event loops as separate threads within a single Node.js instance.

2. Node.js offers no support whatsoever for concurrent computation. I know, I know, all your Web application does is move data between a database and a client. But, if the only use case of Node.js is going to be making Web applications, would it not have been better to make a Web application framework, and provide it as a library?

Languages that actually provide concurrency support (Erlang, Haskell and Rust, to name a few) make writing event loops as easy as it used to be in the 1990s. On top of that, they can be used to write server-side applications that scale.

Re:An Absolute Beginner's Guide to Node.js by dsego on Tuesday August 20, 2013 @10:59PM (#6247913)
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

Re:An Absolute Beginner's Guide to Node.js by catnaroek on Tuesday August 20, 2013 @11:57PM (#6248071)
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 by dsego on Wednesday August 21, 2013 @07:15AM (#6249348)
yes, fast web servers.