Why Lift is My Favorite Web Framework

Lift Web Framework

I’ve worked with various MVC frameworks over my career: Struts, Spring MVC, Django, Rails.  With each of these, I’ve been resigned to splitting HTML pages from designers into templates, messing up the HTML DOM structure to splice in server-side code, and wiring APIs with JavaScript to make Ajax features possible.  That is, until I had my first encounter with Lift.

Switching to Lift was tough initially.  My brain was just too well well wired for traditional MVC.  But in the end, here are a few of the reasons why Lift won me over:

1. Scala.  Lift is based upon Scala, which is our language of choice here at Fliptop.  Scala is a powerful functional language that compiles into JVM byte code.  It gives you all the advantages of JVM reliability and JVM libraries, with (we’ve found) less than a third of the code footprint of straight-up Java.

2. View First.  Lift divides web components into snippets, not lots of pages.  It’s a much more natural way of dividing up the components we interact with on websites.  Instead of artificially mashing together functionally-unrelated controls into a single controller just because they appear on the same page (e.g. a menu system and a messaging system), Lift handles page construction logically and elegantly.

3. CSS Binding.  An HTML DOM element is supposed to be an indivisible unit.  But most frameworks force us to defile the DOM like this:

{% for item in collection{ %}
<input class=”myclass-{{ item.index }}” value=”{{item.value}}” />
{% } %}

Thanks to Scala’s native support for XML, Lift’s css binding feature allows me to navigate the DOM tree, retrieve the DOM objects, and bind designated values into them.  When your designer needs to make changes, she know exactly where to look for the DOM items–exactly where she left them.

4. Native JavaScript/Ajax Support.  As a web engineer, I know and like JavaScript and jQuery.  You can have a lot of fun with it.  But in reality, most of the JavaScript tasks we do are identical, boring and tedious.  Things like API request/response and progress bars.  With Lift’s native JavaScript/jQuery support, you can leave this generic plumbing to the framework, and concentrate on improving user experience.

5. Out-of-the-Box Security.  Let’s admit it – most developers don’t understand security.  Languages and frameworks should at least try their best to prevent developers from shooting themselves in the feet (Sorry, PHP; it’s not just use).  I pleasantly surprised when I discovered Lift automatically scrambles form input names to prevent (most) bots and CSRF.  I know Django and Rails have similar features, but Lift has more.

6. Lazy Loading and Parallel Page Rendering.  When your web pages are based upon snippets, you can really improve the user experience with Lazy Loading and Parallel Page Rendering.  With lazy loading, you are able to start rendering a specific page before all the snippet computations are done. Lift automatically shows a spinner as a placeholder for the outstanding snippet content, and replaces it when the snippet finishes loading. Parallel Page Rendering takes it one step further.  Snippets are able to load and render in parallel in different threads. Parallel Page Rendering can really come in handy when we simultaneously have multiple high-computational snippets that we would like to render, like certain heavy database queries in a CRM system.

At the end of the day, the scarcest resource in a startup is time.  More code = more engineering time = more cost = higher burn rate.  The features of Lift I’ve talked about (and others I haven’t yet, like Comet) help me to do the most amount of work with the least amount of code and complexity.

Give it a try yourself, and let me know if you agree!

Comments

5 comments
Luke Plant
Luke Plant

Links on this page are really annoying - due to the javascript thing you use for links, I can't middle click to open in a new tab.

MatttLloyd
MatttLloyd

Have you tried Play?

I was a die hard Lift user until I tried Play. I can't imagine using anything else these days.

WinstonChen
WinstonChen

@Luke Plant Copy that. We will come up with a better tracking way asap. Thanks for the heads up.

WinstonChen
WinstonChen

@MatttLloyd I have tried it. It works like django for me though. What's your favorite part about play?

Get free email updates