Why Lift is My Favorite Web Framework
blog.fliptop.comThis is OT, but you really should track clicks on links (if you need to do it in the first place) in a different way than this:
<a href="javascript:mixpanel_track_link('http://liftweb.com/','link:liftweb.com');">my first encounter with Lift</a>Came here to say the same. At least they should detect a scroll wheel click and open the link in a new tab.
Or they could use the google approach and change the link in the last moment to point to a tracking service.
One more with the same problem. Right click open in a new window, and then 3 tabs with about:blank.
That is also because using lift?
No, Lift does NOT do this. The site appears to be running on WordPress (guessing based on the 'wp-content' in the paths for assets).
I confess to having a bit of a crush on Lift so I was happy to see something about it on the front page, but this article is a little vague, so most people will probably remember the intrusive click tracking over anything else.
No, that s probably because
<!-- This site is optimized with the Yoast WordPress SEO plugin v1.4.1 - http://yoast.com/wordpress/seo/ -->Interesting. Safari won't even give me the option to open it in a new tab, since it's obviously not a web link.
Just obnoxious.
Nope. This is a wordpress blog.
It's easy to do this with a jquery post - just bind to the click event, and post the tracking data to whatever URL you want as a separate async action, without getting in the way of the user.
You should never put js in the href like this, or insert extra referral links prior to going to the real link as google have been doing recently; it breaks the web.
What I hate in these company blogs - there seems to be no way to go to the actual company site... I always end up editing the address bar and removing "blog." prefix by hand...
Many of the same advantages (and some additional ones, no doubt) hold for the Haskell web frameworks, with the added benefit of using Haskell.
I'm in no position to say whether Yesod or Lift is better; I just wish more people would consider Haskell at all--it's a great choice for web programming (among many other things).
Many of the same advantages hold for any other language's frameworks, with the added benefit of using any other language.
Yesod is great, especially its quasi quoters, such as Hamlet.
However, two things that I constantly bumped into maintaining a small Yesod app is that there was a fairly constant stream of API changes and that deployment on different machines was annoying because of version conflicts installing packages.
If you use Yesod, you are probably best off using a Cabal sandbox (e.g. via cabal-dev) and making specific package versions dependencies. Of course, that may be questionable from a security perspective.
I ended up rewriting that particular web app to Play, which offers some of the same benefits, but was a lot easier to deploy. You can create a stand-alone version of an application with play dist, which includes all the required jars, and the only thing required on a server is the Java runtime environment. Also, Maven/sbt seems a lot more mature than Cabal. As an added advantage, you can use tried and tested Java or can go all-functional via Scala.
Concerning the cabal dependencies problem. I didn't tested it yet, but I believe a sane solution should be to use stackage[1].
I know fpcomplete use stackage for their School of Haskell[2]. This way, there is never any package dependency problem. Which gives them the incredible ability to execute yesod application directly on their server from the code of an user changing the code in the browser. If you haven't did it yet, you should really try it.
Also, concerning the deployment, having a single statically linked binary is very similar to having a single jar file. And this is very easy to deploy using heroku for example.
You can ask me more detail if you want to know how I deploy my application but this is mostly very well documented in the wiki.
[1]: https://github.com/fpco/stackage [2]: https://www.fpcomplete.com/school
Well, for very relative values of "all-functional".
But yeah, Cabal is certainly a bit of a pain. Happily, people are working on it. Superior cabal-dev functionality is going to be integrated into cabal proper very soon, if it hasn't already, for example.
Also, couldn't you just compile your binary with static linking and just deploy that? I understand there can be problems if you depend on certain non-Haskell libraries like GUI toolkits, but that shouldn't be an issue for a web app. I think a statically linked binary is pretty similar to a jar file in practice.
Not everyone develops on the same platform as an application is deployed.
The sever side statefulness of Lift, the fact that it supposes I don't know how to program HTML/JavaScript, and the hostility toward Scala that Lift's creator harbors since negotiations with him joining Typesafe broke down, are all reasons I think it would behoove anyone to avoid the framework. Play, unfiltered, scalatra, and blue eyes are all fantastic
> The sever side statefulness of Lift
Having been using lift professionally for the last year or so, this is definitely my biggest complaint. I feel like Lift got it wrong here -- the *Var model is just hard to reason about. Our app has a lot of complicated logic to save and restore state at the appropriate times, and this model is supposedly the Right Way to do things.
> the fact that it supposes I don't know how to program HTML/JavaScript
Not sure why you say that; I've never gotten this feeling.
> the hostility toward Scala that Lift's creator harbors
Lift has 50 committers now. It's not going anywhere. If dickead maintainers were a real problem, nobody would be using glibc anymore. (I don't have any thoughts on whether DPP is a dickhead; I do think Drepper is, though :-)
One thing you didn't mention is the whole CssSel model combined with the way lift does templating. I think it's awesome, and hopefully I'll never have to work with another style of templating again in my life. (In fact, I wrote an implementation of it in haskell for my personal static site generator, because I love it so much: http://hackage.haskell.org/package/hquery </shamelessplug>).
Can you elaborate a little more on the server-side statefulness of Lift and the issues you encountered?
I was reticent about statefulness on the server-side, until I read an article about statefulness in Lift[1], which does mention how having session affinity helps with it.
Mostly, my questions are: does it scale and how do you handle state loss (due to servers catching on fire or other hardware/software failures)?
State loss is something I've been doing a great deal of thinking about. Right now a page reload is necessary, and I've written code in the past to essentially store any modified fields before running the page reload and restore them when the reload completes.
However, I'm still working through the conceptual aspects of restoring a page without a reload, over AJAX, provided I can figure out a good way to do it without compromising Lift's basic built-in XSS resistance.
I don't know much about how Lift works, but would doing something akin to PJAX[1] (reloading the entire page via AJAX) work in your case?
With regards to state loss, the only way I can see it working is if you save everything to a system of reference, just like you'd do in Play. Unfortunately, that's also a major pain in the ass, as we've found out, especially in the case of multi-step forms in Play.
But we have a system of reference in Lift—CSS selector transforms refer to an element by its location in the DOM, rather than by a given name. I think there's room there for a creative solution.
David doesn't seem to harbor any particular hostility towards Scala. As far as I can tell, he has serious qualms with certain aspects of the way that EPFL and now Typesafe run and have run the Scala community, and have managed the evolution of the language itself, but he loves the language nonetheless. Thus why he has sunk a great deal of time into the Lift community, into keeping it alive, into speaking about it, is currently sinking still more time into the next phases in Lift (Lift 3) and how to push the foundations that Lift 2 laid down even further with that, and why as far as I know it is still his language of choice for many projects, including telegram and Visi.
You state "the server side statefulness of Lift" as a reason it would behoove people to avoid Lift, without bothering to explain why that is a reason to avoid Lift (it isn't--see http://lift.la/blog/lift-state-and-scaling). You state the language "supposes [you] don't know how to program HTML/JS" again without explaining how that is the case (it isn't--I am very good at both, and have never felt as much freedom to use those skills unfettered by server side concerns as I have with Lift; that's anecdotal, but if you make some specific complaints, I'll be glad to address them). And last but not least, you argue that David is hostile towards Scala without providing a single shred of evidence to support your statement.
In the future, it would behoove you to provide evidence for your claims.
Regardless of the technical qualities of Lift, its future is pretty uncertain with 1) dpp leaving the project (in pretty bad terms) a few months ago and 2) Typesafe choosing Play over Lift for its stack.
I would definitely not pick Lift today for a new project.
dpp did not leave lift. true he has other projects and focuses on more than just lift, but he is still heavily involved in it.
as to why typesafe chose play over lift: they wanted to go with lift but dpp didn't want to work with them - didnt think it a wise decision. his explanation: http://www.quora.com/Lift-web-framework/Why-did-Typesafe-sel...
>dpp did not leave lift. true he has other projects and focuses on more than just lift, but he is still heavily involved in it.
Well, this doesn't sound a lot better than him leaving the project.
With a team of committers that are contributing consistently to the project, as well as David continuing to contribute regularly, I have no idea how you can get by saying this. Releases have continued apace, and work on Lift 3 has begun. What exactly is it that you think would be bad were dpp to leave the project altogether that you see happening right now?
This was a very interesting read, especially the part about the internal workings of Typesafe (a bit concerning too).
nice to learn this. thanks
Apologies if this is nit-picky, but...
Some of the main points are weak and don't really apply to differentiating Lift specifically. For example, the fact that Lift is Scala-based doesn't make it any different than Symfony is PHP-based or Spring MVC is Java-based. Subjective, but I definitely understand that that this is an opinionated view (rather than a objective "Lift has Feature X" viewpoint).
Similarly, what server-side framework that's in wide usage nowadays doesn't have the ability to have some form of generated/dynamic JS wiring? I'd say that's table stakes nowadays, not something to callout by any means.
Lift's JS & jQuery code generation is nightmare-inducing, it's ridiculous to call it a "benefit". JavaScript should not be auto-generated by some flavour-of-the-week web framework in a totally different language. You're just creating a whole world of pain for future-you.
I respectfully disagree. I was able to finish an ajax form, including value validation with only a snippet and it's binded scala function. I did not have to create a specific rest API and write up jquery ajax code along with the snippet. Lift's JS & Jquery support was never meant to replace js and jquery. (don't write up every js feature with lift.) It's meant to eliminate tedious js works that both frontend and backend developers don't want to spend time on.
I think calling it nightmare-inducing is going too far, but there's nothing that forces you to use it. I think it's fantastic for prototyping, because it lets you focus on getting things done in one place. If you're not prototyping, I think you should keep your JS in JS and come up with a common interface to interact with your JS from the server—I've chosen events dispatched on the document element in a variety of situations as that communication protocol.
I tried to like Lift, but it's so woefully documented that I can't. At the moment I've gone back to Wicket (which is fantastic on many of these, particularly building a page out of component objects rather than bunging lots of stuff in a page controller, and has an even better way of doing bindings than lift does), even though it doesn't fit perfectly with Scala.
documentation is getting better and better these days, although i cannot argue documentation part.
I've had very similar feelings using enlive in Clojure land. I doubt I'll be switching back to a more traditional templating engine any time soon.
I'm very happy with Hiccup, I think both paradigms are better than the more common ERB style templating. Either pure Clojure (or whateverlanguage) or pure HTML rather than a mix.
I wish Clojure had a batteries included framework like this just to draw more attention to the language.
Have you had a look at Luminus[1]?
Yeah, thought of Enlive when I read this. I wish this style of templating could get imported into Rails.
I agree. View first rocks!
After some years of living with Lift: Liftweb is awful. Don't use it.
There is not enough documentation (by a large margin, even with the books, one example being the dozens of hooks you could hook into if they were documented), it's too complicated and there are a millions ways to do one thing.
That said the rendering and binding is the best way to do rendering I've seen yet. I'd wish this was easily usable with other frameworks. And Rogue (from foursquare) for Mongo on top of Liftweb persistence mapping is excellent. My understanding they will support things outside Lift in the future.
I am amazed people even see Lift as in the same balpark as Play. When I last used lift It appeared to be a relic of the J2EE stack ported to a new language. This goes beyond any technical capabilities of the framework and down to how it expects you to work in it. Even the author says that just getting started can be a pain, doesn't that tell you something about your framework. It its hard to understand what to do its hard for people in the future to understand what you did. So who cares if you can make pages with just a few "snippets" no one else can figure out what you did.
Well, we cannot assume that people cannot learn. Snippets are smaller piece of codes compared to controllers, and logically making more sense. All you have to do is to train people. Isn't it the way people learn MVC too?
I might get downvoted for this..but I'll risk it, because it is a message that needs to be passed. My experience on using Lift. A few months ago, I was evaluating various frameworks to start off with my new web app. I am already running a dozen RoR apps and gradually I'm moving away from RoR. I will explain as to why, later in my post.
I was evaluating between Play and Lift and I ended up choosing....Lift. Lift has an extremely high barrier to entry mainly because of the poor documentation. When I first started off with scala, I didn't even know what the hell was SBT, when I downloaded Lift, there were a lot of things that were confusing - I was expecting perfectly organized folders just like ruby on rails, but everything was almost hidden/scattered. However this was the only barrier to starting up with Lift. I also did read about the controversies about the framework, etc [1]. of Lift, but honestly, none of them actually mattered to the developer, that is me. Now that I've chosen Lift, I think I made the right choice. Now, WHY is Lift better?
1) It's a 3+ year old Framework that is extremely stead-fast and stable, production-ready.
2) Scalability - This is a subjective view, but many high profile companies switch to Scala from Ruby/PHP/etc. when they need to scale. And Lift is a really good framework that gets the job done. [2][3]
3) Contrary to popular belief, once you cross the barrier to entry, it becomes much much easier to develop Web apps with Lift. Remember those wordpress days? How scary it was in the beginning to write custom themes and plugins?? But once you started writing a few, it felt like a breeze, right? That's what I'm talking about - That's exactly how Lift is too! [4]
4) Security - Security is hard. Sure you can write your Web app without using a framework. But if you use RoR, you will realize how much work is being done on behalf of you to make your app secure (Authenticity token, CSRF protection ,etc.) Lift is no different and it is one of the most securest frameworks I've ever worked with.[5] This is a very good guide explaining why you need to choose Lift over anything else.[6]
5) RoR vs Scala - Now, Imagine this scenario - You are a sculptor (web developer). You have two materials to choose from to create a statue (your web app). One is ordinary clay (Ruby on Rails) and the other one is a Metal, preferably some alloy made of copper and bronze (Lift). It is extremely easy to model your Statue (your web app) in Clay. And once you're done modeling, you can add some chemicals, or even thin layers of metal on top of it, etc. to make it strong (Think Unicorn, Phusion, etc). But, no matter what you do, the core is still made of clay and if you throw it down, your clay model will shatter into pieces.
Now compare it with the Bronze alloy (Lift). It is extremely hard to make a statue with it, but once you make statue with it, it's going to be so hard and robust, it can handle pressure (load) well - Even if you drop it, it might deform slightly, but never break. But, the disadvantage is that it takes too long to model a statue with this metal. However, you should decide if the trade-off in time is worth the effort in the long run. Of course everyone wants a nice status that is robust!
In the real world, you will probably be ok with RoR, but when you need to scale, you will realize the potential benefits you are missing out soon[7] - For example, if RoR can handle X requests/sec, and Lift can handle 10x requests per second, and assuming X requests require an Amazon box, then you save 9 boxes with Lift. That is huge savings for your start up, isn't it? I always wonder why people try so hard to scale RoR. It's a great framework, but the wiser thing to do would be to use something more efficient when you need to , than holding onto something that is less efficient because you like it. Also RoR has its own confusing terminologies (personal opinion). For example:
render json: @post
render :json => {:errors}
Notice the colons before and after the word 'json'.If you are interested in Scala, Coursera has a course on Learning Scala by Martin Odersky (The creator of Scala) and it is really good. Scala is not a purely functional programming language, which means if you are accustomed to programming in Ruby style, you can take it with you to Scala too.
[1]http://www.quora.com/Lift-web-framework/Why-did-Typesafe-sel...
[2]http://img.scoop.it/FP9bEzouSr7kRinQRAtGmDl72eJkfbmt4t8yenIm...
[3]http://www.quora.com/Why-did-foursquare-choose-Lift
[4]http://stackoverflow.com/questions/2573608/what-type-of-weba...
[5]http://seventhings.liftweb.net/security
Awesome response.