6 ms·
Once Again, Twitter Drops Ruby for Java
- dasil003 16y agoI shudder to think of CTOs basing high-level engineering decisions based on such content-less fluff.
- kaffiene 16y agoTwitter have hard throughput issues that are real engineering problems. 'Fluff' is probably a better term for the cheap and cheerful web sites that Rails is designed to produce than a message handling service on the scale of Twitter.
- deleted 16y ago[deleted]
- lallysingh 16y agoIndeed. I'ts already turning into a "my language is more scalable than yours" contest, here on HN. If it was normal posturing and trash-talk, that'd be fine. But engineers are going to suffer for this --- their well-thought-out arguments for one platform over the other are gonna wash to big site chose A over B. We will use A.
- laujen 16y agoTwitter is beyond the scale of most businesses. This -- whether Scala or Java or PhP or RonR or Python -- is the best choice for our code base generating millions of hits per day is a problem many of us would love to have!
- SpiralLab 16y agoAgreed. Build for the problems you face now - not the problems you may theoretically have in the future. If a business grows that rapidly - it is most likely that the original systems will have evolved dramatically from day one anyway - in ways you wouldn't have imagined.
- grandalf 16y agoThis isn't a knock against Ruby. Java and Ruby are designed to solve different sorts of problems (though there is a lot of overlap). Twitter is not in the overlapping region.
- daemin 16y agoAdditionally it makes sense to me to try building something as experimental as twitter was back a few years ago in a language and framework that allows quick iterating and rapid prototyping, such as Ruby on Rails. Now that the design has largely been solved (shall we say), the application can be migrated to a different architecture and programming environment. One that is more suited to the large scale, low latency requirements, and minimal functional changes that twitter finds themselves in now. It's also funny to think but Java used to be the slow language on the block for building websites and services in. Then a lot of people ended up using it, and a lot of effort was put into the JVM, especially the hotspot compiler, the garbage collector, etc, and now it's one of the best technologies out there for doing large scale websites with. I think if more people use Ruby and Rails, that we'll get more investment in the platform and it will end up being significantly faster in the future.
- theoj 16y agoOnce you increase the scale sufficiently, it's more cost effective to hire a team that makes the code run faster rather than add large expensive servers. This is what's happening now at Twitter. It's not that Java is now absolutely 100% better than Ruby on Rails, it's just that Java is better for a site of that scale.
- acangiano 16y agoYep. Ruby on Rails: suitable for apps with less than 1 billion queries per day.
- theoj 16y agoIt's more than just about queries. Ruby on Rails is an absolute pig in terms of memory used. That's something you find out pretty quickly if you build your own VPS setup.
- aphexairlines 16y agoGoing to the JVM because of memory usage issues is like going to KFC to lose weight.
- bballant 16y agoOn my team such remarks cost a dollar. The JVM generally does very well in terms of memory use compared to many languages. It's easy to test: write an a small program in both languages that creates boatloads of objects and then watch the memory. The JVM will use up all the memory it can (the amt is configurable with some runtime flags) before the GC kicks in and frees up space. It uses a couple of buckets for different types of objects, and can easily clean small short-lived objects with a bit of a CPU hit, but without affecting the performance of the application. The upshot is you'll see Java's mem use slowly creep up, you'll see a small spike in CPU, then the mem use will drop. If you don't see this, it means the code is poorly written and its keeping around object references. Ruby's GC is much less efficient. It has no concept of memory buckets like the JVM and will effectively stop execution and traverse every object in the heap twice, marking and then freeing up space. Early versions of Java (pre 5) had some substantial problems with memory management, but it's been very performant for quite some time and easily out-paces ruby.
- guelo 16y agoI have no insight into Twitter's decision making, but the reason I recommend Java over the other popular languages comes down to readability and maintainability. In my experience the dynamic-ness of the language begins to work against maintainability and readability after a while, especially after the original designers hand off the project to other programmers. Most language communities have built over time best-practice guidelines for readability and avoiding common bugs. But I think Java's age and enterprisy culture have allowed it to evolve stronger guidelines (see Joshua Bloch's Effective Java), and it's limited flexibility make it easier to maintain. If you are in a highly competitive startup environment where break-neck execution for the next 6 months to a year is a matter of survival then Java might not make sense, but that doesn't describe most projects.
- eropple 16y agoThis matches my own experience as well. There are creeping-horror Java codebases, but I find it easier for me and the people I work with to effectively build long-term, maintainable, sustainable code in C# or Java. (My day job involves Java, my play-around startup concept is based on .NET.) I suppose that if you're building a crash-or-sell "startup," this might not be a huge priority for you, but as guelo noted, most projects don't fit in this mold.
- Sapient 16y agoI don't believe Ruby and Rails are prescribed for most projects. Just the ones where they makes sense. That said, I have taken over development of a few legacy rails applications and never had a problem adapting to the idiosyncrasies of the old developer or team.
- haploid 16y agoWell, it's not necessarily true that RoR is prescribed for most projects. A more general statement, which seems in my experience to be accurate, is that $shiny_hot_language_popular_with_the_kids_these_days is the prescribed language/platform for startup applications. I am old enough to remember when Java was actually in this exact role, with "legacy" web apps written in C( via cgi or nsapi ), perl, or c++/com/asp( via asapi )being seen as uncool and dinosaurish by kids who shat their pants after reading the servlet/jsp 1.0 spec. Nowadays, I'm seeing more chatter about clojure/haskell/node.js startup technology stacks than RoR, so my guess is that the shiny new thing is moving yet again.
- Groxx 16y ago3x faster for the pain of Java? I'll stick with Rails until I have enough money to pay people to migrate for me. edit: >That along with the news that Twitter has hired 25 more employees kinda tells that Java's code base is practically more maintainable than equivalent Ruby code - at least when the code base is huge and the team size is large. What? How does hiring more employees imply something is easier?
- fleitz 16y ago"That along with the news that Twitter has hired 25 more employees kinda tells that Java's code base is practically more maintainable than equivalent Ruby code" Uhh if you need 25 more people that tells me that your code is less maintainable and you're writing much more of it. No one has ever debated that in raw execution speed Java is faster, the problem is that most startups have plenty of CPU and few devs. Twitter really did things ideally, start on a rapid dev platform and then port to a faster platform after acquiring the userbase and capital infrastructure that makes such a decision make sense. I'm not sure that if I was working on the JVM that Java would be my language choice, I'd probably use Mirah/Clojure/Scala. The extra 25 devs are probably to ensure T2EE (Twitter 2 Enterprise Edition) compliance and refactor their POROs (Plain old ruby objects) to work with their ETB middleware. /snark
- Sapient 16y agoI think you nailed it there. Most startups fail anyway, so devoting a single day more than needed on development is a waste of very valuable time and money. How many extra VPS' is a month of saved development time worth? All skill being equal, choosing Java over Ruby for a new project is one of the worst cases of optimize early I can imagine.
- rbanffy 16y agoI like my Python options - to start with Python, pinpoint the hot parts and going from hand-tuning Python code, Cython and then C - is a better option. They started with Ruby and Rails and, possibly, their optimal path was this one: Ruby, then Scala and then Java. But that's one path I would rather not go down. Not unless I could use another non-Java JVM-friendly language. Java is very low-level compared to Ruby, Python or Scala. C++ is lower still, but the extra performance and control it gives you, as well as a free LLL-to-HLL boundary, are worth it.
- bballant 16y agoI also thought that was a weird comment. But In my experience a big team benefits from a compiled, statically typed language like Java (better yet, Scala). Perhaps that's what the author meant.
- noelwelsh 16y agoTwitter is well known for using Scala. Although the article says Java, I'd like to know if this is the case (i.e. no Scala) or a simplification. I've done more Java programming than a man ought, and now a fair bit of Scala. The JVM is fast -- far faster than the Ruby/Python/PHP VMs. Harnessing that power has been an issue, as Java is so inexpressive. I find with Scala I can write code as quickly as in any other language I've used. It makes a great combination -- code quickly and get quick code -- and as a result I don't see any use for RoR or other interpreted frameworks in my coding.
- plinkplonk 16y agoInteresting why they chose Java instead of Scala for this move. The last time they moved off Ruby they moved to Scala, not Java. Anyone at Twitter want to comment?
- drdaeman 16y agoMaybe they actually meant Java-the-platform, not Java-the-language?
- cgopalan 16y agoFrom the original engineering article on the twitter site, it seems they switched from a database backend (MySQL) to using Lucene and also heavily customized it. Maybe it was just a lesser hassle to interact with Lucene using Java. Would love to hear reasons directly from them.
- ChrisArchitect 16y agogah, this again eh. Friday's news. This is a pretty unique/upper tier end of the spectrum problem. They needed to be able to cope with the ridiculous amount of realtime indexing and searching going on around the SEARCH stack, so ok, Netty etc. Not really anything about abandoning Rails etc.
- gulbrandr 16y agoPlease do not post links with utm junk in the URL.
- sgt 16y agoWhen they say they are changing to Java, does this mean Scala, or do they actually mean the Java programming language running on the Java platform?
- bxr 16y agoBetween their development blog and github account, they appear to use both significantly. I'd like to know more about the proportions, but haven't seen any numbers about it online.