Live data from Hacker News

Benchmarking Codswallop: Node.js vs. PHP

philsturgeon.co.uk

1–10 of 85 posts

Re: Benchmarking Codswallop: Node.js vs. PHP

#2
Good test.

At some point, you'd expect these arbitrary this vs. that comparisons to die off. They haven't, and I'm guessing they won't.

Basically, it comes down to picking the tool that best supports your use case, or being okay with a compromise. Like the SQL/NoSQL discussions recently... Use it poorly and you get poor results.

Re: Benchmarking Codswallop: Node.js vs. PHP

#3
I agree that the comparisons are often unfair between languages/frameworks, and agree with everything phil says, but there is a lot to be said for language level non-blocking constructs.

I am really enjoying reading Go code and seeing how people use concurrency etc; and they are all doing it the same. When I would read ruby, I would have to know the particulars of a library like Celluloid or EventMachine which made it harder.

Re: Benchmarking Codswallop: Node.js vs. PHP

#5
Node benchmark is flawed though. Add something like

require('http').globalAgent.maxSockets = 64;

at the top of node script if you want a fair comparison with async php version. The bottleneck is bandwidth here. Not the runtime.

On my laptop, original script from the author took 35 seconds to complete.

With maxAgents = 64, it took 10 seconds.

Edit: And who is downvoting this? I just provided actual numbers and a way to reproduce them. If you don't like how the universe works, don't take it out on me.

Re: Benchmarking Codswallop: Node.js vs. PHP

#6
Node.js for web scraping usually is the obvious choice:

Scraping using jQuery syntax such as:

  $('table tr').each(function(ix, el) {
    names   .push($(el).find('td').eq(0));
    surnames.push($(el).find('td').eq(1));
  })
is more familiar to most web developers as opposed to the PHP syntax.

Even if Node was 5x slower than PHP I would still go for Node because of its easy jQuery syntax.

Re: Benchmarking Codswallop: Node.js vs. PHP

#7
I get sick of these language wars, especially the constant stream of PHP ridicule that just never seems to end. The positives I try to take away from all of it is that there are a lot of people that are extremely passionate about software development and are striving for better tools and ways to express themselves. I want to believe that through the vitriol encountered in some of these articles that there are people really trying to improve the technologies at heart instead of taking part of some kind of programing language apologetics. In regards to PHP, I think that the ridicule has led to improvements in the language, but the overall tone in some of these articles is still a turn off for me.

Re: Benchmarking Codswallop: Node.js vs. PHP

#8
Benchmarking is very hard because even the same language could show different results.

For example:

  for($i = 0; $i 
vs

  $count = count($list);
  for($i = 0; $i 
Most of the time benchmarks prove how capable a programmer is, not the speed of the language used.

Re: Benchmarking Codswallop: Node.js vs. PHP

#9

Node.js for web scraping usually is the obvious choice: Scraping using jQuery syntax such as: $('table tr').each(function(ix, el) { names .push($(el).find('td').eq(0)); surnames.push($(el).find('td').eq(1)); }) is more familiar to most web developers as opposed to the PHP syntax. Even if Node was 5x slower than PHP I would still go for Node because of its easy jQuery syntax.

Did you bother to read the post? It pitted two different DOM traversal libraries against each other:

* cheerio (https://github.com/MatthewMueller/cheerio)

* PhpQuery (https://code.google.com/p/phpquery/wiki/jQueryPortingState)

Both of these use a jQuery-esque syntax, so your comment regarding DOM traversal in PHP is a moot point.

Re: Benchmarking Codswallop: Node.js vs. PHP

#10

Node.js for web scraping usually is the obvious choice: Scraping using jQuery syntax such as: $('table tr').each(function(ix, el) { names .push($(el).find('td').eq(0)); surnames.push($(el).find('td').eq(1)); }) is more familiar to most web developers as opposed to the PHP syntax. Even if Node was 5x slower than PHP I would still go for Node because of its easy jQuery syntax.

The argument you really should be making is that the Javascript syntax is familiar. jQuery and it's methods for traversing the DOM can trivially be implemented in any langauge. e.g. PHP:

http://symfony.com/doc/current/components/dom_crawler.html#n...

Post reply on HN