The Essential Post-BUILD ASP.NET Playlist

I am back and mostly decompressed from //BUILD/ in Seattle. Lots of great product announcements – both digital and physical – and it truly is an exciting time to be a programmer on the .NET stack.  With releases in nearly all product groups from server to desktop, productivity tools to development tools and even hardware, we are seeing a company that is involved with and involving the open source community in more and more of what it considers to be at the heart of it’s development experience.

What You Missed if You Missed It

Not everyone was able to attend //BUILD/. I got in last minute on a waiting list. Others who had previously registered were dealing directly with Hurricane Sandy’s devastation, or indirectly with the impact on Eastern transportation and were otherwise unable to attend.  The facility was also limited in space – something that Steve Ballmer addressed in his keynote – resulting in greater than anticipated demand and preventing many who wanted to attend from doing so.

For whatever reason you were unable to attend, I present to you the list of sessions available on Channel 9 that are must-sees for every developer on the ASP.NET stack.  As a professional eager to improve their skillset and continue learning, I highly encourage you to invest 6 hours into your career and watch these sessions on-demand.

The Basics – What’s Here and What’s Coming

Here’s a quick look at the things that are already here and available to developers, and a few things that are on the horizon.  First up, the ever-funny Scott Hanselman on the state of the stack.

 

Next, Scott teams up with Jon Galloway for an entertaining peek at some of the new and not-yet-ready bits we have to look forward to.  This covers everything from Web Essentials, to a brief look at SignalR, templating updates, direction on the ASP.NET team and more.

 

From a script side of things, there are some major improvements to the way we write client side code.  My call is that TypeScript is going to be huge in our community and something you won’t get away with not knowing within a year.  Anders Hejlsberg walks you through.

 

As well, Mads Kristensen has a great talk on the experience in Visual Studio.  The tools we have at our disposal make me look back on 1999 and wonder how the heck any of us made it work.  We have a great kit, and VS2012 is bar-none the best IDE out there.

 

In the Wings and Good To Know

There are some technologies, features and libraries that are critical building blocks for us web devs.  Daniel Roth tackles some of this with coverage on Web API and cross-client development.

 

Real-time apps are becoming the norm, especially if you’re working in the “social” space, but this is true also of games, LOB applications and pretty much anything else you can think of.  And, yes, even chat Smile.  Check out Damian Edwards and David Fowler as they demo the juicy pub-sub power of SignalR.

 

#

And There you Have It

Those are my top picks for web devs.  There is one more very track that you should be aware of – touched on in many of these talks – and I encourage you to explore all of the cloud content on Channel 9

    Cloud Talks from //BUILD/ on Channel 9

I wish you all a very happy infusion of knowledge and awesome!

The //BUILD/ Keynote

WP_000401In a fashion very similar to MIX11, the keynote kicks off with a live musician. The twist this time is that the guy has a couple of Windows 8 apps that he’s running on a 27” all-in-one and is playing synth music off of the device.

Ballmer comes out to applause and welcomes everyone, then starts the keynote with a note to the East Coast. Very classy.  He quickly covers some highlights, generally available information through media, and then states strongly: “If you want the best experience in Windows 8, you will buy a Windows Phone.”

Next up, he wants to start showing the devices now available (or soon available). He elicits some laughs with a “It’s all shipping hardware, so let’s see how this goes.”  and then, when showing off PixelSense, “Here’s our 82” Windows 8 slate…” Nice demo, cracking jokes, showing off Bing maps on the biggest tablet I’ve seen.

Jumps into OneNote (a great app I use all the time) and adds some notes. I WP_000404anticipate some applause later when he shows it updated on the other devices.

Next up is a demo of the DELL 27” AIO. This is likely to be our new family PC.  On this machine he’s showing off the search contracts that are available for applications to implement. This allows users to search system and app wide with one search effort.  Share contract is up, but this is a mixed crowd, so the tech details are thin. If you’ve worked with the Windows 8 SDK these contracts were the thing that stood out most to me.

The new Bing app looks wonderful…love the pinned view and how it works with IE side-by-side. Great way to use pinning.

Now he’s showing off the roaming profiles. This is bigger than most people realize, but the demo is cool just the same. He’s changing the lock screen background on one PC and the others are changing on the fly.

The Windows 8 Phone offerings are very strong. I’m leaning towards the Nokia as I’ve always loved their phones (the first mobile I got in 1998 was a Nokia).

Now we’re back to OneNote, this time on the phone. No applause? Craziness.

There’s a 1.5 lb tablet from Asus. Pretty slick. He’s using the tablet to show off pinning in the built in Sports app. Pinning is something that Microsoft is really hoping that devs embrace, and they need them to. This is one of those features that really distinguishes Windows from other OS’s, for now. But the feature is too good to not be mimicked.WP_000405

When he moves to the Surface, there is general applause.

“Surface is the best expression for ‘PC meets Tablet’, good for work and play.”

Free music streaming for every Windows 8 machine. This is significant, and it works across Windows, Windows Phone and Xbox.

One last peak at the Surface…the clicking and folding that we see in the ads…and he finishes with a stylish walk across the stage to more applause.

The Lenovo tablet tablet is very nice..1.5 lbs and running on Atom, so everything x86 will run.

WP_000406The next laptop, at 2.38 lbs, is the Aspire S7-191 from Acer . It supports multi-touch, and comes with some pretty beefy hardware.  Ballmer shows off the device and shares how he’s been surprised at the impact this laptop has when he shows it off.  This is the class of machine that every Windows 8 developer should have.

“We’re all in with Windows 8.”

There’s a quick Xbox video highlighting some of the cool features that you get when you mux up Windows, Xbox and Windows Phone.

Next up, Steven Guggenheimer.

As big Phineas and Ferb fans, my kids are going to LOVE this: Agent P Strikes Back. It’s an HTML port to Windows 8, and it looks good. Sweet…he just plugged in an Xbox controller into the Surface and is now playing the game with the controller.  Then he takes it to the next level…WP_000410fires up Skype and docks it to the side, then brings up the game side-by-side. Your iPad can’t do this.  And then the same game running on Windows Phone. Very cool.

Wow…the HP all in one 27” workstation is pretty nice.  Guggs just opened it up while it was running.

The Sony Vaio has a capacitive pencil that works in really high res and looks very fast and accurate from the demo. He’s showing off a sketch app which works great in a “lay it flat and work with the customer” mode.

Now some economics through the Microsoft Store:

  • 70% to devs for all apps sold through the store
  • Jumps to 80% when you sell $25,000
  • Or…use your own delivery mechanism and get 100%

The Microsoft Payment engine is next up on the demo slate. You can now use PayPal in-app, the Microsoft payment system, or write your own.

WP_000411Michael Bayle from ESPN comes on stage and walks us through the development experience that they “reimagined”. I’m going to get sick of that word by the end of the week. The app is using all the bells and whistles of Windows 8, sounds like they collaborated heavily with Microsoft, and they built it on their new APIs at http://developer.espn.com. Nice work, guys.  The app supports deep pinning within the app itself, hosts all kinds of content, and you can move around easily with semantic zoom. 

Mr. Ballmer walks out on the stage.  Talking about writing apps…and showing tons of apps. SAP and Dropbox are coming, along with everyone from fitbit to Disney to Adobe to Hulu and more.  Twitter just announced that they’re building a “great Twitter app” this morning as well.

Now he’s making the pitch: here’s why you should build for Windows 8:

  • Lots of volume
  • Good timing

WP_000413Interesting that he’s talking about “devices” and not just PCs. The expectation is that there will be 400 million new devices running Windows 8 this year.

Steve acknowledges that there’s limited Windows Phone users right now, but commits to better marketing efforts for Windows and Windows Phone.  “You will not be able to pick up a magazine, newspaper, or watch television without seeing our ads quite frequently.”  The marketing commitment is something that has been missing on Windows Phone, so I’m really jazzed about that.

Holy Crap. Steve just started the giveaways:

  • 100 Gb of Online Storage (lots of laughs lol)
  • A free Surface (crowd goes nuts) – with a plea to build a couple apps

 

Now, on to Windows Phone with Kevin Gallo, Director of Program Management of Windows Phone.  He walks us through how he has customized his experience. If you have a Windows Phone already, this is something that you likely already love and use.

WP_000414Lots of great features coming for users and developers:

  • Tap and send
  • Share contracts
  • Kid Zone – really played this one up
  • Three sizes of live tiles
  • Rooms – private sharing of events, messaging, photos with groups of people
  • Better hardware
  • New UI elements
  • Common cloud services
  • Higher reuse of code through shared code base.
  • Windows Phone is now emulated on Hyper V
  • In-App purchases
  • Wallet
  • Lenses
  • Performance improvements
  • Speech API
  • Lots of tooling improvements
  • Bluetooth, better WiFi and NFC
  • …tons more. 90% of the top developer requests are now implemented and part of the package.

The Windows Phone SDK is now out with a free version of VS 2012, emulators, tools, samples, etc.

Next, he fires up Visual Studio to some applause, planning to show us a demo.

Cool…simple app using paired devices (Windows Phone and Windows 8) over NFC. Takes a picture, uses a gesture to “flick” the photo from the tablet to the phone, then from the phone to the device. The code base is shared, there’s c++ wrapped as a component, a shared project, a Win8 project and and WP8 project. The c++ code was older and easily imported, then called from the other apps.

WP_000415Now the real s#!t is happening. They’re flying a quad copter with the phone, it’s got a live video feed, but their “lawyers wouldn’t let them fly the helicopter over the crowd”.

75% of the top grossing apps are games, so this isn’t a market that you should not ignore if you have the ability to develop for Windows 8. Consumables, durables, c++ native code, all kinds of gaming engines are online with the platform, including Unity, who’s here to demo the Unity Gaming Engine on Windows Phone.

The Unity IDE is pretty sweet…I haven’t played with game environment editing since the Half Life editor and Milkshape. Looks like the IDE supports multiple platform targets (iOS, Windows, Android, etc). You can edit the game while it’s running, which he did, then easily deployed it to a prototype Nokia device.

WP_000417Richard Kerris from Nokia just came onstage to introduce the Nokia 920 (again to much applause).  Features:

  • NFC
  • Pureview
  • Maps that work (hahahahaha!!!)

Holy crap. They are handing out the 920 to everyone in attendance!

“Now you really do have everything you need to start building great apps for Windows Phone 8”.  And then, he dropped the price of the Windows Phone app store pricing from $99 to $8…everybody can get in at this price.  Only for the next 8 days.

http://dev.windowsphone.com for all the kit.

A Web Developer's Look at the MVC4 Request Pipeline

This article is intended to give you a solid understanding of how client requests move through the Asp.Net Mvc 4 Pipeline.  As developers, we need to know what options we have to override default behaviour, modify or augment requests as they arrive (and as they’re executed) and extend the pipeline as our requirements dictate.

A friend recently asked why his constructor was being called multiple times on the “same” request.  I thought the best way illustrate why this happens would be to explain the entire request stack.  Or say, “Just because!”, but I also enjoy writing articles like this, so we’ll go with the entire stack version.

If you’re looking for the “Coles notes” version, scroll down about halfway to see the summary. Smile

Once Upon a Browser

I’ll skip a few steps (like keyboard interrupts on the client device) and skip to the part where the HTTP request enters the interesting bits of the MVC Framework.

On the first request, application startup is executed from Global.asax, which configures the following:

  • Routes for WebAPI
  • Global filters
  • General routing
  • Bundling and minification
  • Authorization providers

Bundling and minification relate to client-required resources such as scripts and stylesheets and don’t affect our core request.  Authorization providers – for FaceBook, Twitter, Microsoft Account and Google Account – are now supported out-of-box, but don’t relate directly to our method execution either.

