9

What Dynamic Typing Is For

> The compiler should understand the DSLs I’m writing and automatically map them to types it understands. If it needs more information—like a database schema—to figure that out, that information can be provided.

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.

[0] https://scala-slick.org/doc/stable/sql.html

[1] https://github.com/ThoughtWorksInc/Binding.scala

an hour agondriscoll

The article is well written and shows why dynamic typing can be so compelling.

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.

2 hours agouser68858788

This is the first time I see a compelling argument for using dynamic languages for writing web backends. Not that I actually write web backends, so maybe this is all obvious to real practicioners. Thanks for sharing!