Live data from Hacker News

.NET and Node.JS – Performance Comparison

salmanq.com

41–50 of 119 posts

Re: .NET and Node.JS – Performance Comparison

#41

Until Mono becomes 100% supportable, none of the advantages of .NET outweigh the misery of having to use Windows for development and serving.

What do you mean by supportable? I was happily using mono for a number of custom servers in a similar way a couple of years ago. You don't need any huge frameworks to make mono really useful.

Re: .NET and Node.JS – Performance Comparison

#42
post #26
post #20

Earlier quoted context omitted.

It wasn't wrong on many levels. - For very obvious reasons, JS (or Python or Ruby) would be slower than Java, C# at number crunching. - Node.js would handle concurrent connections better than most Asp.Net apps since the framework is non-blocking. Now you could write non-blocking code with .Net, but that isn't how most people write Asp.Net code. OTOH, with Node.js that's the only way you could write an app. - I am imp…

So you are saying that nodejs is slower in general, and .NET is slower when people don't know how to program in .NET. To add on top of that, mvc 4 has extremely easy ways to set up async controllers/tasks. However, these are not needed or even WANTED most of the times. They are only really needed in I/O operations, a sector in which .NET excels anyway since you can get ORM magic happening easily. Also, don't think no…

- Correct. I am saying that nodejs is slower in general. The reason you would use nodejs is to save development time, and not to extract the last drop of performance. It is for the same reason that people have written so many apps on Python and Ruby.

- I/O in nodejs is always asynchronous. I/O in typical .Net apps is almost always synchronous, due to programmer choice. This approach is followed in the vast majority of Asp.Net apps. So according to you, this would imply that most .Net programmers don't know how to program in .Net.

- I can't follow how "ORM magic" is related to I/O. The ORM magic I remember has been a terrible experience for me when I had to use .Net (3-4 years back). We have to write our own ORM to replace EF, since it was dog slow. Including the LINQ expression tree parser, design-time tools etc. You can find this result here: https://github.com/jeswin/AgileFx

I know that things finally got better after EF4. But I haven't worked much on .Net of late.

Re: .NET and Node.JS – Performance Comparison

#43
post #13

Earlier quoted context omitted.

Because .NET is Microsoft's baby? How is this not a huge conflict of interest? At the very least, he should put a disclaimer of that conflict somewhere in the article.

Are you insinuating that there is deception being used here? or an inaccuracy? If the blog post was by a node contribute, would you cry foul for that as well? how about giving some counter points against the substance of the blog instead of just attacking the author's credibility based on where he is employed. I am guessing that since you cannot disagree with what was actually said and done by the author, you are gra…

[deleted]

Re: .NET and Node.JS – Performance Comparison

#44
post #13

Earlier quoted context omitted.

Because .NET is Microsoft's baby? How is this not a huge conflict of interest? At the very least, he should put a disclaimer of that conflict somewhere in the article.

Are you insinuating that there is deception being used here? or an inaccuracy? If the blog post was by a node contribute, would you cry foul for that as well? how about giving some counter points against the substance of the blog instead of just attacking the author's credibility based on where he is employed. I am guessing that since you cannot disagree with what was actually said and done by the author, you are gra…

> Are you insinuating that there is deception being used here? or an inaccuracy?

I don't know what he's insinuating, but looking at the code and liking neither technology the bench does indeed look completely inaccurate (it's not even comparing apples and oranges, it's comparing bananas and clams) if not willingly deceptive: https://news.ycombinator.com/item?id=5460267

Re: .NET and Node.JS – Performance Comparison

#45
post #13

Earlier quoted context omitted.

Because .NET is Microsoft's baby? How is this not a huge conflict of interest? At the very least, he should put a disclaimer of that conflict somewhere in the article.

Are you insinuating that there is deception being used here? or an inaccuracy? If the blog post was by a node contribute, would you cry foul for that as well? how about giving some counter points against the substance of the blog instead of just attacking the author's credibility based on where he is employed. I am guessing that since you cannot disagree with what was actually said and done by the author, you are gra…

>Are you insinuating that there is deception being used here? or an inaccuracy?

It could be both, and we should investigate both cases. Why should he get a clear pass?

>If the blog post was by a node contribute, would you cry foul for that as well?

If it was skewed towards node and/or he didn't mention it, then sure.

>how about giving some counter points against the substance of the blog instead of just attacking the author's credibility based on where he is employed.

The blog post has no substance to begin with. The comparison is bogus and the assumptions he makes do not stand. There are already about 20 comments in this thread as to why this is.

