Saturday, 24 February 2007
Why use J2EE (aka JavaEE) instead of Rails
First off, I love Ruby. However, I'm not a Ruby evangelist. To be a "proper" evangelist you must preach the technology all the time even if it is a square peg in a round hole. Listen to this guy:
Why even use J2EE at all, why not use Rails? Well a sometimes you don't have a choice...
Why use Ruby instead of Java
- It is in style - Java is no longer "cool" enough to get your next book deal and present trendy talks
- It is easier - Java APIs tend to be designed with the locator to the factory of locators to the factory designed by committee of complexity lovers
- It is interpreted - it is often just easier to write scripted code faster which is why JSP is more successful than OO-Java (irony intended)
- Your system is relatively simple
- dynamic typing
Why use full-on JavaEE
- You aren't using MySQL - HA. Nothing supports connectivity to the number of databases nearly as fully as Java.
- You need proper concurrency control - What if two users edit the same data at once? What if 1000s of users read the same data at once? What if one edits that data while 1000 read it?
- Imperative transaction management sucks
- You need services or APIs not provided to or by Ruby
- You don't think the place you're deploying this to will install C compilers on their production AIX boxes (necessary to install most Ruby libs because they're light wrappers around C code
Frankly I love Ruby but Rails is a toy. If you're writing grandmother's address book and pessimistic locking for everything is okay, and occasional undetected data loss isn't that big of a deal -- it doesn't matter what you use. Time to develop is critical but often more critical is cost to maintain. Ruby's deployment semantics are a pain here.
However, I grow increasingly dissatisfied with Java as a language. Its not the syntax so much as the goofy committee-designed APIs. Yet I increasingly LOVE the JavaVM. Open source, FAST, parallel GC, JITs, multi-platform! Gotta love that (even if the classloader architecture blows just a little bit). Projects like JRuby and support for scripting in the JDK make me increasingly encouraged that we DON'T have to choose. We can have Ruby with a non-sucky deployment environment (we use JRuby for testing already). We can use unpopular databases with Ruby. We can get better transaction management, JMS services, etc. We might even one day call non-bizarre Ruby libs from Java (a guy can dream) rather than their bizarrely designed Java alternatives with no performance penalty and even a modest gain.