Assuming the app is already running, we can get back to the incoming request.

The registered route handler (an MvcRouteHandler by default) won’t find a physical file for our controller action, so instead it associates a matching route in the RouteCollection (which we configured above) and gets the IHttpHandler that will be used for the request.  In our case, it’s an MvcHandler, and it’s instantiated with the current instance of the RequestContext.

There are some other pipeline events that are firing, true, but now, we’re moving into the interesting bits as a web dev (versus someone developing HTTP handlers).  The MvcHandler is now processing the request.  If you haven’t modified the default behaviour, a DefaultControllerFactory is spun up and creates the controller.

As we ultimately inherit all our controllers from System.Web.Mvc.Controller we have a few interesting events around the time our action (a public, non-overloaded, non-static class method) is being executed that we can participate in.

  • OnActionExecuting
  • OnActionExecuted
  • OnAuthorization
  • OnException
  • OnResultExecuting
  • OnResultExecuted

However, we also have the ability to create our own filters, which is arguably a better way to interact with the request.

So, filter execution then kicks in, in this order:

  • Authorization
  • Action
  • Result
  • Exception

Note that the final order of execution is tied to the following orders of precedence:

  • Global filters
  • Controller filters
  • Action filters
  • The order in which those were applied (within their type)

Our method execution and view rendering are wrapped up in there as well.  You can see this by inheriting from ActionFilterAttribute and overriding the Action and Result events.  Put this attribute on your action and you’d see something like this if you were Debug.WriteLining:

  • OnActionExecuting
  • Action (method) executing
  • OnActionExecuted
  • OnResultExecuting
  • View executing
  • OnResultExecuted

One of the great features of the MVC Framework is model binding, which is part of this request pipeline but really deserves it’s own article.  Model binding is the process in which incoming HTTP data - such as form data or query string parameters - are converted to .Net types.  This means that we don’t need to cast a form field to an int, but more interestingly, that the form collection (or querystring parameters) as a whole can be converted to complex .Net types like a Person object. (I have some samples on this here.)

There’s one last point worth mentioning here. When the view is being executed it is done so by the registered view engine(s).  You can replace this with anything available in the community or you can create your own.  There are a couple of exceptions to this part of execution:

  • You are not returning a result that derives from ViewResult, in which case your method is executed and the result is returned to the client. You can set your response types (like 403, or 200) explicitly.
  • Your action is an EmptyResult, or it returns void which is translated into an empty result. Again, you can set your response types as you wish.
  • Your action generates an exception, in which case the last piece of your code being executed may just very well be your custom exception handler.

What About the Coles Notes?

A shorthand version of the following might be as follows:

  • Incoming request
  • App initialization (on the first request to the application)
  • Routing magic/kung fu
  • Controller creation
  • Filter execution
  • Action invocation
  • Filter execution
  • View Rendering
  • Final filter execution

And BAM! Your user sees something in the browser.

Riddle Me This

Now, a quick quiz.  Given the following view:

    <h2>Execution Count Testing</h2>
    <p>
        The execution count from the view is: 
        @Model. (@MvcApplication3.MvcApplication.ConstructorCallCount 
        constructor calls.)
    </p>
    <p>
        Rendered from the partial view via Html.RenderAction, the 
        execution count is: @{Html.RenderAction("ExecutionCountAsPartial");}.
    </p>
    <p>
        Rendered via ajax request from the partial view, the execution 
        count is: <span id="count-result"></span>
    </p>

    @section scripts
    {
    <script type="text/javascript">
        $(function () {
            var requestUrl = '@Url.Action("ExecutionCountAsPartialViaAjax")';
            $.ajax(requestUrl)
            .success(function (data) {
                $("#count-result").html(data);
            });
        });
    </script>
    }

…and the following controller code:

    private int _myCounter = 0;

    public HomeController()
    {
        MvcApplication.ConstructorCallCount++;
    }

    public ActionResult ExecutionCount()
    {
        return View(++_myCounter);
    }

    public PartialViewResult ExecutionCountAsPartial()
    {
        return PartialView(++_myCounter);
    }

    [OutputCache(NoStore=true, Duration=1)]
    public PartialViewResult ExecutionCountAsPartialViaAjax()
    {
        return PartialView("ExecutionCountAsPartial", ++_myCounter);
    }

…would you have thought you would have seen this?

image

Back to our original question, we have to differentiate between what a client request is and what you might refer to as an execution request.  In this case, the view for ExecutionCount is invoking three “execution” requests across two “client” requests.  The first two action invocations are made through the first client request, and when that is returned to the browser, the client is making a second request via Ajax which results in the third method execution.

So, two requests from the client and three actions executed, and the constructor is called three times.  We’re trackin’.  So, why all the controller constructor calls?

Well, let’s turn this around a second.  What if different actions are attributed with different filters?  Authorization requirements?  What about out-of-order execution (as in, single page applications making requests on whatever timing plays out)? The result in any of those would be a design where we’re no longer able to DoOneThing and we’d have to write composite filters that were able to handle the permutations of the above and other scenarios.  The MVC pipeline is designed such that each request passes through the above steps, regardless of where the request comes from.  This ensures consistency in execution for all requests.

If you are looking for different behaviour you can work around this if you simply separate your concerns: what I’m saying here is that a controller shouldn’t be used to do heavy lifting.  My answer to my friend was simply that his constructor was likely doing too much work and, in his case, user state shouldn’t be managed in the constructor.

More Reading

Now, all that is likely enough for most of us, but if you want to dive deeper you can read up on the following topics in more details:

As well, code from this article is available in the following repository on GitHub:

https://github.com/MisterJames/AspNetMvc-Execution-Pipeline

Getting Ready for the Dojo

Hey everyone in Ontario!  Well, at least, hello to you 50+ rock star developers from the CTT .NUG who signed up to participate in the Asp.Net MVC session this week! imageYou guys rock!

I’m stoked to be running this Dojo out here – the attendance at the intro to MVC a few months back was really strong, so I’m honored to be invited back to dive deeper and get you guys writing code. We are going to build out a database-backed, membership-enabled, fully functioning web app.

This is a hands on session – I need you to bring your laptop along, and I highly recommend that you have the tools installed before you come. We have about 120 minutes – which is already tight – and if you spend the first 45+ minutes installing tools, you just won’t get as much out of it!

Grab a copy of the following so you don’t have to miss any sessions and you can dive right in:

Visual Studio 2012 – This has everything you need. You can either grab a free 90 day trial edition or a completely free Express Web edition.

- or -

Visual Studio 2010 – But, you’ll need to add some “fresh” if you want to hang out with the cool kids. Make sure you have the following:

  • Visual Studio 2010 SP1
  • The latest version of NuGet
  • Asp.Net MVC 4 _RTM Version _IMPORTANT – the project templates and tooling have changed. To get the most out of this dojo, I need you to have the final version of MVC4 running on your machine.

 

Just a quick note…while I am a totally huge Windows 8 fan and encourage you to try it out, for the purpose of this Dojo session I highly recommend running from Windows 7 (or boot to a VHD from Win8 to Windows 7). I will be demoing a tool that has not yet been updated to work with the new version of PowerShell on Windows 8.  If you are already running Windows 8 full time (like me!) then I will be able to help you out and we can work around it.

Really looking forward to meeting everyone and working through as much code as possible in about 2 hours. See you there!

On Location: Building Connected Applications with Windows Azure

imageHey everyone, I’m geeked out to be joining Jonathan Rozenblit live at the Microsoft office in Mississauga to talk about Windows Azure Mobile Services.

Set time aside on October 22 at 1pm Eastern!

The theme: connected applications.  Mobile devices are limited by computing power.  Users want simple authentication (even those that don’t understand that appreciate a simple Facebook login to your app).  You need power on the service side.  You need to support multiple platforms easily.

And perhaps you’re building a new client onWindows 8, Windows Phone, iOS or even Android.  Regardless of the mobile platform, we’re going to equip you with the tools you need to get started building your apps.

