Awesome Scala | ASSIST Software Romania
get in touch
>

LIKE

SHARE

Facebook Share Tweet LinkedIn Share

FOLLOW

LinkedIn Follow Xing Follow

Intro

In this article I am going to present some of the most useful Scala libraries and frameworks which help ASSIST Software engineers to develop highly scalable applications that support concurrency and non-blocking.

What is and why Scala

Scala is a programming language for the Java Virtual Machine (JVM) that integrates features of both object-oriented and functional programming. Scala provides a best-of-all-worlds experience for developers, it’s compatible with classic Java libraries and it’s designed to express common programming patterns in a concise and elegant way. But most important: Scala provides a type-safe language with powerful concurrency on top of a mature ecosystem.

Scala Programming language

Web Frameworks

There are lots of Scala frameworks which you can use to develop web applications quickly and easily, but I will present the ones which are mostly used:

Play

Play is the official Scala framework supported by Typesafe Inc., creator of the Scala programming language. Play is a modern web framework which combines productivity and performance making it easy to build scalable applications. This framework is ideal for developers who are more familiar with the MVC architecture.

Spray

Spray is not a framework, it's a suite of lightweight and very fast Scala libraries designed to build RESTful web services on top of Akka. With Spray you can develop standalone service based on spray-can module which provides a low-level, low-overhead and high-performance HTTP server and client. You can also develop a web service which runs inside a Jetty server.

Using Spray together with a JavaScript framework like AngularJS, jQuery, Backbone or many others, you can approach the new trend of the web applications by moving the business logic from the server into the client side.

Lift

Lift is another popular, secure and powerful full stack web framework for scala. Lift is based on a View First approach as opposed to the typical MVC architecture, that means it divides web components into snippets, not in pages. The big plus of this framework is the native JavaScript/Ajax support, which offers an easy way to develop complex interactive web pages.

Other great scala web frameworks

Scalatra

Scalatra is an easy to understand micro-framework and a great option if you want to build lightweight and simple applications. Scalatra is inspired by Sinatra which is a Ruby framework.

Finatra

Finatra is another async web framework inspired by Sinatra, but this one runs on top of Finagle, a RPC System created by Twitter.

BlueEyes

BlueEyes is a purely asynchronous, extremely high-performance framework, intended only to create RESTful web services.

Database

In this section I will present a few scala libraries that allow you to access SQL databases like MySQL or PostgreSQL, but also NoSQL databases like MongoDB.

Slick

Slick is an easy, scalable, concise, safe, compositional and mature database query and access library for Scala. Slick tries to make queries use the same for comprehension as Scala collections do. It’s supported by Typesafe Inc. and can be used only on the following databases systems: H2, MySQL, PostgreSQL, SQLite, Derby/JavaDB, Microsoft Access, HSQLDB/HyperSQL.

Slick is to Hibernate and JDBC, what Scala is to Java and Groovy.

Squeryl

Squeryl is an ORM which is completely type-safe and the queries are written in a DSL that is close to SQL. This library allows you to explicitly control the granularity of data objects that are retrieved while it provides an elegant solution to the N+1 queries problem.

Squeryl is more like Hibernate.

Activate

Activate is a great scala framework to persist objects in different paradigms such as relational, prevalence and non-relational. It’s designed to be simple and uses Software Transactional Memory, which is a concurrency control mechanism to handle with transactions in-memory, without needing to use transactional control from the storage.

Activate is the best choice for applications with concurrent bank transactions.

Salat

Salat is an ORM for MongoDB which provides fast, simple, bidirectional serialization between Scala Case Classes and DBObject. Salat is based in Casbah, the official MongoDB driver and because of that Salat has the following restrictions:

  • can’t support nested inner classes
  • doesn’t use a class type at the top-level to a trait or an abstract superclass
  • any type of Map must have String key only which do not contain “.”or “$”

Salat is the most used MongoDB persistent library.

ReactiveMongo

ReactiveMongo is an asynchronous, non-blocking Scala driver for MongoDB. In a classic synchronous driver like Casbah, each operation blocks the current thread until a response is received and that can be a problem if you have an application with multiple concurrent accesses to the database.

ReactiveMongo is young, but mature enough to be used in production.

JSON Manipulation

Spray-json

Spray-json is a lightweight, clean and efficient JSON implementation in Scala and is based on the parboiled parsing library. Considering the deserialization time, spray-json is nor the fastest library, neither the slowest. Another negative aspect is the limit to parsing json data with more than 22 fields. This limit is because spray-json is based on Tuples, where the maxim type is Tuple22. However spray-json is a very used library because it offers an easy way to manipulate entities from/to JSON.

Jackson-module-scala

Jackson-module-scala is the fastest JSON parser and is the official Scala support module for Jackson (Java library). You can also use the java library in your scala project and will obtain the same performance, but by using jackson-module-scala you will have support to serialization and deserialization of scala Case Classes, Sequences, Maps, Tuples, Options and Enumerations.

Json4s

Json4s is a very promising project where the aim is to provide a single AST to be used by other Scala JSON libraries. Json4s has an extremely rich functional API and supports multiple backends like Lift JSON or Jackson and has native support from Spray and Scalatra.

Testing

Specs2

Specs2 is an open source library based on specifications. Specs2 supports unit testing for one class (unit specifications) and acceptance testing for the full-system (acceptance specifications). The specs2 tests are asynchronous and each runs in its thread using a Promise, that’s why it works well with Akka.

ScalaTest

ScalaTest is another great testing library which can be used to do unit tests, functional tests, performance test. ScalaTest offers deep integration with tools like JUnit, Mockito, ScalaCheck, Selenium, ScalaCheck and supports TDD (Test Driven Development), BDD (Behavior Driven Development) and acceptance testing.

Scalastyle

Scalastyle is a scala style checker which examines your code and indicates where you are not respected the grammar or the functional programming principles in Scala. It can be integrated with Intellij or Eclipse, but also it can be used with SBT, Maven, Gradle.

Metrics and Monitoring

Kamon

Kamon is a set of tools that help you to get metrics from your applications built with Spray, Akka or Play. Kamon offers support to be integrated with other backend services like StatsD and Graphite which are free but it can also be integrated with New Relic.

Do you want to get in touch with us? 

If you are interested in our software development services, you would like to join our team, or you simply want to find out more about us, we’d love to hear from you! Drop us a line and a member of the ASSIST team will get back to you as soon as possible. We are sure we can ASSIST you.

GET IN TOUCH