2011/Scala+Lift Quick Start

From IndieWeb
(Redirected from Scala/Lift Quick Start)
Jump to: navigation, search

Session Notes

Why Scala and Lift?

  • Scala:Lift :: Ruby:Rails but offers better scalability, security, stability
  • Scala has the conciseness of a dynamic language and the type safety of a static language
  • Scala is like a Java++, but runtime (JVM) compatibility, not source back compatibility as C++ and C
  • Scala enables functional programming, but doesn't force it on you - use any Java libraries.

PHP hosting is ubiquitous but few hosts offer JVM out of the box. Fortunately it is easy to install Lift (including Scala, Jetty, JVM) on Unix/Linux/Mac OS.

Quick start procedure:

  • Install maven2 (or 3) with your OS's package manager. You don't have to install Jetty, Scala, or even JVM! Maven will pull in all of those as needed to run the app.
  • git clone a sample Lift app such as lift_24_sbt
  • cd lift_24_sbt
  • cd scala_29 # this project has subprojects per Scala version
  • cd lift_basic # this sample app includes database and login
  • ./sbt update # simple build tool: fetch dependencies
  • ./sbt ~jetty-run # compile then launch web app
  • View http://localhost:8080 in a browser and see the running web app.

The ~ before jetty-run tells sbt to monitor changes in source files and reload on any change. However the ~ currently seems necessary to run lift_24_sbt app; without it, it just exits after startup.