Hanalei, Hawaii 2010-03-18

... In Which We Discuss Proprietary Object Noise

Jeff wrote a good post today on languages within languages- wrapping up the post with Embrace the idea of languages inside languages. In The Land of Strings, we speak regular expressions.

Jeff wrote a good post today on languages within languages- wrapping up the post with

Embrace the idea of languages inside languages. In The Land of Strings, we speak regular expressions. In The Land of Data, we speak SQL. Oh sure, you can pretend those languages don't exist, and hide out in the Kingdom of Nouns-- but you're only cheating yourself out of a deeper understanding of how things really work in those other places. Fluent interface object wrappers may seem like a helpful convenience, but they're actually an ugly hack, and a terrible substitute for true language integration.

There are two points at work here:

  1. Developers should know their languages (he uses Regex and SQL to support his point) and
  2. We should be able to use these more clearly/closely in code

I left a comment on his blog, but thought it worth a post of my own to respond. No, I'm not cranky cause he mentioned SubSonic (and some not-so-flattering words) - that's just Jeff. What're you gonna do. He told me my blog sucked, too... but that's what you get with the guy - a cuddle or a kick, the claws or a lick - that's Jeff Atwood :). And I love him ...

Why Jeff Is High
Regex SUCKS. Someone please blow it up :). The old saying of "I solved a problem using Regex - now I have two problems" is dead on. I don't think using Regex to support any point you're trying to make is a good idea - let alone a sober one :):).

SQL is abstracted because it's a shotgun, cocked and loaded. It's locked in the gun closet so it doesn't blow the foot off your application when you screw up. .NET isn't a Query Analyzer or a spreadsheet. Their are two powerful systems at work here - they don't need to sleep together, their lovechild would eat us all and crap out Regex.

How many weird little holes would open up in your app if your Database was, essentially, IN YR APP? Consider Jeff's response to my comment:

IDataReader rdr = QueryDb("SELECT * FROM Customer WHERE Country = 'USA' ORDER BY CompanyName"); Which is more likely-- developers that understand Subsonic, or developers that understand SQL? Which is more desirable?

WIthout asking him what "QueryDB" is (nor telling him that you can actually do that very thing with SubSonic), my response to him:

Jeff - how would you write this example (from your comment), taking in an argument from a variable to avoid injection: "IDataReader rdr = QueryDb("SELECT * FROM Customer WHERE Country = '"+KILLMYAPPPLZKTHX+"' ORDER BY CompanyName");"... Which is more probable? A developer that learns SubSonic, or a developer who writes inline SQL ripe for injection? Which is more desirable?

Things like SQL Injection, Concurrency, Locking, Connection Pooling, and most importantly: Repeating Yourself. Frameworks are around so we can focus on the job at hand, not writing SQL and Regex all day. I'll take the Framework please, with a side of Going Home Early. I'll read my Regex books when I get home tonite, I promise.

All of this joking aside, I do find a lot of common ground here with Jeff - I don't like the nasty nasty API calls. It's been one of my goals to make SubSonic as readable as possible so you know whats going on, or can at least figure it out. I'm assuming you don't want to write inline SQL... right?

This is the point of this post (buried deep in the bottom of it) - I agree with Jeff about readability, and I'd like to make our next query tool a little more readable SQL-wise. I don't think the answer is hauling SQL into C# though :p.

To me, his example above, and mine:

IDataReader=new Query("Customer").WHERE("Country = 'USA'").OrderByAsc("CompanyName");

Is about as close as you can get.

And finally - a small clarification I think is in order :). It's not

proprietary SubSonic object noise

It's MPL'd Open Source code (which you're welcome to help us with Atwood!) and belongs to everyone :).