Category Archives: software development

Microsoft .NET gotchas revealed by Visual Studio team

The Visual Studio Blog makes great reading for .NET developers, and not only because of the product it describes. Visual Studio 2010 is one of the few Microsoft products that has made a transition from native C++ code to .NET managed code – the transition is partial, in that parts of Visual Studio remain in native code, but this is true of the shell and the editor, two of the core components. Visual Studio is also a complex application, and one that is extensible by third parties. Overall the development team stressed the .NET platform, which is good for the rest of us because the developers are in a strong position both to understand problems, and to get them fixed even if it means changes to the .NET Framework.

Two recent posts interested me. One is Marshal.ReleaseComObject Considered Dangerous. I have some familiarity with this obscure-sounding topic, thanks to work on embedding Internet Explorer components. It relates to a fundamental feature of .NET: the ability to interact with the older COM component model, which is still widely used. In fact, Microsoft still uses COM for new Windows 7 APIs; but I digress. A strong feature of .NET from its first release is that it can easily consume COM objects, and also expose .NET objects to COM.

The .NET platform manages memory using garbage collection, where the runtime detects objects that are no longer referenced by active code and deletes them. COM on the other hand uses reference counting, maintaining a count of the number of references to an object and deleting the object when it reaches zero.

Visual Studio 2008 and earlier has lots of COM APIs. Some of these were called from .NET code, and for the same of efficiency called the method mentioned above, Marshal.ReleaseComObject, to reduce the reference count immediately so that the COM object would be deleted.

Now here comes Visual Studio 2010, and some of those COM APIs are re-implemented as .NET code. For compatibility with existing code, the new .NET code is also exposed as a COM API. Some of that existing code is actually .NET code which wraps the COM API as .NET code. Yes, we have .NET to COM to .NET, a double wrapper. Everything still works though, until you call Marshal.ReleaseComObject on the doubly-wrapped object. At this point the .NET runtime throws up its hands and says it cannot decrement the reference count, because it isn’t really a COM object. Oops.

The post goes on to observe that Marshal.ReleaseComObject is dangerous in any cause, because it leaves you with an invalid .NET wrapper. This means you should only call it when the .NET instance is definitely not going to be used again. Obvious, really.

Once you’ve digested that, try this illuminating post on WPF in Visual Studio 2010 – Part 2 : Performance tuning. WPF, or Windows Presentation Foundation, is the .NET API for rich graphical user interfaces on desktop Windows applications. Here is an example of why you should read the post, if you work with WPF. Many of us frequently use Remote Desktop to run applications on remote PCs or PCs that do not have a screen and keyboard attached. This is really a bad scenario for WPF, which is designed to take advantage of local accelerated graphics. Here’s the key statement:

Over a remote desktop connection, all WPF content is rendered as a bitmap. This is in contrast to GDI rendering, where primitives such as rectangles and text are sent over the wire for reconstruction on the client.

It’s a bad scenario, but mitigated if you use graphics that are amenable to compression, like solid colours. There are also some tweaks introduced in WPF 4.0, like the ability to scroll an area on the remote client, which saves having to re-send the entire bitmap if it has moved.

Nokia Maemo, Intel Moblin gives way to MeeGo

Nokia’s Maemo operating system, a Linux distribution for mobile devices, is being merged with the Intel-sponsored Moblin distribution to form MeeGo, under the direction of the Linux Foundation:

MeeGo combines Intel’s Moblin and Nokia’s Maemo projects at the Linux Foundation to create one open source uber-platform for the next generation of computing devices: tablets, pocketable computers, netbooks, automotive IVI and more.

says the Foundation’s Jim Zemlin.

Watching the joint Intel and Nokia interview it seemed to me that this is more Maemo than Moblin, especially since Nokia’s Qt framework and Qt Creator IDE is mentioned as the primary application development platform for MeeGo.

The most significant factor is that Intel and Nokia will now be backing the same mobile OS. You would expect this to have an impact, though I guess the move is an attempt to win back mindshare that has gone to Android, the up and coming mobile OS from Google.

Although both Android and MeeGo are based on Linux, the Android OS has a completely different development model based on Java rather than C/C++.

XML literals come to PHP via Facebook: XHP

Facebook engineer Marcel Laverdet has written up the XHP project on which he has been working at Facebook, and which he says is “quickly becoming a cornerstone of front-end PHP development at Facebook”. XHP enables XML fragments to be valid PHP expressions. In addition, most HTML elements have been pre-defined as variables. The project is hosted on github and you can read a quick summary here. PHP inventor Rasmus Lerdorf has had a quick look and says:

The main interest, at least to me, is that because PHP now understands the XML it is outputting, filtering can be done in a context-sensitive manner. The input filtering built into PHP can not know which context a string is going to be used in. If you use a string inside an on-handler or a style attribute, for example, you need radically different filtering from it being used as regular XML PCDATA in the html body. Some will say this form is more readable as well, but that isn’t something that concerns me very much.

Lerdorf goes on to express concern about performance, but says that in combination with APC caching it is much better, and with HipHop compilation to native code becomes “a viable approach”.

One of the benefits here is that getting XML markup out of quoted strings means that it can be checked as it is parsed, so that errors are caught earlier. There are parallels with Microsoft’s work on Linq (Language Integrated Query) which pulls database queries into the language, and XML literals in Visual Basic 9.0. Ideally, developers should not have to hide code such as SQL, XML or Javascript within strings that are not checked for valid syntax until runtime.

This might also re-ignite the debate about whether XML literals should be in C#, now also gaining more attention because of the popularity of ASP.NET MVC.

Visual Studio 2010 RC arrives with go-live license

Microsoft has made the Release Candidate of Visual Studio 2010 available for download to MSDN subscribers. From tomorrow (10th February) the same release will be available to everyone. There is a go-live license so you can use this in production if you wish, though if the full release comes in April as planned, it hardly seems worth it in most scenarios.

What’s new since the beta? Jason Zander says mainly performance. Note that the Chief Architect of Visual Studio is Rico Mariani, formerly Microsoft’s .NET performance guru, which is encouraging in this respect.

The blow-by-blow account of issues with the RC is here.

Whatever your views on the direction and future of Microsoft’s platform, there’s no doubting the huge scope of this release, though in my view the company has not communicated this particularly well, saying too much about things like SharePoint development, top of its list of walkthroughs but still an ugly business, and not enough about features such as IntelliTrace debugging, or the new ability to float windows out of the IDE and onto a second display, which will have a more immediate impact on developers. Note that the Visual Studio IDE has been re-built using WPF (Windows Presentation Foundation), and that it comes with a the first completely new version of the .NET Framework since 2005.

Silverlight 4.0 is another area of interest, though I understand that it will not be complete in time for this release. Visual Studio 2010 will have Silverlight 3.0 out of the box, with the ability to install the 4.0 preview release and eventually the final release as an add-on. I’ve also heard that Silverlight 4.0 is not yet supported at all in the RC, so be cautious if this is your area of work – you may need to stick with the last beta for the moment.

New is not always better, of course. I’m interested in hearing from developers working with Visual Studio 2010 – whether performance and stability issues have been overcome, and what you think of it overall.

Palm Ares: an online IDE for WebOS development

I spent a few minutes trying out Ares, Palm’s web-based IDE for WebOS, the OS used in the Palm Pre smartphone.

Ares is in public beta and I’m not going to pretend I found it smooth going. No doubt it will be fine after a little patient learning. It is amazing, with drag-and-drop visual interface builder, code editor, source code management, debugger, and logging.  Microsoft’s Internet Explorer is not supported in any version; you need Mozilla Firefox 3.5 or higher, Apple Safari 4.0 or higher, or Google Chrome 3 or higher.

image

The online IDE uses a bit of Java but seems to be mostly HTML and Javascript. If you try to launch the application, you need a Palm emulator running locally, but you can preview in a browser without any local dependencies.

In order to try Ares, you have to sign up for Palm Developer Center. As part of the process, it appears that you have to give Palm permission to charge fees to your PayPal account, which I disliked, though membership is free for the time being. Of course you hope that any fees will be more than offset by the steady chink-chink of income from your app sales.

Is this the future? My immediate reaction was to be very impressed; a little further in and I was greatly missing the comfort of Eclipse.

Still, this stuff will get better; and the idea of just browsing to an URL to continue development is compelling.

Pros and cons of Adobe’s LiveCycle services in the cloud

Adobe has fully released LiveCycle Managed Services, offering a hosted platform for LiveCycle applications. The software is configured and managed by Adobe, but runs on Amazon’s EC2 (Elastic Compute Cloud) virtual servers.

LiveCycle is a suite of applications which I think of as two things combined. On the one hand, it forms a server platform for business process or workflow applications based on Adobe PDF forms and documents. On the other hand, it provides data services for Rich Internet Applications, usually but not necessarily to client applications on the Flash runtime, either in or out of the browser. It is a little confusing, but these two aspects are essentially the old Adobe Enterprise platform merged with Macromedia’s work in support of Flash, combined into one suite after Adobe’s takeover of Macromedia in 2005.

The usual arguments in favour of hosted services apply and this is a smart move from Adobe. Still, customers are currently forced to use Amazon for the actual virtual servers, even though others such as Rackspace Cloud Servers are substantially cheaper than Amazon EC2. Is that a problem? According to Adobe’s John Carione, senior enterprise product marketing manager at Adobe, “when we were evaluating vendors, we think that one of the areas Amazon excels in is around security.” I noticed that the security topic also occupies around one-third of this introductory video, suggesting that this remains a significant barrier to adoption for many potential customers.

So how will managed LiveCycle work? “We’re providing a fully managed service, and part of that is going to be delivered with what we’re calling  the Adobe Network Operations Center … which is going to provide 24×7 monitoring of the applications, backup and recovery, upgrades. They’ll be one contact at Adobe to talk to about everything,” says Carione. Apparently the Network Operations Center is based on a piece aquired with Omniture last year. Ominiture was a web analytics business which was based on hosted applications and services; maybe that was an important factor driving the acquisition.

When I asked Carione about ease of scaling, I got a slightly defensive answer. “This is a v1, we have the opportunity for customers to buy additional instances. In the future we’ll have more of that dynamic scaling.” Another issue is integrating with on-premise resources such as databases and directory services, which Carione says is a matter for business integrators; in other words, a significant challenge. And what if Amazon goes down? Carione did not answer directly, but said that 99.5% uptime is guaranteed.

What’s new in Visual Studio 2010 – more than you may realise

I’m beginning to think Microsoft has under-sold Visual Studio 2010. Of course it is a huge product, as I observed back in October, especially since it includes a major new release of the .NET Framework as well as updated tools, but I thought I had discovered most of the significant new features. Still, when I sat down recently to write up an extended review, I found a lot that I had missed.

One of my reflections on this is that Microsoft has done of poor job of communicating what is new. I attended the Professional Developer’s Conference in 2008 and 2009. The developer-focused keynote on the second day last November should have hyped the best of what is new; but instead we got Steven Sinofsky on Windows 7 quality control – hardly the most exciting of topics – a sneak preview of IE 9, an unconvincing tour of Sharepoint and Office 2010, and Scott Guthrie on Silverlight 4. Guthrie was fantastic, leading us blow by blow through Silverlight’s new capabilities, but much else was neglected.

It doesn’t help that Microsoft’s home page for Visual Studio 2010 has meaningless headlines. “Set your ideas free”, “Simplicity through integration”, “Quality tools help ensure quality results.” Pure fluff, which saps your will to read further.

Here are a few things that I found interesting – nothing like comprehensive, just features that perhaps have not had the attention they deserve.

Microsoft F# – a new language from Microsoft Research, integrated into Visual Studio with remarkable speed. The people I’ve spoken to who have taken the time to discover what it does are truly enthusiastic. Some of its strengths are parallelism, asynchronous programming, graphics manipulations, and maths. You probably won’t write a complete application in F#, but it will be great for assembling libraries.

Windows Workflow Foundation 4.0 – potentially a new and effective approach to visual programming and long-running state management. Flow charts are often used to teach programming, since they express common concepts like if conditions visually. WF lets you draw a process as a flow chart – or there are other types of chart – using the nice new WPF design tools, and then execute it in the runtime, which is part of the “Dublin” extensions to IIS, now known as Windows Server AppFabric (I have no clue why this confusing name was chosen). To get the idea, I suggest reading David Chappell’s Workflow Way. For applications that fit this kind of model, it is a compelling approach, and integrates well with Windows Communication Foundation for messaging.

Dotfuscator – I know this is a third-party thing, but this is no longer just a tool for obscuring your .NET assemblies in the hope of preventing decompilation. The new Dotfuscator does runtime analytics, and can report back to a portal when your application runs, what features you use, what operating system it is on, whether it crashed, and so on. It also supports application expiry, known as “shelf life”, and can detect if assemblies have been tampered with. Some of this sails close to the spyware wind, but this is a matter of getting informed user consent. These are interesting features for Windows desktop developers, if there are any left, and even the free edition is quite capable.

Test and Lab management – a challenge to set up and configure, but when it works, amazing. Lab Management uses Visual Studio, Hyper-V and System Center Virtual Machine Manager to automate deploying an application over one or more VMs, so you can run tests against it. This hooks into Team System so you can file a bug report with a link that actually shows the bug happening at runtime, with a snapshot of the virtual environment.

Step backwards through code – IntelliTrace is a new feature of the Visual Studio debugger. Configure it to collect IntelliTrace events and call information, and you can then step backwards as well as forwards from a breakpoint, examining variable values as they change.

Team Foundation Server Basic – what this means is that even a solo Visual Studio developer can have TFS running locally or on a networked machine for source code management, issue tracking and so on. It’s worth considering because of the way it integrates with the IDE. I admit, I still like Subversion which I have on a remotely hosted server, since it acts as an effective off-site backup, but I’d much rather use TFS Basic than nothing.

UML – Microsoft has finally done what it should have done years ago, and implemented a wide range of up-to-date UML diagram tools. Nothing revolutionary, just useful.

Not everything is wonderful in the new Visual Studio. Deploying to Azure remains clunky in Beta 2 – when is this going to get better? SharePoint is another one; I appreciate the value of F5 debugging, but you still need SharePoint installed locally, with great potential for mucking up IIS, and the whole thing feels unwieldy.

Apple’s lock-in works. Can anyone improve on App Store?

Timothy B Lee writes of the App Store/iPhone and now iPad lock-in:

The store is an unnecessary bottleneck in the app development process that limits the functionality of iPhone applications and discourages developers from adopting the platform.

While instinctively I agree, the evidence for the damaging effect of the App Store is not there. On the contrary, the locked-in iPhone has transformed the mobile app market and expanded it remarkably.

Reason: the user experience is great, the approval process at least weeds out apps that would be intrusive or harm performance, and installing an app from the store is less risky than installing an app onto Windows or OS X.

Ironically, Apple’s own iTunes is an example of an app that installs services you do not necessarily want or need. Personally I keep it off PCs and use a Mac Mini for gadgets that require it.

Is it possible to find a app distribution model that avoids the monopolistic and dictatorial model of App Store, but delivers an equally good user experience during and after purchase and installation?

A good question, but to my mind an open one.

A Silverlight UI for Windows Mobile 7, backward compatibility in doubt

Note: speculative post; I have no official information on this.

It’s been rumoured for ages; but at this point I would be surprised if the Windows Mobile 7 UI were not built with Silverlight. Consider:

  • Silverlight has to be supported – it should have been in 6.5 – otherwise nobody will take mobile Silverlight seriously
  • WM7 has to have excellent UI design; and WPF/Silverlight is Microsoft’s designer-friendly UI framework
  • Silverlight 4 already supports touch control in the current beta
  • Scaling/Zooming is baked into Silverlight and ideal for a mobile UI
  • If Silverlight is present on the device it would make sense to build the UI with it

If this is right, there are a couple of interesting aspects for developers. It will make Silverlight a more attractive platform in scenarios such as Enterprise roll-outs where the device can be specified.

The awkward question: what about all those existing Windows Mobile apps built either with native code or with the compact framework? Again, there are rumours of lack of backward compatibility. Does that mean that all Windows Mobile 7 apps with a UI will have to be done in Silverlight? That’s what John Biggs says:

WinMo 7 will not run 6.x code. End of story. It is based on Silverlight and .Net. Everything save a few basic programs will not work under WinMo 7. There is no expectation that this will be a “business device” and the focus is currently on games including some XBox Live functionality for gaming and messaging. There will be a Microsoft App store with an easy approval process.

I find this a stretch. I can believe that Microsoft might initially target the consumer market, or have crippled “consumer” versions; but not that it would give up on mobile business apps – we heard at PDC (to the point of tedium) how Microsoft is supporting “three screens and a cloud”, unified for developers by Visual Studio. There’s no reason why Silverlight should not be used for business apps.

What about backward compatibility though? Traditionally Microsoft does a good job of keeping your old stuff running, within reason; possibly too good – Windows is full of compatibility hacks that may be to its detriment overall.

Another point to bear in mind: WM7 needs a browser, and I don’t see Microsoft re-implementing IE in Silverlight.

So I’m sceptical about this too; but with Windows Mobile at such a low ebb could the company decide it has little to lose?

Windows Azure is too expensive for small apps

I’m researching Windows Azure development; and as soon as you check out early feedback one problem jumps out immediately. Azure is prohibitively expensive for small applications.

Here’s a thread that makes the point:

Currently I’m hosting 3 relatively small ASP.net web applications on a VPS. This is costing about $100 per month. I’m considering transitioning to Azure.
Q: Will I need to have 1 azure instance per each ASP.net application? So if I have 3 web apps, then I will need to run 3 instances which costs about $300 per month minimum, correct?

The user is correct. Each application consumes an “instance”, costing from $0.12 per hour, and this cost is incurred whenever the application is available.

Amazon also charges $0.12 per hour for a Windows instance; but the Amazon instance is a virtual machine. You can run as many applications on there as you like, until it chokes.

Google App Engine has a free quota for getting started, and then it is charged according to CPU time. If the app is idle, you don’t pay.

In addition, all these services charge extra for storage and data transfer; but in a low-usage application these are likely to be a small proportion of the total.

Summary: Azure’s problem is that it does not scale down in a way that makes business sense. There is no free quota, unless you count what is bundled with an MSDN subscription.

I realise that it is hard to compare like with like. A cheap Windows plan with a commodity ISP will cost less than either Amazon EC2 or Azure, but it is worth less, because you don’t get a complete VM as with Amazon, or a managed platform as with Azure, or the scalability of either platform. The point though is that by cutting out smaller businesses, and making small apps excessively expensive for customers of any size – even enterprises run small apps – Azure is creating a significant deterrent to adoption and will lose out to its rivals.

Check out the top feature request for Azure right now: Make it less expensive to run my very small service.