Live data from Hacker News

When Haskell is Faster than C

paulspontifications.blogspot.com

1–10 of 119 posts

Re: When Haskell is Faster than C

#2
A similar anecdote from my own experience:

Chesspark had a web and a win32 native client. It kept track of your friends with a roster (the underlying stack was based on XMPP). As a way to make new users feel welcome, I and a few coworkers were added to all new user's roster (like MySpace Tom). It wasn't long before this overwhelmed our clients.

Each client was written by a different developer. One was in JavaScript, and one in C. Due to some poor design choices on the C side, the JavaScript client was substantially faster. I don't remember the exact benchmarks, but I think it was close to 50x faster.

The JavaScript code took less time to develop and less time to fix. The C code did eventually get fixed and outpace the JavaScript on raw speed, but if I were doing it again, I never would have made a native client to begin with.

Re: When Haskell is Faster than C

#3
I don't think his example is helping his argument at all.

He cherry picks optimizations for the Haskell, such as using Data.Vector.Unboxed instead of the regular lists and removing calls to isLetter, but then he rolls his own linked list and uses getc in the C version. He doesn't even have the correct return type for main.

Haskell written by decent Haskell programmers is faster than C written by poor C programmers. Not very surprising.

Re: When Haskell is Faster than C

#5
post #2

A similar anecdote from my own experience: Chesspark had a web and a win32 native client. It kept track of your friends with a roster (the underlying stack was based on XMPP). As a way to make new users feel welcome, I and a few coworkers were added to all new user's roster (like MySpace Tom). It wasn't long before this overwhelmed our clients. Each client was written by a different developer. One was in JavaScript,…

Good design choices are better than bad design choices?

Re: When Haskell is Faster than C

#6
post #2

A similar anecdote from my own experience: Chesspark had a web and a win32 native client. It kept track of your friends with a roster (the underlying stack was based on XMPP). As a way to make new users feel welcome, I and a few coworkers were added to all new user's roster (like MySpace Tom). It wasn't long before this overwhelmed our clients. Each client was written by a different developer. One was in JavaScript,…

Good design choices are better than bad design choices?

More like: good design choices are vastly more important than micro-optimisation, and Haskell is a good design choice.

Re: When Haskell is Faster than C

#7
I'm in no position to judge the quality of the Haskell code (I couldn't program my way out of a wet paper bag in Haskell) but after half a lifetime of writing C for a living I can say with confidence that the C code is horribly written and horribly inefficient.

It is tempting to pull the code and fix it.

If you want to compare two languages make sure that you are proficient in both.

Re: When Haskell is Faster than C

#9
post #2

A similar anecdote from my own experience: Chesspark had a web and a win32 native client. It kept track of your friends with a roster (the underlying stack was based on XMPP). As a way to make new users feel welcome, I and a few coworkers were added to all new user's roster (like MySpace Tom). It wasn't long before this overwhelmed our clients. Each client was written by a different developer. One was in JavaScript,…

Nice story.

If I flatly said that JavaScript was 50x faster than C, I'd have butchered your story and some real points of interest here.

Supposing your team is productive in JavaScript, but not too exceptional with C, then a similar time investment can produce significantly faster JavaScript programs. In this way, in real practice, language productivity can totally drown technical performance differences. Even when you need to optimize, optimization is also subject to productivity differences.

It is probably inherently somewhat harder to reach the required level of ability in C to get the required performance, and thus to find people with this ability. Ergonomics and ease of entry don't just make people happy, they also have an impact on the performance of the average program to be written.

But even if it turns out that C is at no disadvantage here - it matters more what you will be able to use well. If C makes insane things possible that you will never do, they aren't a good reason for you to use C.

Moreover: following a general policy of writing JavaScript (or other favored language, within reason) is going to give you good-enough performance in a HUGE variety of problems.

Even if this performance is less than C's for an important program, there are two mitigating factors:

1. The slower performance may still be easily 'good enough'. There are diminishing returns on speed improvements. More speed does not always make the software better.

2. You can get the required speed by optimizing and replacing the bits which are bottlenecking the speed-critical bits, without committing to writing the entire project at 'max speed' out of the gate, which will often be a gigantic waste of resources on speed improvements that no one will ever see.

Most projects have limited applicability and limited lifespans. What matters isn't whether you are at maximum performance. What matters is whether performance is good enough for purpose.

Re: When Haskell is Faster than C

#10
post #2

A similar anecdote from my own experience: Chesspark had a web and a win32 native client. It kept track of your friends with a roster (the underlying stack was based on XMPP). As a way to make new users feel welcome, I and a few coworkers were added to all new user's roster (like MySpace Tom). It wasn't long before this overwhelmed our clients. Each client was written by a different developer. One was in JavaScript,…

[deleted]
Post reply on HN