3 ms·
The 'slick' library for scala ticks a lot of these boxes. It allows you to write type-safe, idiomatic scala code to query your database, transform results into
by s_kilk 12y ago
The 'slick' library for scala ticks a lot of these boxes.
It allows you to write type-safe, idiomatic scala code to query your database, transform results into proper objects while avoiding the weight of an ORM.
- hibikir 12y agoI disagree. It sure gives you all of those things, but it is still a heavy ORM, that requires a whole lot of slick specific magic do simple things. You can let it own your table definitions, which is a bad idea if you ever want to update it in place, you can spend a lot of time writing the definitions by hand, or you can use their code generator, which writes code that is very verbose, full of useless comments and hard to read. For a large org, Slick also adds to the already significant Scala learning curve for Java devs. Scala itself is good and pretty, but when the first task you give someone new is to write a CRUD-like rest service using slick on one end, and spray on the other, they don't get to spend any time learning actual scala, and instead domain specific languages that are hard to reason about without serious Scala experience. No, this is not speculation: We are going through this problem at work right now, with dozens of developers learning Scala, and only a few of us that really started with significant experience. If I have to use slick, I use the few direct SQL bits. From my perspective, is the one saving grace of the library.
- s_kilk 12y agoFair enough, thanks for the perspective! What library would you use instead of slick?
- nje 12y agoYou could try https://github.com/njeuk/dbmapper https://github.com/njeuk/dbmapper . I use this for my Scala projects, having rejecting Slick and it's unwanted data DSL.
- joe_fro 12y agoWe went through a similar migration process and it sounds like we had different experiences. We started with the devs taking some time just to study and learn Scala basics then added the frameworks on top of that. I think if you go that way and you're using Slick > 2.0 it really starts to look like idiomatic Scala and everything in Slick looks like List manipulations. The other bonus is that a lot of the SQL generated perfors well and is easy to read.