For all the details, check out the information site and scroll down to register for the October 22 event.  See you all there!

If you want to follow along:

 

For more information on getting started with Azure, check out the main download page for the event.

Myths That (Some!) Ruby on Rails People Tell You

Hey…this post just shot past 10,000 views and I’ve received a ton of feedback that the title was inflammatory, which is completely fair. I’ve renamed it from “Lies that Ruby on Rails People Tell You” to the above, as I realize I was painting with the same wide strokes I am complaining about in this post. Thanks to all who were calling me on my BS title.  Cheers, -JC

Over the course of the last several years I’ve had the pleasure of working with developers from many different backgrounds.  It is true that there is incredible talent in every discipline. It is also true that you can build out great solutions on any of today’s modern frameworks.

I got my legs programming when it was cool to hate Microsoft (the first time around).  I built CGIs that ran on Linux servers, attended “distro install competitions”, ran my home internet off of the Linux Router on a Floppy project and through it all maintained that the blue mothership from Redmond was evil.

Then I grew up.

The reality of a multi-platform solution hit me very early in my career. It was great to be part of a production environment where many different engineers took on projects of different capacities requiring multiple skillsets and a ton of teamwork. I had learned that the “right way” to do something was through teamwork, cooperation and ingenuity, and that a particular breed of technology or the language you chose played a much smaller role in a successful project.

For over a decade now I have been programming primarily on the MS stack, and in the last three years have spent a lot of time working with the MVC Framework. I enjoy the workflow, the toolset, the community and especially the opportunities I’ve been granted that allow me to share my experience and mentor others.

Today, it is the attitude I once held – that the way to do all things is the way I do it with the technology I prefer – it’s that attitude that frustrates me more than anything. It really is true that the things you like least in others are the things you like least about yourself.

Okay, So What Am I Trying to Do Here?

Let’s start with what I’m not doing. I am not trying to say that the MVC Framework is better than Ruby on Rails.  That may be my opinion, but that’s because it’s best for me. Please appreciate the difference.

What I _am_ trying to do is to show that there is much less of a gap than might be suggested. The MVC Framework is mature, stable, performant, and worth exploring. It is also very likely worth switching to if you are on older tech.

What I am also trying to do is to grow the chorus of folks who are willing to try new things out. This is the one I hope I win at, because this is how things are going to get better. I often use the analogy of the iPhone, Android and Windows Phone. We have three great options for smart phones because there are three vendors taking a serious whack at the cat.

Oh Ruby, Don’t Take Your Love to Town

While I’ve had the privilege of working with some of the brightest minds along the way, I’ve also been part of teams where being at odds over which tech to use ends in turmoil on the project. Throughout my career the arguments have varied and blurred in focus between operating systems, languages, platforms, patterns, frameworks or even companies.  Windows vs. Linux, c++ vs. Java, Mac vs. PC, iPhone vs. Android, AWS versus Azure, .Net vs. [insert any framework here].  Some battles seem to be more intense than others, but in the last year I discovered one that actually blindsided me, I was completely unaware it was brewing.

And it comes from Ruby on Rails developers.

Judging Books

I want to be fair here – there’s more than one camp in the Rails world and I’ve met some insanely intelligent, productive, passionate developers who could do pretty much anything for mobile and web in RoR.  I’ve worked alongside some that have a background using .Net.  But there’s a slice of the Railers that has either never used the MVC Framework or used it in an early incarnation and have since not only condemned the thing, but also the developers that do good things – intelligently, productively and passionately – working inside Visual Studio.

More recently, I’ve been surprised by the venomous bile that has built up in some of these folks’ throats over the last year, to a point where they are spreading inaccurate, misleading and even entirely made up points to counter what is offered in the .NET camp for MVC development.  So I want to set the wheels in motion to correct some of these myths.

Myth 1: It’s Easier to Bootstrap a Project In Rails

