Why debate politics when you can just blog about ORMs?

TL;DR: ORMs, like everything in this world, have a time and a place.  Figure out where it makes sense to use them and use something else when ORMs don’t make sense.

ORMs are a hotly debated topic in the world of programming.  There are countless impassioned blog posts from programmers discussing how ORMs either killed their pets or cured their aunt’s cancer.  Why, oh, why is this talked about so much?  Aren’t there more important topics at hand, or are our lives so void of conflict that we have to sit and argue about this till we’re blue in the face?  Can’t we just move on and accept that ORMs are a part of our lives, and that, in some cases, they can even be good?

(Yes, I get the fact that by joining in on the conversation, I am being a hypocrite.  I promise to keep it short.)

I read a post recently that got some attention on Reddit’s r/programming.  The gist of it was, if you’re going to use an ORM, you might as well just learn and write SQL.  But this post (and all posts on ORMs, including my own) should be taken with a grain of salt – the author says it all at the end of his post:

“It should be made clear that I am not claiming this is how all applications should deal with a database.  All I am saying is that this fits my use case based on the data I am working with.”

So… all that impassioned discussion, for what?  To come to this startling conclusion?

“I use SQL because ORMs don’t fit my particular application.”

I gotta tell you, that right there is riveting. (I understand I’m oversimplifying.  Don’t take my sarcastic jives too seriously.)

Not to say that the author’s article had no value – it makes some good points about the weaknesses of ORMs.  And let me be clear: learning an ORM is not a substitute for knowing and understanding SQL.  My experience with both hand-coded ADO.NET (.NET’s most simple database access library) and Entity Framework (a Microsoft-supported ORM for .NET) has taught me to know when you use one and ignore the other.  But for most new projects, the first thing I do is model my database in Entity Framework (either Code First or Database First, depending on the scenario.)  Which leads me to answer this one, simple question.

Q: Spencer, why do you use ORMs?

A: Because they deliver business value by allowing me to get things done quicker. Do I want to spend my time writing and debugging typo-prone, hand-coded SQL queries or making THINGS that do STUFF that businesses want?

Donald Knuth’s nugget of wisdom, “premature optimization is the root of all evil,” is so very true.  Oftentimes, ORMs are ignored because they are “leaky abstractions” and “too slow.”  Yes, they’re slower than hand-coded ADO.NET.  But guess what else is slower as a result?  *Me.  *How can I maximize my productivity when I’m sitting there writing things like this:

When I could be writing things like this:

Or this (for primary key lookups):

Or this, if you prefer query syntax (in this case, I don’t):

Bottom line: ORMs help me deliver more value to the company I work for.  If I work faster, they get more productivity out of me.  Not to mention that it gets me to the fun stuff faster.  That’s about all I feel I need to say.  But I’ll say a little more and talk about one company’s experience with ORMs.

StackOverflow needs little introduction – it’s one of the biggest websites on the Internet.  It’s built on ASP.NET with a SQL Server backend.  Most if not all queries ran through LINQ to SQL, an ORM similar to Entity Framework.

LINQ to SQL is far slower than hand-coded ADO.NET, but did that matter?  In fact, it did, but only when LINQ to SQL wasn’t fast enough.

Sam Saffron, co-founder of StackOverflow, determined that LINQ to SQL was too slow in certain parts of StackOverflow, and wrote his own ORM, Dapper, to handle the queries that were computationally expensive to run on his application layer.  The result for them was faster load times for some of their webpages.

Dapper is nearly as fast as hand-coded ADO.NET and is of course much faster than LINQ to SQL, but Sam didn’t ditch L2S right away either and tells you not to do the same.  In his words (emphasis my own):

I would not recommend people go crazy and dump LINQ-2-SQL just because of this. My recommendation would be: measure, find bottlenecks and fix the ones that matter.

So, there you have it.  Agree?  Disagree?  Sound off on twitter (@schneidenbach) or the comments below!

EDIT: Changed “error-prone” to “typo-prone” in my little Q-A.  People seemed to think I meant SQL was error-prone, when in fact I meant that I’m prone to making mistakes.  ADO.NET requires lots of string-searching for columns and casting those column values to the correct types, and in all of that typing I tend to make more mistakes as opposed to using Entity Framework.

Hey, Xamarin - the Indie developer needs Visual Studio, too

TL;DR – Xamarin should include Visual Studio support in their Indie subscription level OR at least add it on as a separate monthly cost.

