Hacker News new | ask | show | jobs
by gary4gar 4968 days ago
Twitter's better performance is because of a better architecture than Java language. Further, the performance is from JVM, so you can use any of the JVM language including JRuby to get similar effects.

This articles seems more like link-bait to me.

2 comments

I agree. I think I could write a scalable Twitter in mostly Ruby. And I've never written a line of Ruby in my life.
Have you worked on other sites with a similar scale to Twitter? If not, how would you know?
I work at Google :)
Then you should really know better than to make statements like "I think I could write a scalable Twitter in mostly Ruby. And I've never written a line of Ruby in my life."
This isn't really a comment on Java, Ruby, Twitter, Google, or my programming ability. It's a comment about the fact that once you've designed a scalable distributed system, the constant factor runtime isn't so important.

Twitter has clearly engineered a working distributed system (or you would have read stories like "5% of Twitter users lost their tweets when our servers caught on fire last night"), so the fact that they wrote it in Scala or Java is largely irrelevant. They need fewer computers than they would have if they wrote it in Ruby again, and that's not something to discount, but I think it's technically possible to have a full Ruby stack do what Twitter does. And, they would have needed even fewer computers if they used C or C++. So it's clear that Java was a social choice (it had the right books, libraries, and stack of resumes) rather than an absolute must.

Besides, Ruby and Java both make the same C library calls to do I/O. So it all ends up being the same for everything except search, trending tweets, and other cpu-intensive analysis.

I think I could write a scalable Twitter using mostly low-paid workers who manually write down the tweets and deliver them in person. It's just a matter of hiring enough workers now that I've designed this scalable distributed system.
Well, there's pretty much no response he can give to that then.

Unless of course, you work in the marketing department or clean the buildings?

Based on that I would like to hear how you would do so. Would make an interesting blog post or comment here.

  <!-- insert *evil grin* here -->
I suppose it doesn't matter if you didn't work on similar scaling problems in Google.
You're right and I know that "appeal to authority" is not a valid argument mechanism.

With that in mind, I just couldn't pass up the opportunity to make an amusing comment.

And..?
Fair enough :)
I don't think so. Java outperforms JRuby, probably because of typing. See: http://shootout.alioth.debian.org/u64q/benchmark.php?test=al...
Java probably outperforms JRuby primarily because the JVM was designed and tuned to run Java.

But in any case, if Twitter's architecture is truly scalable then any intrinsic slowness of the language shouldn't be a big problem, because they can just toss more hardware in to compensate. What is a problem is a buggy VM that leaks memory. To run thousands of instances in a heavily instrumented way, the VM must be stable and predictable.

Statically vs dynamically typed peformance difference is clear for virtually any static or dynamic language you care to name, it has nothing to do with the jvm being "tuned" for a language: http://shootout.alioth.debian.org/
>> peformance difference is clear for virtually any static or dynamic language you care to name <<

JavaScript

http://shootout.alioth.debian.org/u64/which-programs-are-fas...

Only when they removed LuaJIT from the shootout, it is dynamic and fast (it was around where Java is in the benchmarks).
The LuaJIT performance is pretty impressive for a dynamically typed language, but it's hard to deny the fact that mainstream dynamically typed languages our outperformed by their static counterparts.
Thats partly because they were not designed for performance. Lua of course was as it was designed partly for slow small systems. But pypy is getting on pretty well too and javascript, showing what you can do even if not designed for performance.
How does that explain Julia[0]/Node.js? Both within 1-2x speed of C, I think static has less to do with it than you think.

[0] http://julialang.org/

You pretty much have to enforce static type invariants (e.g. "this variable will never be other than an int") to JIT stuff performantly. I don't think that's a point against the GP's argument at all.
Probably because there are better Ruby programs to be written for those tasks :-)