It’s quite easy in Rails to get started. If you are comfortable with the command line you can create a new project by invoking a couple of commands. You can use template sites or boiler-plate generators that allow you to select the most common elements and assemble a project to get started.  There are also UI-based tools that facilitate a basic template of a project in Rails to get you kickstarted.

But that doesn’t make it easier.  Just different.

As an MVC Framework developer, I also get my choice of options. To start with, I can just say “File->New->Project”. I can use default project templates that are included in Visual Studio, download starter projects from the web, or, if I prefer, start with a completely empty solution and use Nuget to cherry-pick functionality that other developers have made available.

Myth 2: It’s Easier to Manage Packages Rails

This one was true, especially a couple of years ago. But Nuget – the open source package manager for Visual Studio – has come a long way and as of this writing there are very few things that it lacks. You can manage packages at the solution or project level. You can leave your binaries out of source control and leverage automatic package restore. You can cache projects at the machine or solution level. You can (very easily!) build out your own Nuget server, or use a third party solution like MyGet to host widely available private package feeds or an internal corporate feed.  Semantic versioning, dependencies, package upgrades and more are all implemented. 

Furthermore, the Package Manager Console is built on top of PowerShell and can be extended by Nuget Packages, meaning other developers can push out new functionality to your IDE along with functionality for your project by adding new commands to the Console.  It also has access to (almost) the entire extensibility points that Visual Studio offers, so it can modify your configuration, add files, create references, or insert code and more to affect your project.

And, especially for .Net developers, there are additional benefits.  Nuget is not limited exclusively to MVC projects; rather, you can use it for console apps, web service projects, Windows 8 or Windows Phone projects or whatever you like, so it’s opened the door to even more sharing and open source community to more devs around the world.

Myth 3: It’s Better to Develop with RoR Because it’s Open Source

If your personal opinion or corporate agenda is that it’s “better” to develop on OSS solutions, then good on you. For the record, the MVC Framework is completely open source. So is the entire Asp.Net stack. And the script libraries that are included in the project templates.  Oh, and Nuget, too.  This is not a differentiator for Rails.

Myth 4: I Get More Options for View Engines/I’m not Limited by Microsoft View Engines

First of all…what limitations?  The Razor view engine – the default for MVC – is likely one of the best view engines around right now. It did not have to support years of history when it was crafted, but it got to learn from it. It is intelligent as all get out and understands inline switching between code and markup. It is darn fast. It is terse (though not as much as Haml, for example) and versatile.

There are other view engines available to the MVC Framework such as Spark, NVelocity, Brail, or others or you can write your own.

Yes, in RoR there are many view engines. But like the MVC Framework there is a default, a whole bunch of less relevant engines and niche ones that exist to satisfy niche requirements.  Several people have demonstrated why they prefer certain ones over others, but no one has shown me why their view engine of choice is better.

Myth 5: Ruby on Rails has Been Around Longer and is More Mature

This is an irrelevant, misleading comment that is usually followed by statements like “there are more answers to questions on Stack Overflow” or “there is a better community” or the like.

Let’s address the first point: Ruby on rails has indeed been around longer than the MVC Framework, but this is a slight of hand.  The MVC Framework is built on top of the .NET Framework and the toolset for MVC is an extension of Visual Studio.  Maturity isn’t dictated by age, and what is really important is how comfortable you are with your tools.

I know, right away, that comments will fly like “Visual Studio is a memory pig and crashes all the time” or “Sure, I like VS, it’s the best wrapper for ReSharper that’s out there”.  Fine, if you prefer a different environment that is your choice, but it doesn’t mean you can dismiss VS for what it is: the software development tool used by more professionals than other other IDE on the planet (I can’t speak for the moon).  I use it every day with very little friction and the productivity wins are quite large.

On the second point: Stack Overflow may have more questions about Ruby. But let’s not forget that more people asking questions might not be a “good” thing! Let’s pause and think why people might be asking questions for a moment. Are they relevant for recent releases? What are the quality of the answers?  Or the questions?  And if your party line is that more questions are better, then head over to the Microsoft forums where there will be questions on MVC, ASP.NET, c#, Visual Studio, or the .Net Framework itself.  You’re likely to find just as many bad questions, answers, arguments and features in any language, if you look hard enough.

