Wednesday, August 8, 2012

SLICK - Scala Language-Integrated Connection Kit

By Vasudev Ram


SLICK is an acronym for Scala Language-Integrated Connection Kit. It is from Typesafe, the company that provides commercial support and training for Scala, Akka, etc.

Excerpt:

[ Slick is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can write your database queries in Scala instead of SQL, thus profiting from the static checking, compile-time safety and compositionality of Scala. Slick features an extensible query compiler which can generate code for different backends. ]

I took a look at the example on the SLICK page, and interestingly, it was easy to understand, though I don't really know Scala. But that example (*) was just the SLICK equivalent of an SQL INSERT followed by a SELECT. More complex queries may or not be as readable. But the idea of writing the database query and update logic in the programming language used for the rest for the application, instead of in SQL, is interesting. I had worked on a database middleware product earlier, which allowed something of the same kind, though with a completely different design and for a different language and platform (the product was implemented in C and ODBC on Windows, but the library (a DLL) was callable from both Visual Basic and C; in fact, it was mainly meant to be used from VB).

(*) That example was from a SLICK usage mode called Lifted Embedding. It also has two other modes, Direct Embedding and Plain SQL, the last of which looks more or less like traditional embedded SQL such as Pro*C (Oracle), ESQL/C (Informix), JDBC (Java), etc. Examples of all three modes are on the SLICK web site.


- Vasudev Ram - Dancing Bison Enterprises

No comments: