I am glad to announce the first release of the Scala Pages (SCP) lightweight web framework, which I wrote for a personal web application project. Although it’s still at a humble stage of development, I believe it is useful enough to be shared. I am planning to extend it in future and I hope that it will contribute to increased diversity in the Scala web development area. Software and manual can be downloaded from this page:
http://www.thomasknierim.com/scala-pages-web-framework/
The source code is included in the distribution zip file. Comments, suggestions, and constructive criticism are always welcome.
Addendum: I was asked to make a brief comparison to the Lift framework, so here’s my answer:
The approach that SCP takes is different. To put it in a nutshell, Lift is Rails-inspired, XML-oriented, and it abstracts from the Servlet API and the request/response model. SCP is inspired by traditional Java MVC frameworks; it is text-oriented, and it builds directly on the request/response model and the Servlet API.
Lift processes templates using the SAX-parser and presents Scala XML data structures to the programmer. By contrast, SCP reads templates as plain text from top to bottom, performs variable replacement and executes embedded instructions. Template processing with SCP thus consumes fewer resources. Lift uses prefixed XML tags; SCP uses processing instructions.
Lift wraps much of the Servlet API and presents a number of abstracted objects to the programmer, such as the S object, the SHtml object, LiftRules, and so on. SCP doesn’t do that. With SCP you get the familiar JEE objects such as HttpServletRequest, ServletContext, etc. and you use these directly from the Scala code. So, it’s easy to use if you’ve done Java web development.
The consequence is that you deal with the request/response model directly, which I personally prefer, because it keeps the control flow simple and clear. The only disadvantage of the MVC request/response model is that controllers tend to become bulky and difficult to reuse. The SCP solution to this problem is the same that Lift offers: snippets.
In SCP, snippets are processing instructions powered by a custom Scala class that the programmer provides. This means you can encapsulate application logic and/or complicated display logic into a snippet class which -if properly coded- is perfectly reusable. SCP also keeps template expressions very simple, because the more complex a template language becomes (many are even Turing-complete), the more likely it is for application logic to sneak into the view. Currently, iteration is the only supported type of control-flow.
Last but not least, Lift is huge compared to SCP. It has a lot of functionality that SCP does not offer, at least not at this time.
RSS Feed



















