Dumb Arguments for Strong Typing

I'm a big fan of Haskell. Really big. It's my other favorite language besides Prolog. And there can be no question that a significant aspect of Haskell is its expressive and powerful type system. In a sense, it's the face that launched a thousand type systems. There was recently a bit of a row about dynamic and static languages (in my opinion this is the winning post) and I won't rehash it here. Instead, let me trash a few idiotic arguments for static typing that arise in web development.

Statically-Typed SQL Generation!

This one really grinds my gears. First of all, there is not a single (to my knowledge) complete statically-typed wrapper around all of SQL. The static framework du jour probably supports some “common subset” of SQL that MySQL, Postgres and SQLite can do. This is a really awful subset to work with, yoking the oxen of Postgres and SQLite to the ass that is MySQL, but this isn't my point. My point is, how often have you seen an application of yours get into production, only to have the SQL fail because of compile-time detectable type errors?

The answer is zero. This has never happened to anybody. Sure, you've had SQL injections. And it's quite likely that your framework prevents them—nevermind the categories of valid and safe SQL that are excluded from it in the process. But it has literally never happened that SQL that worked when it was committed stopped working in production because of some unforeseen type issue.

Why is that? Because you write SQL interactively and you don't commit it until it actually works.

There are plenty of interesting frameworks out there for SQL. The most compelling ones I've seen lately are Postmodern for Common Lisp and SQL Alchemy for Python. I have a certain appreciation for myBatis. The rest are taking an elegant-albeit-verbose external DSL (SQL) and replacing it with an inelegant, limiting, frequently also verbose internal DSL.

This is a non-problem, folks! Don't waste my time solving it.

Valid HTML Generation!

Whoopee, you solved the hardest problem of all! My HTML is now going to be valid!

Funny story: it almost does not matter at all if your HTML is valid. Being valid won't make it render properly. Nobody can tell or care if your HTML is valid.

Similar to the above, what happens with your static generator when WHATWG releases new elements? Do I have to circumvent your system, or do I have to wait for the next release? This was a real pain with JSF and HTML5.

Other Considerations

Note that there are things you can do for me with your library that I may value. For instance, Postmodern is able to give me a level of compositionality that is kind of missing from SQL. That's nice. But the only way for it to really support all of SQL is by having a generic process for converting s-exps into SQL. You don't have to get a new Postmodern whenever a new version of Postgres comes out to use new features. That's the flipside of the type checking argument. If you wrap a lower-level system that has worse type checking than your language, you have to basically code that other system from scratch with your types. What are you buying with all that effort?

The other irksome thing about wrapping both SQL and HTML, but especially SQL, is that you're trying to treat something high-level as if it were low-level, in something that you believe is high-level, but is actually lower-level. You cannot really have a procedural wrapper around SQL and have it be more powerful than SQL, which is declarative. The best you can hope for is a procedural library for writing SQL statements. And that's what Postmodern and SQLAlchemy do, and why they don't get into as much trouble as Hibernate does.