A very ambitious statement can be seen on the
official website of the project. In the same place it is offered to be convinced of it on
examples . Personally, I find it difficult to judge, I used only Java web frameworks, and that is by no means all. Therefore, I will try to tell about it in more detail, and let everyone make his own conclusions.
The most important thing to note is the absence of the “best of all” statement. And this is understandable, if only because Lift is more complicated than most frameworks. Firstly, because it actively uses the functional side of
Scala , and secondly, because Scala is a language with strong static typing. But, for those who are willing to learn, Lift is a really powerful tool (I know from experience, I have been using it for the past few months).
First, some background information.
Key facts:
- Start of development - 2007, the first version - 2009, the current version - 2.2.
- Already in 2009, Foursquare was completely rewritten from PHP to Scala / Lift, now Foursquare has more than 6 million users and several thousand requests per second.
- Written in Scala, which means it is compatible with all libraries on the JVM, servlet containers, etc. You can simply connect .jar to an existing Java web application, edit web.xml and use.
- Developing the idea, the authors tried to take all the best from the most powerful frameworks of that time - Rails, Django, Wicket, etc.
- Lift templates are valid HTML, they cannot contain code, but are not necessary, you can generate HTML directly from code, especially since Scala has built-in support for XML.
- All logic and settings are implemented exclusively on Scala, without special XML files or other tools.
- Using SBT and JRebel, the development cycle (the time between making code changes and updating in the browser) is reduced to a few seconds.
- Automatically guarantees protection against 6 out of 10 most dangerous vulnerabilities (according to OWASP ). In real systems, this is confirmed , for example, by Rasmus Lerdorf for Foursquare.
As already mentioned, Lift actively uses the functional side of Scala. This is reflected firstly in the fact that you do not need to think about how to send and receive information from the client, how to transform it, what interfaces to implement and how to correctly connect them. Instead, you just write
what to do . The simplest classic example: there is a button that, when clicked, sends a request to the server, some actions should be performed there, after which some response should be sent to the browser. We look at the code.
')
Template:
<button id="b">Push me</button>
Scala code:
"#b [onclick]" #> ajaxInvoke(() => {println("server"); Alert("client")})
We deduce in the console the message and we return javascript for performance on the client. Everything! Minimum code, maximum result. And this approach can be traced in all parts of the framework.
Seven things
from Lift, which are made much more difficult or not implemented at all in other frameworks:
- Delayed loading : you can mark parts of the page that are generated for a long time, Lift will take care that the other parts load immediately and slow parts as soon as they are ready.
- Parallel page generation : you can mark several page sections for parallel generation, new streams will be automatically selected for them.
- Comet and Ajax : the simplest Comet-chat is implemented in 20 lines of code, on the same principle as the example above.
- Linking Ajax Components (Wiring) : My favorite new feature allows you to link (even in a few steps) several Ajax components on a page, and they will be re-drawn if necessary.
- Templates friendly to designers : the latest version has become even more beautiful - instructions for Lift are transmitted via the second attribute
class
. In my project, for example, templates can be opened as regular HTML and they look exactly like the application page, but without dynamics. - Multipage forms (Wizard) : declaratively described forms that support the Back button, which can be launched either multipage or via Ajax. Previously, these forms were a chip JBoss Seam, now in the Lift is even more convenient.
- Security : due to the competent use of static typing and functional programming, Lift guarantees protection against most of the most dangerous vulnerabilities for interactive web applications.
And everything else
In addition to the above features, there is a whole necessary set:
- menu, authorization, your ORM, and easy integration with other ORMs (for example, I use Hibernate out of habit);
- ready empty application, which is convenient to start;
- the latest version has a very cool Dependency Injection with the ability to change dependencies for the duration of the session, request, etc .;
- localization;
- file uploading;
- a set of tools for creating web services;
Etc. etc. To all this, it is important to add the power of the Scala language itself, which, personally, after many years of working with Java, never ceases to please every day.
How to be with all this?
I tried to thoroughly do Lift 3 times over the last year. And somehow he could not grasp the essence, throwing. Even began to make a prototype of the web interface for working on Vaadin. But at the end of 2010, having tried again, I was able to figure it out and now I am terribly happy. I think that the reason for the unsuccessful attempts is mainly to get used to the functional approach. Java habits actually sit deep and interfere with thinking in another perspective.
Therefore,
before seriously taking up the Lift, it is probably worth feeling confident in using the functionality of Scala .
All worthy books on Scala and Lift are either free or not hard to get. For Scala, the best option is
Programming in Scala 2nd edition . I studied Lift mainly by examples from a distribution kit, a
Wiki and a free book from the creator -
Simply Lift . Well-designed questions quickly and efficiently respond either to
StackOverflow or in Google groups on
Scala and
Lift .