Choosing a Scala web framework [closed]
Asked Answered
B

2

39

I am about to start a project for a web application that should run on a Tomcat server. I have decided to go for Scala - the other alternative where I work being Groovy - essentially for type safety. I am now faced with the task of choosing the right tools for the job.

The project I will need to develop will be accessed only through a JSON API. It will interact both with its own database and with two external services, which expose respectively a JSON and XML API. I will also need to be able to schedule periodic jobs where my application will execute various synchronization tasks with these external services.

For the database, I would like to be able to define my models in Scala and automatically generate the schema. If the need arises to change my models, I would like to have migrations to handle it.

For this application, I am trying to evaluate Lift, Play! 2 and Scalatra.

  • Lift was my first choice. It is the most mature of the three projects, and seems to be considered highly secure (I do not want to compromise on security). Moreover it features what seems to be the best JSON handling library in Scala. Still, after dabbling a bit with it, I am not sure this would be the right choice. The documentation is not exactly the best I have seen. Moreover, Record + Squeryl seems to me a better abstraction than Mapper, but documentation for this use is even more scarce. Finally, although Lift can certainly be used to create a web service, it seems that its real strength lies in the state handling, and so I am not convinced that the additional complexity is needed for my project.

  • Play! 2 seems to have a better documentation, and looks more familiar to me (I come from a Django background). Again, its default database abstraction does not really appease me: ANORM relies on SQL, which does not help with type checking. I would have to use Squeryl anyway, and I am not sure whether the documentation for this use case is as good. Moreover, deploying Play! 2 applications is at the moment moer complicated than I'd like. One has to install Play! on the production server, and I am not sure this is an option where I work. Otherwise, there is a plugin to to make it work with servlets containers, but it is very new and I am not sure how stable/reliable it is.

  • Finally there is the option of using Scalatra. Scalatra seems very easy to set up, and it is designed exactly to create web services. The compromise is that Scalatra does not offer much functionality. It does not integrate with existing ORMs or suggest how to organize the model part of the application, and it does not help in designing cron or command line tasks. I am also not sure about the long term future of the project.

What do you think would be the best choice for my task?

Braley answered 1/8, 2012 at 9:22 Comment(4)
Please, explain the vote to close with a comment, so that I can improve my question.Braley
I will try to guess: this is because questions like this (here is X,Y,Z -- what is the best?) without hard parameters are tends to give opionated and subjective answers. AFAIK, all of the frameworks you have listed fits to talks in JSON, auto schema for database. Or maybe there is some other reason.Earmuff
Well, I thought I gave some parameters: good documentation, only need web service interface, needs to be able to schedule tasks, needs to be able to be deployed reliably on Tomcat, handles schema migrations.Braley
It is a little annoying having the question closed without any comment whatsoever about how to improve it, and more so during the SUmmer of Love :-/ blog.stackoverflow.com/2012/07/kicking-off-the-summer-of-loveBraley
S
25

If you are coming from a MVC background then Play will feel the most familiar. Lift is not MVC and it takes some time to wrap your head around it.

There is no reason that you can't use Scala with a Java-based framework like Jersey, Spring MVC, Dropwizard, Restlet, RESTEasy, etc. Or you could use Scala with Grails just like you can use Java with Grails. Note - Groovy has type safety starting with version 2.0 so that's something to consider.

If you are thinking about Scalatra then don't forget Spray, Unfiltered, BlueEyes...

Be sure to check out Matt Raible's comprehensive comparison of web frameworks. And these other SO questions: Scala framework for a Rest API Server?, How to implement a REST Web Service using Akka?

Singular answered 1/8, 2012 at 12:30 Comment(0)
B
10

Although you already gave some candidates I recommend to you this talk by Tim Perrett (author of Lift in Action, in which he compares scala webframeworks : http://skillsmatter.com/podcast/scala/scalable-language-web

Bastogne answered 1/8, 2012 at 9:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.