Redmond Diary

By Andrew J. Brust

Blog archive

WebMatrix, Razor and a Return to Simplicity

This week, Scott Guthrie, Corporate Vice President at Microsoft's Developer Division, announced, via blog post, the early Beta release of a new tool called WebMatrix. WebMatrix is a free developer tool that enables Web development geared toward what I might call Markup-and-Script developers (more on that in a minute). And although WebMatrix draws upon technologies already, or soon to be, present in the fuller ASP.NET Web development platform and the Visual Studio integrated development environment (IDE), it is a radical departure from what those technologies have evolved into. Some review of Microsoft developer tool history might bring this into perspective.

Simple Beginnings
In the early and mid 90's, Microsoft's developer tools were pretty simple and straightforward. For Windows development, Microsoft had its Visual Basic (VB) product, and for Web development, it had something called Visual InterDev. For hardcore developers there was Visual C++, and for adherents to the acquired FoxPro product (now called Visual FoxPro, of course) there was that too.

The four products were sold together as a single entity called Visual Studio, but that name was really a bundle and umbrella brand for the four constituent products. Most Visual Studio customers used VB and InterDev for their work. VB featured an easy drag-and-drop design environment for building Windows desktop applications: drop controls on the form, set some properties, add a little code, and you could have a functional application. Visual InterDev provided an IDE for developing Active Server Pages (ASP) applications, which were simple text files consisting of HTML and Visual Basic code (actually a scripting version of VB, called VBScript). The VBScript was embedded within the HTML markup within <% and %> tokens so that the ASP engine on the Web server would know to parse it and send it to the Active Scripting engine. The files ended in an .asp extension so that the ASP engine would be invoked in the first place.

None of this was especially difficult, and yet it was impressively powerful. With VB, and ASP/Visual InterDev, Microsoft provided a way for clever, logical thinkers to be productive programmers in a short amount of time, and to use the same programming language expertise for both desktop and Web applications.

It was the best of times; it was the worst of times. Microsoft made programmers productive, but the low barrier to entry meant that lots of VB and ASP applications were written by bad programmers, and it gave the platform a bad name. Meanwhile, Java and its Java 2 Enterprise Edition (J2EE) flavor were eating VB and ASP for breakfast. J2EE was more complex and fragmented, but also more robust, scalable and, to be honest, more appealing to a higher caliber of developer.

Redmond's Revenge
Microsoft's response was to create the .NET Framework. Version 7 of Visual Studio was the first version of Visual Studio .NET. It provided a single IDE for desktop development and Web development, which could be done in a new version of VB (called VB .NET), or in a new langauge called C#, which bore an uncanny resemblance to Java. C++ could be used inside this IDE as well, and so could Microsoft's own licensed version of Java, called J#.

This version of Visual Studio and its Web technology, now called ASP.NET, extended the forms metaphor to Web development, such that the old "VB" and "ASP" were now called WinForms and WebForms, and they worked in a very similar manner. A (surprisingly) little known fact is that ASP.NET applications could still be developed using the old <%... %> syntax in the markup, without the need for forms and controls, but there was no encouragement from anyone to write ASP.NET code as if it were ASP.

The new IDE was more complex than any of the old ones, but in unifying them, it added simplicity too. A universal forms metaphor and a unified IDE, with the added rigor of the .NET Framework, and fully object-oriented programming made .NET very competitive with J2EE. Also, the programming was just enough harder to filter out many of the less capable developers who were on the Microsoft platform before. Microsoft made a big bet, and it won.

The Plot Thickens... And So Does the Platform
But Microsoft lost too. In political terms, it abandoned its base. And I think it did so based on a notion of false choice: it thought it had to cater to enterprise developers or productivity programmers, but that it couldn't do both.

And then it got worse: after the 2005 edition of Visual Studio and version 2.0 of the .NET Framework came out, Microsoft added a trio of technologies: the Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF). Originally these three technologies were planned to be part of what became Windows Vista, and were to be known collectively as WinFX. When they shipped, however, Microsoft decided to dissociate them from Vista and allow them to run on XP as well. Since they were really extensions to .NET, Microsoft rebranded the collection as .NET 3.0.

And this is where things started to get really complex. WCF and WF were not, and are not, for the faint of heart. WPF introduced a completely new way to create desktop applications. And while it added a slew of new capabilities, its designer for Visual Studio removed most of the productivity from its WinForms counterpart. These technologies have since been updated and have been joined by Silverlight (a relative of WPF, remade for Rich Internet Application use), ASP.NET MVC (which does away with the WebForms metaphor, but does not return us to the single-file comingled code + markup model), Language Integrated Query (LINQ), the Entity Framework (a data access model which sits atop, but effectively replaces, the native data access core, known as ADO.NET) and an array of application lifecycle management features within the Visual Studio IDE itself.

This is neat stuff. This ups the challenge to Java. It accommodates development of very large applications, built by big teams, distributed across the world. All of that is good. Much of it is crucial and necessary. But none of it helps that original constituency of developers who want a highly productive environment in which they can build entire applications (albeit smaller ones), quickly, easily, and largely by themselves. And those folks have been willing to be neglected for only so long.

Voting with Feet
Many of those productivity programmers have left the Microsoft platform, and many newer, younger programmers who also fit that profile, have steered clear of .NET and Microsoft completely, for this and a variety of other reasons. A lot of them have moved to languages like PHP.

If you look at PHP, you'll see it bears a strong resemblance to the old ASP: code comingled with markup, contained in blocks offset with <?php and ?>, inside files with a .php extension. There's no huge framework, nothing really like WCF and WF, and most PHP developers use very light tools for editing their code -- thick IDEs exist, but aren't so much the norm. PHP has a huge and enthusiastic community around it too. And while it may not be the right environment for those huge enterprise apps, it's good enough: Yahoo and Facebook run it, in fact.

So we're left with a situation where Microsoft is losing in market share, passion and enthusiasm to a development environment that works quite similarly to something Microsoft had 15 years ago. Yes, there are important differences: PHP runs on Linux as well as Windows. PHP is open source. Its syntax looks much more like C or JavaScript than it does Visual Basic. But the fact remains it has a simplicity and short path to productivity that intrigues developers and empowers them, and that's exactly what Microsoft knowingly and willfully jettisoned

Microsoft could always promote the fact that code + markup still works with ASP.NET. You can still use <%... %> syntax... and store everything in single files with an .aspx extension that you can then just push up to a Web server. You can edit these files pretty easily in Visual Studio. If you have the discipline to ignore all the other stuff in ASP.NET and the .NET Framework and all those menu options and toolbars and dockable windows in Visual Studio, you'll be fine. But advising abstinence and calm is no way to win over an entire population of developers that wants to spread out in territory that is friendly and navigable to them

Back to Basics
So instead of providing guidance around using a subset of ASP.NET Web Forms and a subset of Visual Studio, or just bringing back the old tools, Microsoft has done something far better. Through the introduction of a technology code-named Razor and its use in a new code + markup environment called ASP.NET Web Pages (not Forms) and provision of the new, highly streamlined WebMatrix IDE, Microsoft is beckoning the productivity programmers back, in a credible way, without condescension.

Now instead of starting your code with <%, you can use a simple @ sign for embedded expressions (and you don't need to end the expression with anything!) or use @{ and } for full-on code blocks. You put everything into files with a .cshtml extension (you can use .vbhtml too, with the inline code in VB.NET but the Razor code block syntax differs slightly). Razor also provides so-called HTML Helpers that make short work out of complex tasks. Want a scrolling window with tweets from me? Just embed this code in a page:

@Twitter.Profile("andrewbrust")

There's another helper just like that for Facebook, and a collection of others for creating data-driven user interfaces, sharing links on social networking sites and performing Web Analytics tasks.

WebMatrix also comes with a workstation-hostable version of Microsoft's Web server (Internet Information Server, or IIS) called IIS Developer Express. And it comes with a small, file-based database engine called SQL Server Compact, which is entering its 4th version, but only its first version optimized for ASP.NET. SQL Server Compact databases, and SQL Server Compact itself, can be easily deployed to any Windows Web server over any file copying protocol, including FTP. And WebMatrix can do that for you, with just a couple of clicks. It can even help you find a hoster and provision an account. There's also built-in starter features for creating and editing data, and for performing SEO analysis on your pages.

Web Matrix isn't exclusive to ASP.NET and SQL Server by the way. It also lets you edit and create applications using PHP and MySQL! That's a HUGE step for Microsoft, especially with regard to the database.

Gimmick, Experiment or New Leaf?
WebMatrix isn't perfect, certainly. And it's streamlining sometimes borders on plain old bare-bones. There's no IntelliSense (pop-up syntax completion), no rendered view of your Web Pages (you have to run the pages in a browser for that) and not much documentation that I can find, either on the tool itself or on Razor and the HTML helpers it includes.

Also, this is not the first product Microsoft has had called WebMatrix. An earlier product with the same name, back in the early days of .NET, which provided a simplified IDE for creating ASP.NET WebForms, was put on offer, also for free. That product gave rise to the Visual Studio "Express" Editions... but the original Web Matrix project died.

Will its successor suffer a similar fate? Is this just a freebie tool that Microsoft will obsess on for a while and then let languish? Is it just a cynical attempt at converting PHP developers over to the full-blown ASP.NET stack? It's hard to say, and Microsoft needs to make a real commitment to this WebMatrix if it wants developers to invest in it.

But it's a great start, and it's the first thing I have seen in a while from Microsoft that makes programming powerful and fun at the same time. I hope it's a precedent, and not mere anomaly.

Posted by Andrew J. Brust on 07/12/2010


comments powered by Disqus

Featured

Subscribe on YouTube