If I was about to start writing a new web app…

Several techie friends recently asked what technologies I would recommend if I was to set out today on building a new web app / web service. I’m not sure I’m the best person to ask, but I guess if you’re coming from a “real job” into the startup space it can be daunting figuring out what’s worth investigating. So, in the spirit of helping more people, here’s my quick and highly opinionated braindump on this topic, based on what I’ve learned so far building 5 Blocks Out.

it’s so SHINY!

Since I’m dispensing unsolicited advice, let’s start with this: understand the problem you’re trying to solve before building your technology shopping list. If you don’t do that you will find yourself wasting time playing with shiny new stuff that doesn’t really help you build the software you want. Mmm, shiny.

On to the list.

Application Frameworks

  • In the Ruby domain it’s worth looking at Rails
  • …and Sinatra: much simpler than Rails and, I think, more fun. Great for small and low-in-the-network-stack apps.
  • I hear the new .NET MVC stuff is not bad.  It sounds like they learned a lot from Rails, which is great.
  • Many friends of mine do Drupal development. Looks nice for CMS apps.
  • I hear Java people are playing with groovy and grails. Can’t help you there.

Data stores

Naturally, you need to deeply understand the app you’re trying to build in order to make a smart decision about data storage technologies. That said,

  • MySQL and PostgreSQL are both great for relational data storage. We use PostgreSQL for 5 Blocks Out and I like it a lot. If you’re already familiar with one of these, it’s hard to justify switching.
  • Looking at how 5 Blocks Out has evolved I now wish I had started with MongoDB instead of PostgreSQL or MySQL.  If you have a chance to play with it then do.  It seems a really nice fit to apps that want everything to be denormalized, which many web apps do.
  • CouchDB is also worth looking at, if you’re considering MongoDB and document-oriented stores in general. I personally don’t like the syntax, though.
  • See also Cassandra. It’s overkill for anything I’ve wanted to do, but if you’re storing large amounts of data that isn’t normalized or regular in structure, it’s worth a look.
  • Redis is a pretty awesome in-memory key-value store. Nice for certain kinds of apps. Wish I had an excuse to use it.
  • In general, look up “NoSQL” and read about the vast array of fun new stuff

If you are using Rails…

  • Start by installing RVM and using it with gemsets to install, switch between, and test your Ruby versions and gems
  • Use Rails version 3 unless you really have to use a legacy version
  • This site tells you which Rails plugins work on v3.
  • Rails wants to start you with ActiveRecord as a storage wrapper.  That’s great for SQL-based apps, but you might not want AR if you’re using no-SQL stores like MongoDB.
  • Test frameworks: RSpec and Test/unit are the ones I like best.
  • Some people — not me — prefer Shoulda to RSpec.
  • Cucumber is a popular companion to RSpec for integration testing.
  • JSON as a quick-and-dirty serialization format with great javascript integration
  • Ruby/RailsTextMate has great plugins for Ruby, Rails, HAML, SASS
  • Search for “rails version 3 application templates” to see if anyone has already packaged together a starter kit you like

Lower-level stack: OS, Web, and Application Severs

I try to spend as little time at this level of things as I can.  But I keep getting dragged back…

  • We use nginx, not apache. Simpler, very fast, secure.
  • We use Passenger and Ruby Enterprise Edition with nginx. But there are many app servers for Rails, e.g. it comes with Mongrel.
  • We require Unix of some flavor.  Right now we use Ubuntu and I develop on the Mac (which rocks, ‘cuz it runs all the same stuff as our server).
  • I would not recommend Rails on Windows… I’ve tried it, it’s painful.
  • Monitoring: monit, god, New Relic
  • Deployment and Server config: Capistrano or Vlad the Deployer
  • Server Config: Chef looks pretty hot. Haven’t tried it yet. Want to. I know there are a few other options here, would love to hear of something simple that works well.

Web UI

  • jQuery is great and has a ton of free plugins, plus jQuery Themes. I highly recommend it. I started on Rails with Prototype, but jQuery feels more natural to me.
  • I use HAML for all our HTML generation, and SASS for CSS generation.  I *love* these.
  • Get smart about HTML5

Other bits and bobs

  • I use TextMate as my editor.  Nice if you develop on a Mac.
  • I am not a big fan of IDEs, and if I was I’d still be using Visual Studio with whatever the latest and greatest .NET stuff is. (Yes, I’ve tried NetBeans, and a bunch of other ones. Slow, buggy, ugh. Give me text.)
  • homebrew is a nice package management system for Mac OS X

Hosting

The Cloud