Re: .NET and Node.JS – Performance Comparison

#46
post #23

YAY! .Net sorts bytes faster than Async.js sorts floats. In similar news, Go seems to split strings faster than .Net sorts bytes on my laptop. Fascinating stuff.

And PHP serves an empty page faster than Go splits strings. I declare PHP the winner by default.

Re: .NET and Node.JS – Performance Comparison

#47
post #23

YAY! .Net sorts bytes faster than Async.js sorts floats. In similar news, Go seems to split strings faster than .Net sorts bytes on my laptop. Fascinating stuff.

And PHP serves an empty page faster than Go splits strings. I declare PHP the winner by default.

I have bad news:

------------------

% time ./test.go "test1,test2,test3"

["test1" "test2" "test3"]

0.00s user 0.00s system 79% cpu 0.005 total

------------------

% time php -r ''

0.03s user 0.01s system 93% cpu 0.044 total

Re: .NET and Node.JS – Performance Comparison

#48
I posted this comment: "It's obvious that you're new to Node.js.

First of all, you should be aware that Async.js is a mere flow-control library. It does not offload work to separate threads, and neither is it able to parallelize work. Internally, it mostly does bean-counting (but very helpfully so).

As you can see in the source https://github.com/caolan/async/blob/master/lib/async.js#L35... async.sortBy simply uses Array.sort for the actual sorting. The only reason you'd want to use Async.sortBy is if the values that the array of "keys" is not known beforehand (and needed to be loaded through io - asynchronously). This is clearly exemplified in the documentation. https://github.com/caolan/async#sortBy

The implication of this that your call to async.sortby can be replaced by a call to array.sort. This will remove two unnecessary runs of async.map, inflicting a potentially huge performance penalty.

You do need to pass array.sort a comparator function, otherwise it will sort lexicographically (see https://developer.mozilla.org/en-US/docs/JavaScript/Referenc... ). That said, I'm not sure what the actual contents of your input file is. In your .Net example, you do not seem to bother to convert the array of strings to an array of ints (or floats). I think that .Net sort will sort an array of strings lexicographically as well. Furthermore, in the node.js example, you seem to be content with returning the resulting median as an int, not as float. Do the input "decimals" in the input file represent ints or floats? Do they all have exactly the same amount of decimals? Are both the Node.js and .Net algorithms doing the same thing? I think not.

Finally, we get to Array.sort. Array.sort blocks. Depending on the multi-threading efficiency of the underlying algorithm of Array.sort (which I don't have insight in), the code may not be able to use all available system resources. Keep in mind that Node.js is single-threaded. I practically don't know anything about .Net, but I assume it will magically start new processes and or threads if the runtime deems this beneficial. For Node.js, you may want to try the Cluster api, http://nodejs.org/api/cluster.html . You could try seeing if performance increases by adding one or more extra server processes.

I can't comment about the quality of the .net code since I don't have any experience with it.

I think it would be fair (and very educative to others) if you'd rerun the benchmarks with 1. Async.sortBy replaced with array.sort 2. with both .Net and Node.js algorithms fully doing the same thing (i.e. let them both sort either floats, ints, or strings), and 3. at least one extra server process for Node. I think most interesting would be if you'd made the changes step-by-step, and run the benchmarks at each step.

My guess is that step 1 would give the biggest difference. Depending on how you decide to resolve the differences in the two algorithms, performance of your .Net code may be slightly affected. It could potentially be speed up in fact, if somehow it's able to sort ints (or floats) faster than strings. The actual job of sorting probably overshadows it all though."

What do you guys think of this?

Re: .NET and Node.JS – Performance Comparison

#49
post #48

I posted this comment: "It's obvious that you're new to Node.js. First of all, you should be aware that Async.js is a mere flow-control library. It does not offload work to separate threads, and neither is it able to parallelize work. Internally, it mostly does bean-counting (but very helpfully so). As you can see in the source https://github.com/caolan/async/blob/master/lib/async.js#L35... async.sortBy simply uses A…

See my own notes on the issues I see in the code: https://news.ycombinator.com/item?id=5460267

Re: .NET and Node.JS – Performance Comparison

#50
post #28

A common cause of slowness in .net web app is multiple database round trips during a single request, all happening in sequence. You can write async database calls in .net but they're not the standard / path of least resistance, and by the time you app is hitting these issues, refactoring it all is a big undertaking. The results do not surprise me, but what I find more interesting is how different ecosystems and frame…

[deleted]
Post reply on HN