A bare bones Scala web framework?
Asked Answered
B

7

5

Is there a bare-bones Scala web framework? I basically need the essential features such as:

  • Routing.
  • GET/POST/PUT parameter handling.
  • A simple templating engine (content substitution based).
  • Serialization (JSON, YAML)

I don't like Lift as it does too much for me, as I would like complete control over the generated HTML, meaning that I want to be able to write 100% of the HTML/CSS/JS code.

Is there such a framework? Or is it possible to use Lift in a way that no HTML is generated behind the scenes? Or would I be better of writing a normal servlet?

Babbling answered 13/8, 2011 at 16:38 Comment(0)
T
7

Perhaps you'd like something like Scalatra or Unfiltered? On a separate note, you need not give up any control of your HTML/CSS/JS in a Lift app if you don't want to.

Thymol answered 13/8, 2011 at 16:49 Comment(2)
Thanks @ethan-jewett for correcting my illiterate blabber! ;-)Thymol
+1 for Lift. It can do a lot for you but it doesn't have toMelanochroi
I
2

You can just use Lift to generate services, such as REST ones, is that more or less what you are looking for? http://www.assembla.com/spaces/liftweb/wiki/REST_Web_Services

If we take a look at What Scala web-frameworks are available? none of them have a great simple templating engine, at least to me it seems that way. SweetScala seems the closest though http://code.google.com/p/sweetscala/wiki/GettingStarted

Iapetus answered 13/8, 2011 at 16:48 Comment(0)
H
2

Peter gave a great answer... I'll expand on it a little.

Lift gives you a ton of control and access to raw HTTP requests as well as providing a ton of abstractions on top of the HTTP level. It's your choice on how much or how little you want Lift to do.

You can built a REST-based application using Lift's RestHelper. See http://simply.liftweb.net/index-Chapter-5.html The advantage that Lift's RestHelper gives you over most MVC/Routing based approaches is type-safety and access control at the very edge of your application. But using Scala's pattern matching extractors, you can insure that parameters delivered to the business logic of your application have already been materialized and checked for access control. Further, Lift's REST support will be as concise or more concise than other web frameworks.

In terms of Lift's HTML handling, you have a ton of control over the creation of the HTML, as long as you want to generate HTML as a valid DOM rather than as a series of Strings.

Most web frameworks force you to emit Strings when you're composing HTML. It's up to the developer to properly HTML-escape Strings. It's up to the developer to make sure that closing tags line up correctly. With Lift, you get this kind of thing for free.

You can serve HTML from Lift apps in MVC style. See https://github.com/dpp/hoisted (this is the code that powers http://liftweb.net)

In the "standard" configuration of Lift apps, Lift does some post-processing of the HTML if, and only if, you use certain construct. So, if you put a <head> tag in the body, the HTML page, Lift will take the contents of that <head> tag and move it to the head section of the page. If you include calls to Lift's Comet support, Lift will insert JavaScript on the page to do long polling. But these features are optional and they only happen if you use certain features in Lift.

I hope this helps you understand the benefits of using Lift.

Hustings answered 18/8, 2011 at 0:16 Comment(0)
L
1

Two more frameworks for you to consider:

  • Play is a simple REST framework that is gaining in popularity, and has a nice Scala interface. Its templates translate relatively simply into Scala functions. As of a couple months ago there were difficulties with using JSON packages (like lift-json) that unpack data into case classes because Play has a custom classloader for rapid development. Not sure if this issue is resolved. The Scala company Typesafe uses Play for their site. Play integrates with Akka, and one of the Akka lead developers, Viktor Klang, recommended Play a while back.

  • A little further off the beaten track, there is Spray. I can't speak to the details, but the Wiki looks intriguing. To my eyes, Spray looks to be elegantly designed around Akka integration. I don't think it comes with a templating engine, but it would probably be possible to interface with Scalate (see the mailing list discussion).

Levenson answered 13/8, 2011 at 17:13 Comment(2)
I wouldn't call Play "bare-bones", it is hundreds of megabytes.Ostensible
I wouldn’t call it simple either. It’s very complex.Bullhorn
E
0

Not a Scala framework per-se, but I've had good luck with Jetty+JAX-RS+Scala+Freemarker. These are all pretty heavily battle-tested technologies, and there's no problems with Scala integration. A small shim is necessary to adapt Freemarker to understand Scala collections and properties, but nothing challenging.

Evangelical answered 13/8, 2011 at 17:9 Comment(0)
N
0

Scalatra is pretty bare bones with the scala goodness. Easy to configure, easy to handle Bare HTTP stuff. It is similar to sinatra of scala. Scalatra also has good Maven support and coexists well with traditional java servlets.

Normie answered 13/8, 2011 at 18:23 Comment(0)
U
0

The modern Scala web framework are: Play (on Akka HTTP), Scalatra (Akka Actors) and Finatra. https://www.reddit.com/r/scala/comments/743zjv/web_framework/

Understudy answered 27/3, 2018 at 20:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.