Archive for November, 2013

Why I used Java servlets instead of Rails


November 4th, 2013

Back in 2010 I set up an online store for Arq, and it’s been working well ever since then. It’s based on the excellent Potion Store, which was generously made open source by Andy Kim (thanks Andy!). Potion Store is a Ruby on Rails app. When I first used it, I didn’t have to modify anything about it, which was good because I knew nothing about Rails.

A few years later I wanted to offer discounted multi-license SKUs, so I had to modify the app. I had my Rails book and I walked through the code, or more often the lack of code, since the framework did almost everything by default. In 3 days I learned enough Rails to complete my changes. It worked great, and I wrote almost no code. It was a profound experience — I had never written so little code and gotten so much functionality.

A month ago I needed an online store so people could purchase licenses for Filosync, my new file sync and share product. An obvious option would be to reuse the Potion Store code again. But I decided to write my store from scratch using Java servlets, MyBatis and JSPs, for several reasons.


One reason is speed of change of the framework. Google is nicely tuned for answering programming questions and troubleshooting error messages, but for Rails it was harder for me to get clear answers to my questions. I was never sure which version of Rails was required, or which patch to which module I had to add to my environment. The Java stuff is older and more stable, which makes it easier for me to deal with. Trailing-edge technology FTW! :)


Another reason for choosing Java is obviousness. I was amazed by the Rails approach and how much the framework did for free, without my having to write any code. On the other hand, I felt I had to remember all the things the framework did since there was nothing on the screen showing me what would happen. If I worked with Rails every day I imagine this wouldn’t be a problem, but I don’t work with Rails every day. With the Java approach there’s a lot more typing, and more code means more bugs, but I think it’s easier to follow what’s going on.

I wish there were a Rails IDE that would somehow show me all the things the app is really doing, not just my code — something like the “Show Paragraphs” function in word processors that shows all the hidden characters, except in this case it would show all the hidden functionality.

So, did I do the right thing?I’d like to think that I made the right choice for sound technical reasons, but it could be that Rails was just too far outside my personal comfort zone.

Maybe the problem is just that I prefer libraries to frameworks for this stuff. Java is very simple but it also has everything under the sun if you need something. I just create very simple servlets and then include the libraries I need for database communication, sending mail, and talking to Braintree.

Or maybe the real point of this blog post is it’s hard to take over someone else’s code base and make it your own :)

P.S.  The other day I saw a graph on Twitter showing a decline in Ruby and increase in Java. So I guess I’m on trend?