First i want to talk a little bit about my Journey with web frameworks, since i’ve used quite a number of them, namely Django, Rails, Tapestry5, Wicket, CakePHP (lol), Play, Merb (my favorite for Ruby) and of course Liftweb.
It all started in 2004 when i first started out doing Web-Development with PHP and MySQL. I mean you could hardly call it development, but i produced an administrative interface for my housing business. Within the first few months i noticed that MySQL was in fact not usable for production, so i quickly became fond of PostgreSQL.
After figuring out, that PHP has some OOP functionality like class/private/protected/public where the last 3 don’t really do anything except look neat in the code, i started looking for real programming languages that took what i coded seriously, not just for style. That’s around the time i switched to Ruby, that was Winter 2006. I know that because i remember bringing my Ruby On Rails Book to our ski-vacation to Kitzbühel, Austria.
But you know how it is, once you change your Language, you’ll still have a few projects lurking in the back of your head which you did in PHP or whatever your old language was, so you gotta code that shit, wether you like it or not. But i was in (good or bad?) luck, my biggest PHP customer went broke, so went his Servers and his Project. That was somewhat in mid-2007.
My biggest Ruby Project
Around Mid-2007 I struck a deal with Quelle GmbH, a large German warehouse store. The deal was to sell the Quelle GmbH goods through my company; Franz Bettag - Innovative Lösungen. This was a pretty heavy duty job, since it involved sending 40.000 Packages annually to people within Germany. Not to mention my employees collecting the products out of our 2000sqm (~21.500sqft) warehouse, bringing them to the desk to be packaged and having my Warehousing system print invoices and packaging-lists.
So how did i manage this? Well i wrote my own Warehousing System in Rails within 3 Months. It fully interoperated with eBay and did everything they asked for with great ease.
From there on until Christmas 2009, i’ve spent a considerable number of hours writing Ruby for different projects. Most of them non-public, some were a leap of faith which did not produce any good outcome for me or my customer, so the only ruby project i can be proud of is my Warehousing, since it was quite enterprise grade. ;)
After writing my Housing-Interface in 3 different languages on 4 different Frameworks, i thought the 5th time would be the charm, and it is.
I remember when i switched to Rails, that i really liked the organization with MVC, it gives you clean space to do your things, Models, Views and Controllers, but one thing was still missing, Performance.
When you have a really large Dataset you need to display, and you want to weed out some of the data, in Ruby frameworks you have three options.
Write your own finder on the Model or the Controller, oooooor you can you do it in the View. I know, i know, you shouldn’t do it in the view, but sometimes you’ve gotta let stuff go for performance. Why?
Imagine this, you have 300 boxes full of Cookies in the back of your store, and you need to restock a whole wall with Chocolate, red sprinkled, weed-laced, etc. Now if you have one employee in the back going through all those boxes and find the broken cookies, and one in the front who takes every cookie, checks the color and puts it on the shelf, you’ve wasted a whole person. Why shouldn’t the guy who stocks the shelves also check if the cookies are fine? He obviously also has to take them one by one and check their color for whatever coloring-scheme the boss wants them to be arranged on the shelf.
This exact same issue is happening with most MVC frameworks, you have your controller or model collecting everything, weeding out, maybe weed out again by some other criteria and then display your data. So what is the difference between Scala Liftweb and Ruby on Rails/Merb?
Scala is fast
Scala is so damn fast, if it were lightning, it would be long gone before anyone knew they were struck.
When i compare stuff like Scala’s .filter or .map to Ruby’s .reject or .collect/.each, i seriously cannot recommend to anyone doing filtering of big datasets in their models or controllers, because it will simply suck the life (and performance) out of your server. If you need to use ruby, do those iterations in the view and “next” if your condition is not met, this has actually sliced the render-times on one particular project in half (5.2s -> 2.4s). What i want to say is, Ruby is fine, but Scala is the bomb!
But why should one write Scala when you could prototype in Ruby, and if it is working for you/your customer/whoever, you can still re-write it if you need it to scale?
That was my initial thought as well, but when you get better with scala, and especially get to know some tweaks and tricks with Liftweb, you can have your Prototype faster and better with Scala than anything else. Even if it is a Prototype, if you spend a few more thoughts on it, it will be ready to simply continue development for the beta or production which will be in fact able to scale. And you should never forget that with Scala, you simply safe so much type-checking code, it’s a breeze compared to everything else.
Liftweb is also fast
Not just in terms of performance, but in terms of development-speed. In my early days, i’ve considered Types to be something people used in the 80s, but the more i encounter bugs related to “oh, it was a string? I thought it was a Float!”, that i got sick and tired of writing tests all day long, so why not save 90% of the tests and write 10% of them simply to check if you functionality is right, not if the returned types are the ones you are looking for.
Lift gives you this really amazing toolset to build web-sites which scale, perform, are secure and use the latest buzzword-technology, as well as save an assload of development-time.
In those past 2 years i’ve tried Scala and Liftweb a couple of times (and of course failed a couple of times), but i somehow caught up on the thought, that web applications do not have to be those loose-code things like they are in Python, Ruby or PHP, and they also don’t need that bureaucratic overhead which Java adds to it, so the Golden middle was clear for me, something where i wouldn’t have to write interfaces, and something which would have Typesafety and scale like hell, therefore i chose Scala and Liftweb.
Well i have to admit, View First sure is an easy concept if you’re coming from PHP, but if you’re used to MVC, that’s really something else. Once you get the hang of it, you will forever be a believer. It just feels sooo right, right like you couldn’t imagine if you haven’t done it.
If you read my twitter, then maybe you’ve heard me writing that before, but Scala and especially Liftweb is an eyeopener and a revelation.
The way you can write concise code which compiles and you can be sure, your float will be a float, unless you’ve opened a Box which wasn’t full, but hey, that’s just gonna happen once or twice before you start writing fault-tolerant code which can handle it. ;)
So if you have some spare time, make sure to check out Scala and Liftweb, i hope it will be a journey and improvement of your work as it was to me.