When designing pricing for subscription-based software technologies, oftentimes the best features are saved for the most expensive subscriptions, and rightly so – the developers have the right to profit off of their creation and create higher prices for features they might not normally support.  However, a killer feature can sometimes be priced higher than is reasonable for smaller shops or indie developers, leaving some feeling left out in the cold, and I believe Xamarin is finding itself in the midst of this very pricing conundrum.

For those who don’t know, Xamarin is a mobile development platform that allows you to use C# (or F#) to program for the two biggest mobile platforms today, iOS and Android.  When you’re used to the .NET ecosystem and all of the conveniences it offers, such as LINQ, lambdas, garbage collection, etc., Xamarin becomes very appealing.  Xamarin’s vision is to maximize code reuse among all platforms and includes many great innovations such as Xamarin.Forms, which allows you to create one UI codebase for all three major mobile platforms (iOS, Android, and Windows Phone.)

Xamarin’s pricing model is as follows: for indie devs or shops with five or less employees, you can pay $299/year per platform to develop using the Xamarin stack and their IDE, Xamarin Studio, an offshoot of the open source MonoDevelop.  The next subscription level is the Business level – at $999/year per seat per platform, it includes email support, in-house deployment capabilities, and – wait for it – full integration with Visual Studio, king of IDEs.  (The two final subscriptions are worth mentioning, but aren’t the focus of this post – Starter allows you to develop for free up to a certain app size and Enterprise gives some other high-end business features and support.)

Since Xamarin announced Visual Studio integration for Business subscribers, smaller shops and indie devs have asked for the Indie subscription to include Visual Studio support.  Their argument is that the Business edition is priced too high for them to seriously consider and that the included IDE, Xamarin Studio, doesn’t have many of the features that are available to Visual Studio, including major plugin support (ReSharper, anyone?)  It has been a major topic of discussion on Xamarin’s forums as well as social media, and is currently the 2nd highest voted request on Xamarin’s UserVoice page (1st being for a plugin for Visual Studio only.  Notice a pattern?)

Xamarin announced yesterday that it has changed the Indie pricing to $25 per month per platform, as opposed to $299 annually.  While a step in the right direction to get indie devs to jump to the Xamarin platform, it still doesn’t include Visual Studio integration.

Nat Friedman, I’m talking directly to you here.  *You are missing a big opportunity to deliver more value to your customers and shareholders by opening up Visual Studio integration to your Indie developers.  *$999/year per platform is simply too much for an individual to swallow – even with your 10% multi-platform discount, that’s $1,800 per year for one person!

Yes, your engineers have put a lot of valuable time into making Visual Studio a first-class citizen in the Xamarin ecosystem. I believe that feature alone has tremendous value, so much so that I believe if you make this change, you will see more Indie developers jump to your platform.  However, the value gained for the Indie subscription is not lost for the Business subscription.  In-house deployment and email support are more than enough reason for businesses to shell out $999/year per dev per platform, not to mention that you have to buy it anyways if you have more than five employees.  You have no shortage of enterprise customers anyways, judging by all the logos on Xamarin’s front page.

I believe that the change to the Indie platform to make it monthly is a move in the right direction, but can be vastly improved.  My humble suggestions to improve pricing for the Indie subscription level are as follows.

  • Include Visual Studio support for Indie devs. I think you will find the adoption rate for Indie subscriptions will rise and, subsequently, your revenues.  I don’t believe Business subscription numbers will fall as a result, because there is still a lot of value in email support and in-house deployment, and you will gain additional market share from other mobile development platforms.  Win-win.  Plus, the more people who use your platform, the more valuable it becomes to others.  Win-win-win!
  • If not for free, then consider an add-on pricing model, where indie devs can subscribe to get certain features.  $5/month for Visual Studio support is priced nicely and is pretty attractive for any .NET dev looking to get into mobile development.  Perhaps even allow email support as an add-on, say, $5/month for two support tickets a month?
  • Offer better monthly discounts for multiple platforms. $50/month sounds a bit steep for both iOS and Android.  $40/month sounds much more palatable.  Make it $45 with Visual Studio support.  That’s $540/year for Xamarin – not a bad take at all if you add even 1,000 indie developers to the mix.

Bottom line: I love Xamarin.  I love their vision for mobile development within the .NET ecosystem and they are well-supported and well-funded.  However, I believe that there are great opportunities for you to create even more value for your company and for developers alike.

That concludes my very first post – I hope you enjoyed it.  Agree?  Disagree?  Sound off in the comments or feel free to tweet me @schneidenbach.