Discarding magic feathers -- Going frameworkless in Scala

Click for: original source

A good few years back, I looked into building a Scala webapp using Java’s little-known provided HTTP server rather than one of the many frameworks already out there during my 10% time at Springer Nature. I made a mistake here - to avoid those frameworks I built my own framework to route requests within a webapp. I called it Sommelier, and it is now hidden away in a private github repo as really, we don’t need another of those. Maybe we don’t need any of them at all. By Jim Kinsey.

Building a Scala app with the intention of not using any of those frameworks with their obscure syntax and unnecessary concepts and then going on to build it with SBT would be kind of perverse. I could use Li Haoyi’s excellent Mill, and I have been doing both in professional and personal projects, but given the nature of this project I wanted to see what I could do without.

The article main points:

  • Building a Scala app without a build tool
  • Testing a Scala app without a test framework
  • Handling HTTP in a Scala app without a web framework
  • Frontend in a Scala webapp without a framework
  • Database access in a Scala app without an ORM / DB framework
  • Dependency injection in a Scala app without a DI framework
  • Performance of a frameworkless Scala app

Interesting observations were found in performance space. The average cold build time for the “unframeworkless” version using SBT was 178.86s, over 3 minutes, compared to 7.08s frameworkless. Understanding the kinds of problems the frameworks and libraries we use every day are designed to solve, and the challenges faced in solving them, should help us understand how to work with them better ourselves. The potential causes of unexpected behaviour become clearer - and by understanding these fundamentals without reference to any framework, the learnings can be applied across frameworks. It helps to understand the fundamentals. Good read!

[Read More]

Tags scala akka programming app-development web-development