a_bertrand wrote:Well there is some truth. The way async is made in C#/.NET (I don't know how Java is made but I would say it is the same as .NET) and the way it's done in node.js is completely different. In node.js you subscribe to some "callback" method more or less the equivalent of an event in C#, yet when this callback is called, it will be the only thing running at that time. That means, you can't have a "timer" function running and at a same time a socket.io callback. For most this will be fine as it avoid concurrency issues (no need to lock variables for example), however it's NOT multi-tasking and it's not really async. You simply don't need to pool to wait for an event which is already great.
Really they are not that different. The async call in C# is the same as the async call in node. In C#, the "await" is the same as your callback. However, there is an important difference between the two. C# gives a bit more flexibility before the "callback": the code before the await keyword will run instantly after the async call is made, and then will freeze at the await until the async call returns. This is basically like how you can fire off an async call in node and then it will start to execute all the code below the end of the callback, but C# gives a bit more flexibility since you can reliably know how far the code will run before the async call returns. Note however that there are packages for node that can achieve this same model, such as some of the various implementations of promises.
a_bertrand wrote:For the realtime, well all depends what is your definition of realtime. Where I work, a realtime OS is an OS which has pre-defined / well known timer interrupts. For example, if I want to be waked up every 1/10 of sec, it will be exactly 1/10th of a second, not once 1/9 and the next time 1/11 as it's on windows. The price of such OS are extreme, as well as all the tools to develop on them. But for most those are totally useless and a normal OS like Linux and Windows are more than ok. For stock exchange, realtime news means less than 50ms delay (I don't know the real number here, but it's really a fraction of a second) between the news, and the time you get it. So if the price of a stock goes down you should get it in realtime, for that you pay a lot again. So what's the definition of realtime? All depends what YOU need. For me, node.js is realtime enough for the game I'm developing.
You are more defining a "real-time OS", which is something totally different than a "real-time networked app", which is what node was referring to. You pretty much hit the nail on the head for a real-time OS, which are very common in embedded systems. But when the node website mentions "real-time", they really more mean the "real-time web".
a_bertrand wrote:The issues I do see about node are the lack of multi-processor support per default. That means, if you make your little web server or socket.io server with node.js it will use only one core / thread. If you want to use more, then you need to spawn more processes. While this seems to be odd in today worlds, it does have some logic (as simplification of the core of node.js as well as maybe allow more tweaking???) however for most it can be a source of annoyance. Yes there is some "cluster" solution for node, yet it's not in by default and I don't know how the communication with socket.io from one instance talk to the other. If they don't then you have an issue.
It is somewhat of an issue, but node does include clustering out of the box (I think this was added to the default download a few minor version updates back). As you could probably imagine, any communication between processes in node is done with...you guessed it...events lol. If you really, really need multiprocessor support (and most average users don't, since node has performance comparable to other platforms using multiple processors), it is there, even if not perfectly baked. Honestly the worst part about this is in the business world where you have to explain to the IT department that their godly 32-core server just has 1/32 of its CPUs in action lol.
a_bertrand wrote:Another issue is the "stability" in term of API. Each release of node.js do change the API, and many times it's not backward compatible. Now they promised that the core should be more or less stable as API, but as we are still not with a V 1, I may expect they will actually change things.
node seems like it has stabilized out quite a bit, but I understand the concern. I would like to see a 1.0 release. But then again, this doesn't seem completely like an isolated issue. I have been noticing more and more software projects hesitating to move to 1.0 for some reason. I think more projects are beginning to see it as an excuse for any potential problems, like they are leaving the "We aren't even 1.0" card in the deck potentially for years. Same thing is going on with a lot of F2P MMORPGs, which seem content to stay in beta for years after they are commercially running (Runes of Magic was in "beta" for almost 5 years after their real-money store opened).
a_bertrand wrote:Error handling can be an issue too, as some errors are not within your code, and as you cannot make a try catch around callbacks, you will basically not catch them so easily. All async code do have issues with error handling, same in .NET. Yet in .NET, maybe due to my higher knowledge, it seems easier to catch those issues.
Last thing, is the tools. node.js is pretty new and not developed by a company like Microsoft, so no visual studio for node.js. No incredible debugger. Yes there is tools, yes there is editors (WebStorm for example is really great) but we are FAR away from a visual studio.
I admit error handling isn't what I would like (I would also rather have try catch blocks), but apparently this is a casualty of asynchronous programming all across the board. This is due to the way the stack works during asynchronous calls. The exceptions would not be thrown up the stack correctly and would wreak havoc. So instead in node, an error argument is sent in to the callback, which you can check to see if an error occurred and react accordingly. Not perfect, but it has been working fine for me.
As for tools, to be fair to node,
no language has another Visual Studio. Honestly, that is the problem with .NET, is that Visual Studio forever spoils you. The closest I have ever found, believe it or not, are some of the modern Embarcadero Delphi versions. Java has some decent IDEs, but nothing to the level of Visual Studio. WebStorm is great and all, but having the support that VS gives .NET for JS is impossible because the support that VS offers is built into the languages of .NET in their extensive metadata. That is how Intellisense works so well and so "magically". VS is analyzing your code and building up metadata representations of it that it can consume to read your intentions. This is also how the .NET runtime JIT compiles the MIL to run so well. So an IDE alone can't physically compete with VS. It needs the language, platform and IDE to all work as one.
WebStorm does actually give you pretty decent debugging, however. I have only had to use it a couple of times, but it has helped me easily both times, with full local watches, live mouse-overs, etc. It was pretty nice, even if it is no VS
