Skip to content

Instantly share code, notes, and snippets.

@sroebuck
Created January 15, 2011 22:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sroebuck/781320 to your computer and use it in GitHub Desktop.
Save sroebuck/781320 to your computer and use it in GitHub Desktop.
Scala Web Framework Review

Scala suited web frameworks

Overview

In general these frameworks provide functionality that covers one or more of the following:

  • Routing: A mechanism for taking HTTP requests and routing them to some code that handles them and returns a response.

  • Templating: One or more syntaxes for templating web pages so that the static and dynamic content can be described in a reasonably simple way and the code can be embedded or in some way associated with the template in order to fill in the blanks.

  • Persistence: A mechanism for storing an retrieving objects from a store.

However, some go well beyond gluing the web components together and provide frameworks which generate their own HTML, JavaScript, etc. on the front end and try to hide the separation between client side code and server side code. For the sake of brevity I will refer to these as Rich Internet Applications (RIA) as GWT and Vaadin both refer to themselves as such and they certainly fit into this category.

A very straightforward and effective overview of web application frameworks can be found on WikiPedia here: Web application framework definition and a list of such frameworks is here but makes no mention of Scala: Web application frameworks

  • Written in Java with Scala specific support.
  • Emphasis on simplicity.
  • Command line tool which auto generates a starter template.
  • Compiles content on the fly without the need for an additional build tool.
  • Uses JPA and Hibernate as the underlying persistence framework.

Pros

  1. Quick to get started.

Cons

  1. Automatic compilation on the fly means that you loose some of the control of using your own standard build tool.
  2. Feels uncomfortably focused on features that make for nice demos!
  3. Built in compilation also does some automatic code generation with Java Beans which means that code might run but not compile with a normal compiler.
  • Written in Java with no specific Scala support.
  • Most of the comments about [Vaadin][] are equally applicable to GWT on which it is based.

Vaadin code looks a bit like Swing code. You are effectively writing an interactive Java application which is then run as a JavaScript application within a web client. From a functional perspective, this feels like taking a traditionally declarative style world of HTML and CSS and turning it into a very imperative style. In short, it feels like a backwards approach to solving the problem of interfacing front end and back end programming.

Pros

  1. Suited to Java programmers who don't want to mess with HTML and JavaScript.
  2. Takes away the responsibility for handing the differences between web clients.

Cons

  1. Takes away your control over fine tuning the front end HTML and CSS.
  2. May appear very unfamiliar to someone not familiar with Java GUI application development.
  3. Liable to produce web applications with heavyweight front end JavaScript.

Scalatra appears to basically be a form of request routing engine framework. It provides a simple way of processing incoming requests and routing them to code which renders the response. Any other functionality can be written yourself or added as an optional plugin.

  • Written in Scala.
  • Inspired by Sinatra.
  • Builds with sbt.
  • Runs on jetty.
  • Has some testing support built in.
  • Has optional support for:
  • Is currently used by:

Pros

  1. It appears to be very clear what this does and how.
  2. It appears to fit in well to any combined Scala project with no excess of DSLs or implicits.

Cons

  1. If you want some comprehensive tool, this isn't one.

Scala templating engine.

Web framework.

  • Written in Scala.
  • Built with sbt (formerly with Maven).
  • Exhibiting many of the characteristics of Rich Internet Applications whilst still giving access to the direct manipulation of HTML, JavaScript, etc. This freedom provides a certain degree of blurriness and tension in understanding what it is trying to do and how you go about doing it.
  • Provides templating, routing, security, persistence framework, indeed everything!

Pros

  1. Can do practically everything you need.
  2. Has a lot of strong security features built in by default.
  3. Has a particular focus on smoothing the coding of AJAX and Comet code.

Cons

  1. Always seems to be adding new features but rarely throws any old ones away.
  2. Documentation is fragmented and not aligned with the updates.
  3. There are lots of ways of doing the same thing so it's hard to use other people's code as a cross reference to check you are doing the right thing.
  • Based on Scalate and Scalatra.
  • Appears to be focused on providing a separation of concerns between a concept of 'resources' and 'views', where 'resources' are the bare bones dynamic content of a web page and 'views' are the rendered representation of them.
@mauriciogracia
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment