Once Again, Twitter Drops Ruby for Java
readwriteweb.com
readwriteweb.com
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
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.
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.
My experiences with Java have never been very impressive. Why do you think a bigger team benefits from static typing?
Large teams should be hunted down and broken into smaller teams, it's a stupid idea to have such a large team anyway.
The biggest problems in Java are not static typing (although inferred typing is much better). They are the lack of first class constructors, functions, unsigned types, operator definition and overloading and closures. The one actual feature Java has that no one else has is ironically one that is also one of the worst things about Java: checked exceptions.
When java lets me write something like: let (|>) x y = y x is the day I'll consider using it again, btw the above code is the pipe operator which lets you do things like this.
"Hello World!" |> puts "10".to_i #=> 10
10.to_i #=> 10
I can see how dynamic typing, lack of interfaces, etc. can seem to cause a bunch of confusing to someone who's used to static typing, but in my experience lack of code readability is far more troublesome.Another advantage of statically typed OOP code for big teams is it allows a verbose yet formal way to define interfaces as a team, and then break up the work into smaller chunks. The formality can certainly slow an individual programmer down, but in a big team I've found it makes breaking up the work easier.
I wouldn't argue against the notion that ruby's expressiveness and use of functional paradigms might make up for it's lack of static typing, and ruby in the hands of a great programmer is pure pleasure, but most teams don't have just great programmers.
Finally, I absolutely love Scala and I think it's worth mentioning in any discussion of ruby and java. It, sorta, bridges the gap between the two languages and I'd recommend it as a good choice for a team of any size.
But if you're not testing your code, then the compiler is indeed a great dose of confidence.
I do, though, firmly agree with this: "I wouldn't argue against the notion that ruby's expressiveness and use of functional paradigms might make up for it's lack of static typing, and ruby in the hands of a great programmer is pure pleasure, but most teams don't have just great programmers."
Ultimately things do depend quite a bit on the developer resources you have.
So, what I would love to see is a Web Framework similar to RoR written in Scala ...
Aside from JSP, we're really happy w/ Spring MVC. We've managed to avoid the crazy amounts of XML that Spring is known for in favor of its more modern annotation-based way of doing things.
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.
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.
In my personal experience, I've re-written a few ruby utils in Java for an order of magnitude speed improvement. I've seen a ruby site crater under load because of memory issues that its java replacement easily manages (which is sorta what the OP is about). The JVM is especially well suited for handling "stateless" http requests because it's ability to quickly create and destroy small objects.
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.
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.
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.
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.
- worse, IMO
One thing I cant remember ever having read is a horror story about people taking over a legacy Rails app, while those stories seem to be fairly common when talking about Java apps.
Seems to me that, for the most part, people who know Ruby and Rails have taught themselves, while sub-par and mediocre Java programmers are produced in their hundreds, fresh from their first programming experience in college.
Seems logical to me then that its going to be far easier to get experienced Ruby programmers than to get experienced Java programmers.
Bad code can be written in any language or on any framework. I would suggest, however, that when at larger scales, there are significant benefits to a more restrictive language and tool set. I write Java at work, and while there are cases where it's not as expressive as I'd like (s'why I write my own code in C#, which is as expressive as I'd like), reducing the ability of developers to Do Stupid Things is, to me, a very large plus.
The claim that people who know Ruby and Rails have taught themselves--well, no shit, right? I taught myself Java, too. And C#. And PHP, Python, Ruby, and half a dozen other languages. Of course sub-par and mediocre Java developers are churned out by college. So what? Hire ones who aren't. And if you give it ten years (assuming the Rails fad has legs--I'm skeptical, but just for argument's sake let's assume it's not) colleges will be churning out mediocre Ruby hacks just as well.
Your comment reads as fanboyism and not much more.
I prefer added flexibility combined with convention over configuration. In my experience, Java teams deliver less functionality implemented on top of more complicated infrastructure at 2 to 5 times the time it takes for a smaller team working on Django to implement slightly more functionality.
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.
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.
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?