This is how I’ve been writing web services for the last decade. It was a style that came from being frustrated with the experience of using many all-in-one frameworks.
Frameworks take time to learn and the skills are generally non-transferable. Any complex application still requires you to know the underlying languages frameworks attempt to abstract. Frameworks often make testing more difficult due to adding layers of abstraction between what the application does and how the code is written.
Writing actual SQL/CSS/etc in a dynamically typed language to be used in a template is so much easier to understand, debug, and validate.
What you're describing are string interpolation macros, and e.g. Slick in Scala does this[0]. You write SQL with normal variable substitution, and it compiles to a prepared statement with bind values (so no SQL injection), and can optionally validate against your schema at compile time. Super simple to read, write, and maintain.
I've not done any frontend Scala, but apparently Binding.scala[1] offers similar functionality to make composable HTML templates with databinding based on string interpolation macros (boy was that a jargon-dense sentence to say "nice in lots of ways"). The readme says it's statically checked including HTML tags/attributes.
So yeah statically typed languages do also have template systems, and when you have macros + type inference, as you've guessed, you don't need to drop to dynamic types.
jannesan•3mo ago