I really haven’t played with much in the way of cloud services, beyond hosting. I would look at:
  • Amazon EC2 and Azure
  • Amazon S3 for bulk storage
  • Amazon CloudFront for CDN

…and survey the growing number of services following in Amazon’s footsteps.

Mobile

Start by reading this amazingly comprehensive presentation on the mobile landscape. Then…

And while this post is really about the web app stack, many web apps these days have rich mobile app companions, so…
 

  • iPhone/iPad if your target audience is that small number of people rich enough to have one. But beware, they’re very different from everything else, require you to be tied to a Mac, and Objective C will give you a headache.
  • Android

 

Queueing and Working Offline

If you are thinking about web apps you should also get familiar with queues that will let you do work offline, asynchronously from end user requests. For instance, sending emails offline, rotating images, generating newsletters, etc.  This technique is vital in Rails, since Ruby is interpreted and it’s easy to write inefficient Rails code that results in long  HTTP request times.

Again, wish I had started using queueing way earlier for 5 Blocks Out.

Repository / Source Version Control

Git with GitX. For web hosting of repositories use github, or gitosis if you want to do it yourself. ’Nuff said.

Happy coding!

Ubuntu upgrade breaks RMagick on Ruby Enterprise Edition

I recently upgraded the server running 5 Blocks Out from Ubuntu version 8.0.4 to 10.04. Somewhere along the way the binding between the rmagick gem and the underlying imagemagick libraries broke, probably because Ubuntu upgraded imagemagick on my behalf. And as I discovered over coffee this morning, if your Rails app depends on rmagick, and rmagick can’t bind to imagemagick, you’re hosed. So… here’s the solution I found after some panicked schnoozling around the web.

First, the error: when trying to start Rails you get an error that looks like this:

libWand.so.10: cannot open shared object file: No such file or directory - /opt/ruby-enterprise-1.8.6-20090520/lib/ruby/gems/1.8/gems/rmagick-2.12.2/lib/RMagick2.so

As you can see, we’re running REE (Ruby Enterprise Edition). This complicates matters a little, because you need to ensure you install rmagick in the directory where REE expects it to be.

Here is the series of magic chants needed to get rmagick and imagemagick working together on Ubuntu 10.0.4 with REE (Ruby Enterprise Edition).

$ sudo apt-get install imagemagick
$ dpkg -l | grep imagemagick
ii  imagemagick                       7:6.5.7.8-1ubuntu1                                         image manipulation programs

You can see we picked up imagemagick v6.5.7.8.

Next, verify where your REE binaries are installed, and install rmagick, making sure it ends up in the REE gem directory:

$ which ruby
/opt/ruby-enterprise-1.8.6-20090520/bin/ruby
$ sudo /opt/ruby-enterprise-1.8.6-20090520/bin/gem install rmagick

This step can take a while. Once it completes, check to see that rmagick is bound properly to imagemagick:

$ irb -rubygems -r RMagick
>> puts Magick::Long_versionThis is RMagick 2.13.1 ($Date: 2009/12/20 02:33:33 $) Copyright (C) 2009 by Timothy P. Hunter
Built with ImageMagick 6.5.7-8 2009-11-26 Q16 http://www.imagemagick.org
Built for ruby 1.8.6
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org=> nil

If that works, start the Rails console and try the same thing. You should get the same results, and the fact that console runs is a good indicator your app server will probably run too.

Done!

References:

You know your code is successful when…

Like many Ruby and Rails users, I rely on an open source software named Capistrano to deploy my apps to the web. I did a quick check today to see if I had the latest version of the Capistrano gem, and was shocked and delighted to see a ton of results over and above the core gem I’m using:

$ gem list -r capistrano

capistrano (2.5.19 ruby)
capistrano-boss (0.0.1 ruby)
capistrano-campfire (0.1.1 ruby)
capistrano-cm (0.0.3 ruby)
... [many, many more] ...
capistrano_s3 (0.1.1 ruby)
capistrano_winrm (0.0.1 ruby)
CapistranoTrac (0.5.0 ruby)

There are 43 different results, 42 of which are based on Jamis Buck’s Capistrano. That’s 42 different projects, all based off this single seed.

That’s. Just. Awesome.

Judging solely by the titles I’d guess many of these gems are just small 10- or 20-liners that extend the core Capistrano gem in some narrow way. That’s even more impressive, in my mind. Building something that extensible is hard.

I love “people use and improve stuff I’ve built” as a measure of success.

Follow

Get every new post delivered to your Inbox.

Join 401 other followers

%d bloggers like this: