Recently in Skills Category

Well, Apple's iPad was something of a letdown, wasn't it? The most anticipated product since the iPhone launched onto the global stage not with a bang, nor with a whimper, but with what can only be described as an embarrassed shuffle.

You could tell that things were starting to go awry even as Steve Jobs sat down in the comfy chair onstage to carry out the demo. He was scrolling happily through several web pages, blissfully ignoring the fact that the first one he went to - the New York Times - simply didn't work as it was intended. Why? Because apparently, just like its smaller brother, the iPad doesn't support Adobe Flash.



Tim Anderson wrote recently about the need to develop for the mobile Internet. Mobile search and location-based services will drive the mobile web. Mobile advertising has been growing slower than expected -- recently, research firm EMarketer anticipated a $1.1 billion spend by 2012. The financial downturn has slowed developments, but the potential for mobile Internet revenues is staring us in the face, nevertheless.

This is why Jobs' demo last Wednesday is so significant. The iPad is flawed in many respects. It has no camera. There are no standard ports on the thing. It costs more than many net books, and yet its operating system is locked down. But one of the biggest flaws is that without Flash, many of the sites that we would like to visit are not available.

Such is Adobe's chagrin that its platform evangelist Lee Brimelow published a list of websites including Google Finance, Disney, CNN, popular American media streaming site Hulu, and Facebook application Farmville. None of them were without Flash, meaning that none of them will work on the iPad.

Apple's decision to eschew Flash on the iPhone was irritating enough for Adobe, but to do it on a tablet device that Apple hopes will replace the laptop for many consumers sitting on the couch in the evenings is no less than a declaration of war. Adobe needs to promote itself in new markets like this one, where everything is at stake, and Apple is making it very difficult.

Adobe definitely has cause to worry. Apple's share of the mobile market is only 2.7%, according to research firm Strategy Analytics. On the other hand, it sold 99.4% of all mobile applications last year. People buying Apple's mobile devices use them in ways that users of other mobile platforms do not, and Adobe will be well aware of this, as will Microsoft, which offers the competing Silverlight technology.

And looming on the horizon is a potential game changer: HTML 5. This as-yet unratified technology is nevertheless being supported in its unratified perform in many browsers. It is vastly more functional than HTML 4. Web developers can display video using it, without having to resort to Flash. They can produce HTML-only pages that enable you to drag and drop anything, and edit any content. This is why Google Wave, the search engine giant's revolutionary new online messaging system, was built in HTML 5. It looks and feels like a desktop application.

HTML 5 cannot claim to do as much as Flash can, but it may do enough. Apple, which itself likes to dominate all aspects of its business, doesn't like it when other companies like Adobe dominate a single part of the online experience. What Jobs may have been imagining when he scrawled through that broken site last week was a world in which it used HTML 5 -- and in which Adobe was increasingly irrelevant.

What does that mean for IT professionals and web developers today? It means that understanding HTML 5 as it develops, and honing your skills in this exciting new technology, might not be a bad bet. As this new decade rolls on, you will find it looking more and more attractive on your CV.

So you need a new Windows application. You fire up Visual Studio, but which project type do you select? Windows Forms application, or WPF application?

Windows Presentation Foundation was introduced at the same time as Windows Vista, with final code released in November 2006 as part of .NET Framework 3.0. It was designed to replace existing Windows graphics APIs such as GDI and GDI+ with a more powerful, flexible and scaleable framework for buiding a graphical user interface, taking advantage of DirectX hardware acceleration and rich graphical effects. If Vista had proceeeded as originally planned, it would probably have been deeply baked into Windows itself, but in the end took a lesser role, presumably for performance reasons. Microsoft also added Windows XP support to make WPF more attractive to developers.

Another goal was to improve designer/developer workflow. WPF uses XAML, a declarative XML language, and is amenable to manipulation through a visual design tool. Microsoft released Expression Blend and Expression Design, which export XAML, as well as supporting WPF in Visual Studio.

Developing a Windows GUI can be frustrating. If you have ever wrestled with dialog units or the impact of "small" vs "large" fonts, you will know how badly scaling is handled. WPF is a huge improvement, with sensible layout management as well as great support for multimedia and effects.

Nevertheless, WPF was slow to take off. Issues included the large memory footprint of a WPF application, deployment of the latest .NET runtime, and lack of pre-built components; in fact, for a long time Microsoft itself advised against using WPF for line of business applications.

There was another factor too. Long-term Microsoft platform users have learned to be cautious about any technology that is not much used within Microsoft itself. WPF was a great example, with little obvious use beyond the Expression tools themselves. In this context, it was fascinating the hear the talk from Principal Software Engineer Paul Harrington at PDC in November, about how Visual Studio 2010 has been rebuilt with WPF. Harrington's team has an advantage over most of us, in that they can press the WPF team to fix bugs and make changes, and that is exactly what happened. Visual Studio needed to use invisible windows for some operations; WPF did not support that, but now now in version 4.0 it does. The text rendering in the new editor was making some developers feel physically ill, apparently, because of its blurry appearance on some systems, so a new text stack was built, enabled by turning off ClearType. The Visual Studio team ran into problems with focus and activation, and new modes have now been added to WPF to fix them.

My guess is that the stress-testing of the Visual Studio team combined with other improvements in WPF, such as new business-oriented components, will make it the sensible choice for a Windows GUI application, other things being equal (which they never are), once Visual Studio 2010 is released.

The big caveat is that developing new applications using a Windows-only API does not look like a smart choice in many scenarios, though it could still make sense within some organisations, or if your application is strongly hooked into Windows anyway. WPF has good support for new Windows 7 features, for example. But Microsoft is also releasing Silverlight 4.0, which has considerable compatibility with WPF but runs on the Mac as well as on Windows, is easier to deploy, and which fits with the web model for data handling. Silverlight 4.0 now has COM support on Windows, when run out of the browser, which means you can add native code if you really need to, and integrate with other applications such as Microsoft Office.

In some curious way then, WPF is maturing to become an excellent development framework at just the wrong moment. Nevertheless, I'd now think twice before hitting the Windows Forms option on a new application.

Why Silverlight makes sense

November 23, 2009 9:00 AM

I'm just back from Microsoft's Professional Developers Conference in Los Angeles, where the star of the show was the latest update to the Silverlight browser plug-in that lets you run .NET applications cross-platform and within the browser. The pace of development is remarkable. It is only 9 months ago that we were first shown the beta of Silverlight 3, at the Mix conference in March. Silverlight 3 was fully released in July; and now we have version 4.0 beta, with release promised for the first half of 2010.

It is a big release too. Many of the top Silverlight feature requests are being implemented, including printing, right-click and mouse wheel support, a rich text control with editing, clipboard support (though text-only in the beta), drag-and-drop, interaction with Webcams and microphones, multitouch control, improved just-in-time compilation for faster performance, and improved databinding for business applications.

In addition, the forthcoming Visual Studio 2010 is the first to have the kind of Silverlight development tools you would expect, with a true visual design surface and drag-and-drop data binding. On the server, WCF (Windows Communication Foundation) RIA Services simplify the effort of authentication, talking to data, and integrating with ASP.NET.

Another notable feature is the ability to run a Silverlight application out of the browser, started from a desktop shortcut and displayed in a custom window. New in version 4.0 is an HTML control, which embeds IE on Windows and WebKit (used in Safari) on the Mac. These are desktop/web application hybrids. Silverlight 4 blurs the boundaries, by adding a new trusted mode. Subject to the user passing a security dialog, a trusted out-of-browser application gets local file access to user data, cross-domain network access, and on Windows native code interop through COM automation.

The snag with this last point is that any Silverlight application which uses COM automation will only run on Windows, breaking the cross-platform compatibility which is a key reason to use Silverlight in the first place. Although Microsoft says the feature has been put in simply to meet the requirements of a few Enterprise customers, it seems to me that it goes well beyond that, making Silverlight viable in many scenarios that previously would have required a native solution.

Microsoft's ideal scenario is one where applications run everywhere, but run best on Windows, preserving its desktop lock-in. The company calls this "lighting up the platform"; but Windows is somehow the only platform that gets lit up.

I still think it is time to learn Silverlight. The reason is not only Microsoft's signposting of this as its key technology for future client development, but something else I saw last week: Google's Chrome OS. I'll be writing more about this; but I was impressed by how this forthcoming browser-based operating system promises to solve long-standing problems: cheap, lightweight computers that are secure, that start up instantly, that give us access to all our data, but can be left in the back of a taxi without compromising our secrets.

What if Chrome OS catches on? Does Microsoft become irrelevant? The real world does not move that fast; but considering the continuing popularity of the Mac along with the prospect of Chrome OS, it strikes me as brave to presume a Windows-only client for future development. Silverlight on the other hand should run in Chrome OS, either using Mono's Moonlight, or the Intel port being done for Moblin, or perhaps Microsoft itself will have to dirty its hands with Linux. Google might block Silverlight - it was non-committal on the subject at the Chrome OS press briefing - but I'm guessing that concerns over appearing excessively controlling will trump the desire to shut out a competitor.

The point here is not that Silverlight is the answer for all client development; there are plenty of other strong choices. The point rather is that for Microsoft platform developers Silverlight is the technology that makes it possible to take your C# or VB.Net skills and transition them to a new cross-platform, web-oriented world.

At Microsoft Tech-Ed 2009 in Berlin long-time Windows server expert Mark Minasi gave a session on the .vhd format used by Microsoft for virtual hard drives in Hyper-V, the virtualisation feature built into Windows server 2008.

Minasi's talk was not about Hyper-V, but rather about other things you can do with a .VHD. He even noted that in a Windows environment you can use a .VHD as a superior form of ZIP (though without the compression), if you want a single file that can contain windows files and folders while preserving NTFS security attributes, and that can be mounted - or "attached" in .VHD jargon - rather than having to be extracted elsewhere.

One neat trick is to use .VHDs for multi-boot. Multi-boot is less important now that virtualisation works so well, but can still be useful if want to test an operating system with full performance and access to hardware such as accelerated graphics. The old way to do this is with multiple partitions, but this is somewhat inconvenient. Windows 7 is able to boot from a .VHD, and you can set up mutiple VHDs so that you can choose which one to use at start-up. There are a couple of limitations. The operating system has to be Windows 7 or presumably 2008 R2 (which uses the same kernel); and sleep/hibernate does not work in this configuration.

A VHD is still just a file, so you can back it up by copying it elsewhere, provided it is not the one currently running. Note that in this configuration only the hard drive is virtual, not the computer hardware, so while you could go on to mount the VHD in Hyper-V it would be like moving Windows to a new motherboard and very likely would not boot.

Another clever tip is that Windows 7 setup support a keystroke combination, Shift F10, which gives access to the command line for MinWin, the cut-down version of Windows that runs during setup. Here you can get access to Diskpart, the command-line disk management tool, which among other things lets you create a VHD. So you can take a machine with an untouched hard drive, boot into the Windows 7 setup, shell to the command line and create a VHD, then attach and install Windows onto that new virtual drive. Setup actually states that this does not work; but it does work, and we saw it demonstrated.

There are three kinds of VHDs. A fixed VHD has the same on-disk size as its capacity. An expanding (or dynamic) VHD reports the size that you specify when it is greated, but only occupies the space on its host that is needed by the data written there. This is convenient for backup, and lets you over-commit the host drive if you choose to. The third kind is a differencing VHD - a VHD that is based on a parent and only occupies the space needed by its difference as you write to it. The GUI Windows disk management tool does not support creation of differencing VHDs: one of Minasi's points is that you should learn the command line approach using Diskpart in order to get access to all the available features. That said, differencing VHDs are supported in the Hyper-V GUI management tool.

The bottom line is that VHDs have uses that go beyond virtual machines and if you work on the Windows platform it is well worth becoming familiar with them.

At the Future of Web Applications conference earlier this month I spoke to Microsoft's corporate VP of the .NET Developer Platform, Scott Guthrie about ASP.NET MVC. Guthrie is a co-inventor of ASP.NET along with Mark Anders, now at Adobe. A few months back I wrote a piece entitled ASP.NET MVC rescues Microsoft's web platform, but I wanted to hear from Guthrie how he sees the framework evolving, and to explore whether it is time to abandon the older Web Forms approach. How does he see the future of the platform?

"The amount of buzz and religious fanaticism about [ASP.NET MVC] is amongst the highest I've been involved in, certainly since .NET 1.0 and Silverlight. Some people prefer the Web Forms model  and I emphasise that Web Forms is not going away, there's all the new stuff that's coming for Web Forms 4.0.

"MVC is an alternative way to do UI and still leverage ASP.NET. For crowds like the one here at FOWA that wants total control over the markup, and who like test-driven development, it's a dream framework. Those folk tend to be more online, so they communicate better which is part of the reason you hear the buzz. I think we'll have more than a million developers using ASP.NET MVC within the first twelve months."

In your talk you mentioned the stackoverflow site which performs very well but runs on not very much in terms of hardware? Is ASP.NET MVC more efficient than Web Forms?

"ASP.NET itself has always been really fast, we've had a lot of success with large sites. One of the things people like about ASP.NET MVC is that the model fits to what they are expecting, for the large LAMP contingent which is heavily represented at this conference.  And when they do the performance testing they say 'Holy cow, this thing is fast.'  Stackoverflow is a great example, written I think within three weeks and scaling to that level with two machines. Performance is a feature, and one of the reasons StackOverflow works as well as it does is that it's instantaneous response time.

"Conchango just did a site, implemented in 20 weeks, a giant ecommerce project, it's 100% ASP.NET MVC. The SEO is phenomenal, the YSlow rating is phenomenal, they're just blown away. It was fun talking to them last night - the guy was jokingly saying, 'I can't believe it works so well'. It's like the best marketing literature in the world times ten. More and more when I give talks I'd say half the people are new to ASP.NET MVC, and the other half come upand say, 'by the way we've done five sites on it.' That's great to hear."

On equivalent hardware and leaving aside different coding styles, is ASP.NET MVC going to scale that bit better than Web Forms?

"No. The reality is you can build hugely scalable sites with each. Where it does help a little bit is that there is smaller page size and there's a bit more control. There's less abstractions."

And the page lifecycle is shorter?

"It is shorter. I don't think that's making any measurable perf difference. It's more that it naturally flows to what they're doing. I do think it's fast, in the same way that web forms can be fast too. But it promotes a certain way of working that, if you know what you're doing, you tend to build really fast apps."

What about the open source aspect? Are people contributing code?

"People are not contributing code directly to ASP.NET MVC, but we're shippling JQuery and we're shipping JQuery validation which are open source projects, and we are integrating them into our code. With JQuery in ASP.NET MVC version 1.0 we just shippped it, whereas in version 2.0 we have helper libraries that are making big usage of it.

"I'd say that's a first for Microsoft, we're actually taking open source software that has multiple contributors, and using it in a deep way within our own product.

"We ship the ASP.NET MVC source code under an OSI Licence. You can take the code, you can modify it, you can do builds. I know a few people that have done customer tweaks, but for the most part it's that people like being able to learn the product through the code. There's also the reassurance of knowing that if they ran into something, they could fix it."

Would you consider accepting community contributions to the code?

"We've thought about it. I think a lot of people interpret open source as 'hey, anyone can just submit stuff'. The reality is that pretty much every open source project has a closed set of contributors. They come from multiple organisations or backgrounds, but you don't check anything into the Linux kernel without Linus or Andrew signing off on the fix. That would be true of ASP.NET MVC, in that there would be a core set of contributors. At some point I think we will probably open it up to let people to contribute code, or at least patches."

What's new in the latest ASP.NET MVC 2.0 preview?

"The ability to easily do forms validation for input, server-side and especially client-side in a very declarative, easy way, is a huge productivity win.

"'Areas' provide a way to take a large project and easily structure it into multiple small projects.

"New form helpers and what we call editor and display templates for customising them  is an innovative way to get strong typing, intellisense and debugging support, and a lot of flexibility in terms of UI generation.

"Asynchronous controllers allow you to call call services on the web, the Twitter, the Facebooks of the world, and  much more efficiently  scale your web server. The classic problem if you're calling Twitter is what's the response time of Twitter? What's the response time of Facebook? Most web servers are multi-threaded so they're processing multiple requests, but say they have 10 threads running and 15 requests come in, and each of those requests need to go and access Twitter, you're going to block 5 people while nothing is going on on the server. With the Async support we provide a way that you within your app can say, I'm going to wait for a while, yield back the thread, and when the data comes back reschedule me. It can dramatically improve the scalability of the site.

"We're doing a bunch of work around helpers for caching, paging, and a other things. In general it's a compatible release, we're trying to listen to the community, keep it a very transparent, Agile-based development process and knock off the top asks.

"We ship the source to every preview, take lots of feedback. That's the other thing people have really liked about the project, this open feedback. They don't feel like we're telling them, here's the way it is, take it or leave it. They like the fact that we've been iterating with them."

Guthrie is diplomatic about the question of Web Forms versus ASP.NET MVC, and even though I pressed him, would not quite agree that it performs much better. Clearly Web Forms is not going away. Take a look though at some of the comments from practitioners like Howard van Rooijen of EMC (formerly Conchango):

One of the great aspects of ASP.NET MVC is how lean and clean the architecture is - there is so little background noise compared to WebForms; possibly the best illustration of this is the difference between the MVC Request Pipeline vs. WebForm Page Lifecycle. The number of hoops you are forced to jump through in WebForms, compared to MVC is quite staggering.

Overall I heard nothing to change my general opinion, that if you can use ASP.NET MVC rather than Web Forms, you probably should.

Mobile devices are today's development battleground. Timing is everything: I recall Borland's 2003 conference when it introduced an extensive mobile development strategy based on the ill-fated C++ BuilderX, with SDKs from Nokia and Symbian. The sessions drew sparse attendance and Borland later abandoned the product, returning to the Windows-oriented C++ Builder.

So what changed? In part, devices have become more powerful and mobile internet access faster and more pervasive, making the platform more attractive. A bigger factor though is Apple's iPhone. In hindsight, the mobile vendors and operators made mobile development too difficult, with fragmented platforms and locked-down devices. Microsoft has had some success extending Windows to mobile devices, for enterprise development in either C++ or .NET, but its market share is too small, the devices insufficiently well liked, and the deployment obstacles too great. Java had some success too, but write-once, run anywhere never really worked for mobile.

Enter iPhone, with a single platform and easy deployment through the App Store. The "easy deployment" part has to be qualified, since developers have been confronted with limited access to the device, restrictions on what they can develop, and an opaque approval process; but it has worked, and the potential of the mobile platform - about which we have known for years - is now being unlocked.

Other vendors are belatedly rising to the challenge. I'm just back from Nokia's Qt Developer Days, and saw the energy the company is putting into creating a cross-platform, open source mobile development framework. Windows Mobile, Maemo and Symbian are on the immediate roadmap. On the deployment side, Nokia has the Ovi store. I've also been at Adobe's MAX in Los Angeles, where broad mobile support for the Flash runtime was the big story. The Flash runtime is not coming to iPhone yet, but Adobe has a native compiler for Flash applications which targets iPhone. Adobe also has app store plans. Google Android is another platform where all the pieces are in place, and Palm Web OS a new hopeful on the scene.

This means developers now have numerous choices for mobile development, as well as more pressure to create or extend applications to embrace mobile clients. It is not an easy choice. An AJAX application will work on the iPhone and elsewhere, but there is no offline support or access to device features, and the capabilities of mobile browsers vary greatly - though Webkit is becoming a standard on non-Windows devices. Native iPhone works great on Apple's device, but nowhere else. Flash is becoming interesting, but devices with 10.1 will not be around until next year and it is an unproven platform in a mobile context. Windows Mobile will trudge on, though Microsoft's mobile story seems particularly incoherent at present and I expect declining market share. Java on mobile has not gone away either; and Google Android is pretty much a Java platform. C++ will always be attractive for lean, fast applications.

It is fun to pick winners and losers, but impossible to tell how all this will shake out. Here's two safe bets. The first is that mobile, internet-connected applications are in many ways the future of the client. The second is that focusing on a strong web services API (of whatever flavour) is the right place to start. What's your mobile strategy?

I attended a round table to discuss the use of open source software in government, with Red Hat, Ingres, Alfresco, and on the government side representatives from the Office of National Statistics and Islington Council.

It is a fascinating topic on several levels - and not just for government. The two big questions: first, what is the rationale for prefering open source; and second, if you are convinced of its desirability how on earth do you get a huge, diversified entity like the UK government to increase its adoption?

There is clearly some kind of disconnect. The government already has a policy which stops short of mandating open source, but does say:

Where there is no significant overall cost difference between open and non-open source products, open source will be selected on the basis of its additional inherent flexibility.

In other words, given two otherwise equal proposals, open source is favoured - yet in practice we were told that 95% of software in use in the UK government remains proprietary.

So why is that? There are dozens of reasons. It's the available skills, with armies of experts in Microsoft, Oracle, IBM, and so on, compared with only a few willing to specify open source technologies. It's the culture, with countless existing supplier relationships and a well-trodden procurement path with the usual suspects. It's the existing envirnonment: if you start from a point where the servers are Windows, say, and the desktops all have Microsoft Office, it feels more comfortable to continue down that path. It's the lock-in, especially when it comes to things like proprietay SQL extensions and stored procedure languages, that simply do not port easily to new database managers. And it's canny vendors, who go for site licences with the widest possible scope, so that if a small group decides to break the mould and use something different, it looks more like a cost than a saving - because they are already licenced for the proprietary stuff.

These are tough obstacles to overcome. Put another way, the rationale for adoption has to be exceptionally strong to overcome the inertia; and it was here that I found the round table unconvincing. The open source companies gave diverse reasons for the benefits. Lower cost was mentioned frequently. By contrast, John Powell, President and CEO of Alfresco, talked intensely about how the UK was somehow handing over its soul to silicon valley, by not building up local skills in open source software. Someone else said how nice it was that open source software was free so that everyone in an organization could use it; another gently observed that since most open source companies make their money from support agreements that are per user, this is often not the case.

The most persuasive rationale is that open source software tends to support open standards and therefore avoids lock-in. This lowers long-term costs, by ensuring that the customer always has freedom to switch.

The snag with all these arguments is that the proprietary companies can counter them easily. They will reel off all the open standards they support. They will draw graphs showing how much money you save by using their stuff. They will point out that those with skills in their technology can easily market them worldwide. The outcome is that nothing changes.

I don't doubt that leading vendors make excessive profits on software that should be commoditised and cheap, or that vendors follow strategies designed as much to keep us hooked on their stuff, as to advance technology for our benefit. It's a cycle that needs to change.

At the same time, the open source vendors have to recognize - and to be fair, I reckon they often do - that most of us will not switch for ideological reasons. We want to get our work done. The best open source projects, things like the Apache web server (if there is anything like it) succeed on sheer quality and reliability, not merely through being open source.

The tough question: does the open source ecosystem have sufficient resources to deliver that quality, against proprietary vendors with huge profits to pour into research and development? There are plenty of decent open source products; the number that are truly best of breed is more limited. Currently it is the big proprietary vendors that have the advantage.

I left the table with more questions than answers. Should governments introduce more draconian legislation, to counterbalance the industry bias towards the status quo? Will the move towards cloud computing break the pattern? Should legislation be focused on mandating standards support, or even that applications should be proven to work on two different platforms, rather than the matter of open versus closed source? If today's MySQL is tomorrow's Oracle, is there really any difference? Isn't there too much to worry about already, solving problems and delivering successful projects?

If pressed, I would always incline towards the best technical solution, rather than one which ticks boxes, even open source boxes. That said, we are all susceptible to being bamboozled, not even looking at open source alternatives if we already know a proprietary tool or component or platform that will do the job. Even for individual developers, it makes sense to choose the open source solution in cases where other things are equal; and to think twice before building vendor lock-in into the applications we create.

Tech media pundits talk incessantly about migration to the cloud, but it is always interesting to get reports from the trenches. Two recents ones interested me. The first is from Patrick McKenzie, who sells a niche Java application. He's just posted a detailed and entertaining blog entitled Why I'm Done making Desktop Applications. His application exists in both desktop and online versions, and he says he was a staunch defender of the advantages of desktop apps - "You can keep your Google Docs, Excel is superior in almost every way." Then he made an online version of his app with if anything fewer features, and tracked the statistics. He discovered the following:

  • More visitors to the site tried the web application rather than downloading the desktop version (26% vs 22%).
  • A higher percentage of the web app users made a purchase (2.32% vs 1.35%).
  • Desktop users made five times as many support requests - calculated from the figures he gives for the last 50 requests.
  • His web application is not afflicted by piracy.
  • He gathers reliable usage stats from his web application which he cannot get for the desktop version, enabling him to improve the user interface.

His conclusion:

The next major release will almost certainly be its last. The webapp, and my future webapps, seem to be much better investments.

Does any of this apply to corporate development? It's true that life is easier in some ways if you do not have to make a sale; and there are still some things that desktop applications do better, like integrating with Microsoft Office through COM automation, or continuing to work offline on the train or plane - though see Rails creator David Heinemeier Hansson's You're not on a plane for a contrary view.

Still, many of the other factors do apply. Lower support requests, zero installation, accurate usage monitoring - all these things have immediate financial benefit.

It is no longer web application developers who have to justify their case, but rather those who still advocate desktop development.

If you need any further persuading, take a look at this survey of 1400 Microsoft's small business customers by Accredited Supplier. Apparently 62% prefer business applications that work through a browser, and only 18% prefer desktop applications. The more chilling news for Microsoft is that 13% actively intend to switch to Google Apps - with all that implies for sales of Windows server, Exchange, and Office - while only 36% are sure that they are not switching.

All that cloud talk is translating rapidly into business decisions. I'm not sure whether the future of the business application client lies more with AJAX and HTML 5, Microsoft Silverlight, Adobe Flex, or something else; but for sure it is not a desktop technology.

It is one of the dirty secrets of software development: the number of memory leaks that find their way into production code. Memory leaks are a special category of bug because they can easily go unnoticed. The user's perspective is that they start work using your application and everything is fine. If it is an application that is used lightly, maybe run once every morning to create a report, than everything is fine for ever. If it is a long-running application then eventually it will cause problems, though the user may not know which bit of software is to blame. Since Windows rarely runs out of memory, the user might just notice everything slowing down. It is one of the reasons why restarting Windows from time to time tends to be beneficial.

The huge amounts of RAM in today's machines disguise memory leaks. An application can leak a little bit of memory with every operation, and still run fine for ages. That's not good though; and the migration to web applications makes the problem worse. Web applications tend to be exercised heavily for long periods, which means memory leaks are more likely to have severe consequences.

Although garbage collection in the .NET Framework is meant to relieve developers of the burden of memory management, the reality is a little different. In some respects managed code is more prone to memory leaks than unmanaged code. The problem is that the garbage collector will only free objects for which no valid references exist, and it is easy to maintain such references inadvertently.

So how do you find these guys? You observe memory usage externally with a utility like Sysinternals Process Explorer, or write your own tests with code such as calls to GC.GetTotalMemory, or use a dedicated tool. There are performance tools built into some versions of Visual Studio, which can be configured to do .NET memory profiling, though making sense of the reports takes some effort. If you want to try this in Visual Studio 2008, open the Performance Explorer, right-click a Performance session, and check the boxes for .NET memory profiling collection. This can be useful, though I'm going to suggest a third-party tool which is modestly priced and more productive: Scitech .NET Memory Profiler. Others worth investigating include Micro Focus DevPartner Studio (which does far more than just memory profiling) and Rational Purify Plus.

Here is a quick example. Let's say I'm writing a VB.NET Windows Forms application. I have a main Form1, and a second Form2 which I create and display as needed. I want to have the second form respond to events on the main form, so in Form2 I declare a reference to Form1, which I set when Form2 is displayed:

Private WithEvents mainForm As Form1

Using the Visual Studio editor I hook up an event handler for mainForm.

Everything works fine, until a user complains that the more she uses the app, the more her machine slows down. What's the problem? Well, if you run the Performance Explorer with memory profiling enabled, you might notice something odd. Run the app, and display and close Form2 three times over. The report tells us (among many less useful things) that there were three instances of Form2 created, and that all three were alive at the end. We've found a memory leak.

 

What's the problem? You can guess that it is something to do with the reference to Form1. The Scitech memory profiler easily identifies the exact problem. In order to find it, run the application in a Memory Profiler session, then immediately choose Collect Heap Snapshot. Open and close the three instances of Form2, then again Collect Heap Snapshot. Finally, filter the view to show new or removed instances only. You can see that the number of instances of Form2 is now 3, where it should be 0. Double-click this line in the report to see a list of instances, and double-click the first to see the references to it that are preventing it from being garbage-collected. Although there are several of these, only one really matters, which you can find by checking the option Only show instances included in root paths. The culprit is an instance of System.EventHandler.

 

You can actually fix this memory leak without changing the way the app works. Remove the handles clause from the event handler for the mainForm reference, and replace it with a manual event hook-up in the Form2 constructor:

AddHandler mainform.Click, AddressOf mainform_Click

Then, override Dispose and manually remove the event handler:

RemoveHandler mainform.Click, AddressOf mainform_Click

Try the application again under a profiler, and you'll see that the problem has disappeared, and no instances of Form2 remain in memory after it is closed.

No doubt there are other, better ways to code this application; but it illustrates the troubleshooting process.

The reason this kind of leak is so troublesome is the chain effect. If a form remains in memory, so too do all the objects referenced by that form, and so on. Unfortunately there are occasionally bugs in the Framework itself that make this hard to avoid - see for example this post by the author of Memory Profiler, Andreas Suurkuusk, where he tracks down a problem with the toolstrip control.

I'd argue that .NET applications of a significant size are more likely than not to have some memory leak issues, and that a tool like Memory Profiler is near-essential for troubleshooting them.

I've been mulling over the implications of the news that Sun's JRuby team leaders, Charles Nutter and Thomas Enebo, are leaving Sun because of uncertainty about the future of their project after the Oracle acquisition. They will be joining Rails specialist Engine Yard. This is the key quote from Nutter:

To be honest, we had no evidence that Oracle wouldn't support JRuby, but we also didn't have any evidence that they would.

JRuby is by all accounts excellent - I'm aware that developers at ThoughtWorks use it, and Ruby advocate Martin Fowler (who works there) told me that it works very well for them, observing that some enterprises who would be reluctant to deploy the native Ruby runtime are more comfortable with running Ruby applications on the JVM (Java Virtual Machine). It is foolish of Oracle to let the JRuby guys slip away, particularly bearing in mind the trend towards dynamic languages (like Ruby) rather than static-typed languages (like Java).

What does this suggest about the future of Java itself under Oracle's stewardship? If Oracle could have done more to reassure Nutter of its continuing commitment to JRuby, so too it could do more to reassure the rest of us that investment in Java and its community will continue as strongly under Oracle as it did under Sun. Maybe it will, maybe it won't; though culturally I suspect the new company will be averse to Sun's habit of investing heavily in projects with little obvious potential for direct revenue. The failure to monetize Java fully, along with the failure of its bold experiment in open source, is one reason for the acquisition itself.

That does not imply that Java will go away - Oracle itself is a heavy user, and defending its future was likely a factor in its willingness to purchase Sun. Still, it would not be surprising if the community is a little less warm, and Oracle's investments more focused on its own needs rather than those of the wider platform.

Despite Oracle, there is no reason to be gloomy about Java's future. There is another way to look at the move of the JRuby team, which is that they've found a way to continue working on the project with or without Oracle's support. Java is bigger than Oracle, just as it was bigger than Sun. 

IBM worked tirelessly to free Java as far as possible from Sun's control, developing its own JVM and creating the Eclipse tools project to foster alternative tools and frameworks. Those efforts will have a new context and relevance.

Maybe Oracle will do great things for the Java platform. Maybe it will do little, and momentum will shift to those outside the home company. Either way, investment in Java development is as safe as anything can be in our uncertain industry.

 

 

Current Vacancies from CWJobs

(* Required field)










Preferred format
   
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4