Myth 6: Ruby Tooling Provides Better Database Practices

I will be quite frank: until EF Code First had migrations, it was a great little hack to use in presentations and show how fast a developer I could be. Even in the earlier versions of EFCF migrations there were struggles to understand targeting, versions, naming, which connection strings were being used, etc.

But today’s database tooling is much better, and the MVC Framework aligns quite well with corporate environments and software professionals around the world.  Everything you need for automatic DB generation is built into the default MVC project templates with no additional requirements or dependencies to add.

But if you don’t want to use Entity Framework, how do you access the DB in the MVC world? However you want to. That’s abstracted away so that you can have SQL, SQL Express, My SQL, Oracle, or CSVs files retrieved via JSON served from a Commodore 64.  It doesn’t matter what you choose.  You can pick whatever ORM you like.

And if you do choose EF Code First, then I’m happy to say that migrations have finally arrived. You can use choose your strategy for database creation, seeding or migrating up and down, or use the default (and quite capable) behaviour. You can enable settings that allow for very rapid prototyping or strict it up to prevent nilly-willy changes.  Your “plain old CLR objects” or POCOs are used to infer your naming, relationships, indexes and defaults, but you can override this behaviour as well.  Objects and properties are strongly typed, navigation across entities is discoverable as you code and much of what is there will be familiar to experienced developers.

Besides, what do you do in a RoR application if you have to use legacy data?  Or if corporate requirements dictate the inclusion of Data Architects on your project? You have to slog code, that’s what.

Again, this is an area that has virtually been eliminated as a talking point when it comes to comparing the frameworks.

Myth 7: It’s More Clear Where Things Go in a RoR Project

Disagree completely. You may be more familiar with where your bits need to be flipped, but this is just an issue of groove.  Once you know where things are – in either MVC or Ruby on Rails – you build a comfort level with your tools, classes, scripts, models, packages, etc. and you get to work.  You may prefer your toolset over another but let me assure you that I don’t stumble around in my projects trying to find the parts I’m going after.

I know exactly where my models go.  And my views.  And helpers.  And filters.  If you come from the Ruby world and you don’t know where these things go, I can also assure you that the directory structure is no less intimidating in RoR projects when you aren’t familiar with the layout, patterns or best practices.  This is exactly why we learn our tools, languages and environments: so that we can be productive.

I have had live conversations with the actual humans (yes, they are humans!) who have built out Razor, the MVC Framework, Nuget and who have otherwise been big contributors to the ASP.NET landscape.  They are just as concerned about building out a great development experience as anyone else out there building tools.

Myth 8: It’s Easier to Target Any Environment I Want

One of the great things about Ruby on Rails is the ability to just create a copy of environment you’re working with – say your test environment – rename it and then simply alter the configuration elements you need changed for the new one.

One of the great things about solutions in Visual Studio is the ability to just create a copy of environment you’re working with – say your test environment – rename it and then simply alter the configuration elements you need changed for the new one.

See what I did there?

Let’s Work Together and Build Awesome

Look, what we really need to do is cross-train. Seriously.  There are _great _things in the RoR world, and there are great things in the .Net world.  They argument that “well, they just copied x from y” when you are talking about any framework is pointless.  I can’t see how any professional would argue otherwise.

There are many different shapes of hammers; they all pound nails.

When we accept that – and learn from each other, rather than beating each other up – then we can challenge and inspire each other and push our craft much further.  You can’t say you’re a better developer than me because you’ve memorized your syntax, and I can’t say I’m the better dev because I’m faster with IntelliSense.  We’re different.

And, man, that’s just plain.Okay().

Steps v.Next

If you are a Ruby on Rails developer, I highly encourage you to grab the free tooling and try on some Mvc.

And to my fellow .Netters, go rake yourself some Ruby love.