Rogue: A Type-Safe Scala DSL for querying MongoDB
engineering.foursquare.com
engineering.foursquare.com
...including every SQL database.
What makes type-safety the most important property of a DSL for querying a database to note when introducing it?
"not much"
I'd argue there are potentially better priorities available for a DSL->DB mapper. But hey, they're the ones putting themselves out there and putting in the hard work, not me.
So, more power to them and I'm glad they're contributing back to the community.
With a good type system, you can take that thought one step further and say, "How can I make sure this class of bugs results in a compilation failure in the future?"
Rogue lets us do that. The DSL is both expressive (it covers almost all of Mongo's query features) and easy to use (Rogue queries are concise and very similar to Mongo queries), yet they eliminate (at compile time!) a whole class of bugs that have bitten us in the past. When your Rogue query compiles, you can be fairly certain that it will generate a well-formed Mongo query. Getting a similar guarantee from a test suite would involve a lot more work.
In practical terms, better testing would've saved it, not better type safety.
The rest of the sales pitch doesn't require type safety, although I appreciate that a rather nice piece of software is being shared here.
Type safety obsession reeks of cargo cult to me, but that's not exclusive with well-made software.
However - when you say it would have involved more work to guarantee well formed queries from a test suite, I find myself wondering how that can be true if you test every function that hits the database. Wouldn't malformed queries would cause such tests to fail?