Tag Archives: software development

Brief reflections on 50 years of BASIC

Beginner’s All-Purpose Symbolic Code (BASIC) has turned fifty, as reported on The Reg and by Jack Schofield on ZDNet. A great moment in computer history, or would we have been better off without it?

My first computer (a Commodore PET) ran Basic from ROM, and without it you could do nothing, though developers bypassed it by using the POKE command to write low-level instructions into memory. The language is meant to be forgiving (as far as a computer language can be) and English-like, at the expense of being a little more verbose. It is case-insensitive and does not require braces or semi-colons to indicate blocks or lines of code, which makes programming look less intimidating for beginners.

I graduated onto an Atari ST, for which there was an excellent Basic implementation called GFA Basic, fast and capable. This was great for writing utilities, though, though serious programming tended to use one of several strong C compilers: Lattice C, Mark Williams C, HiSoft C come to mind.

Basic also had a role, even on the ST, as a macro language for applications. For example, the Superbase database manager used a version of Basic.

The company most strongly associated with Basic though is Microsoft. A version of Basic came with MS-DOS.

image

Microsoft also supported Basic for professional development. Microsoft Basic Professional Development System 7.x was a well-regarded development tool for business applications, though commercial shrink-wrap software tended to be written in C or C++.

That trend followed through to the Windows graphical environment. Visual Basic (VB), which made it easy to code Windows applications, was perhaps the most significant Basic release in terms of its impact, especially when it reached version 3.0 with full database support. Its popularity was such that many developers felt wounded when Microsoft discontinued Visual Basic 6.0, a direct successor, in favour of Visual Basic .NET which is something incompatible and different.

Further, VB 6.0 or something very like it lives on today, in the form of Visual Basic for Applications as found in all recent versions of Microsoft Office.

image

Despite this, Basic is in decline. Most of the professional developers I meet at events like Build use C# in preference to Visual Basic, there being little reason not to. C# is the premier language of .NET, and Visual Basic gets in the way if you want to keep up with latest .NET developments. Xamarin, which lets you code in .NET for iOS and Android, supports C# but not Visual Basic. Once you come to terms with semi-colons, braces and case-sensitivity, there is no real advantage to Visual Basic and C# is no more difficult.

I do see Visual Basic still used in education though, as well as by some developers who either prefer the language or are so used to it that they see no need to change; and to be fair, Xamarin aside, there is little if anything you can do in C# that you cannot also do in VB and the output is more or less the same.

The Roslyn project, which will be part of the next version of C# and probably in the next release of Visual Studio, lets you paste C# code as VB and vice versa.

Nevertheless, I believe we will see further decline in Basic usage, especially as it is little used outside Microsoft’s platform.

Would it have been better if Microsoft has not adopted Basic so wholeheartedly? There are some problems with Basic, though it is possible to write excellent code in Basic just as you can write poor code in C#, Python, C, or other more fashionable languages. Some issues:

  • Early versions of Basic encouraged badly structured programming with keywords like GOTO and GOSUB resulting in intricate loops that were hard to follow or debug.
  • Basic abstracts how software works to such an extent that you do not learn some important programming concepts such as pointers, addresses, memory allocation.
  • There is no natural progression from Basic to the C-like languages which dominate computing (C,C++,JavaScript,C#).
  • Visual Basic encourages developers to mix GUI code and business logic in the same files, as well as building user interfaces that tend not to scale well.
  • Small and declining professional use means that Basic is less useful than many other languages in the job market.

That said, Basic powers many excellent business applications as well as introducing many to the wonders of programming, and deserves our respect.

Notes on styling a Windows Store app ListView to vary item appearance according to the data

Problem: You have a ListView containing data. You want to vary the appearance of items in the ListView according to the value of the data.

I spent some time on this in relation to a panel for a game I am writing. For example, you have a ListView containing numbers. How can you have negative numbers appear in red?

image

In desktop WPF (Windows Presentation Foundation) you could do this with Property Triggers but these are not supported in Store apps.

One way to do this is with a value converter. Add a class to your project called MyValueConverter. Make the class public, and inherit from Windows.UI.Xaml.Data.IValueConverter.

Right-click IValueConverter and choose Implement Interface to have Visual Studio create two stub methods, Convert and ConvertBack.

This class is going to return an object which will be applied to the Foreground property of a ListViewItem. The Convert method looks like this:

public object Convert(object value, Type targetType, object parameter, string language)

At runtime, the value argument will contain the item displayed in this row of the ListView. The targetType will match the type of the property we are setting, which in this case is a Brush object.

Now add an instance of MyValueConverter to MainPage.xaml (or App.xaml) as a resource. If there is no Page.Resources element, create it, and add an instance of MyValueConverter with the Key “NumberForegroundConverter”:

<Page.Resources>
<local:MyValueConverter x:Key="NumberForegroundConverter" />
</Page.Resources>

Next, select the ListView element in the XAML editor or designer. Right-click the selected element in the designer, and choose Edit Additional Templates – Edit Generated Item Container (ItemContainerStyle) – Edit a Copy …

image

Accept the default name of ListViewItemStyle1 and click OK.

This generates an element that defines the layout and appearance of items in the ListView. Currently it does not appear to do anything, since it is a copy of the default settings.

Find the element called <ListViewItemPresenter> which is nested within <ControlTemplate TargetType=”ListViewItem”>. No Foreground attribute for ListViewItemPresenter is generated, but we can add one:

Foreground="{Binding Converter={StaticResource NumberForegroundConverter}}"

If you now run the project, you will get an exception, because the methods in MyValueConverter do not yet have any code. Now we have to think about the type of the items in the ListView. In this example, I just typed some strings into the XML editor:

<ListView ItemContainerStyle="{StaticResource ListViewItemStyle1}">
<x:String>145</x:String>
<x:String>-30</x:String>
<x:String>442</x:String>
</ListView>

All the items are strings, so the Convert method can look like this:

String s = (String)value; //note this ONLY works if the item is always a string

if (float.Parse(s) < 0)
{
return new SolidColorBrush(Windows.UI.Colors.Red);
}
else
{
return new SolidColorBrush(Windows.UI.Colors.White);
}

We don’t care about the ConvertBack method so can use this code:

return Windows.UI.Xaml.DependencyProperty.UnsetValue;

It works but there are some issues. One oddity is that when you roll the mouse over a negative number, it looks the same as a positive number.

image

This is because we did a converter for the Foreground property but not for the SelectedForeground property. XAML in Store apps makes extensive use of themes, and themes include a lot of brushes.

Another issue, which may or may not impact your application, is that the converter code does not run again if you change the displayed item dynamically. That is, if you replace the item it updates OK, but if you update the existing item it does not.

A slightly more complex example will demonstrate this. Let’s say that rather than displaying strings, the ListView is displaying Widget quantities, where a negative number indicates backorders. The ListView is bound to an ObservableCollection<Widget>, and the Widget class implements INotifyPropertyChanged so that the ListView will update automatically when a Widget property changes. Note that the NumberForegroundConverter must be updated to accept a Widget value rather than a string.

Here is what happens if a Widget had a negative quantity when the ListView was first populated, but got dynamically updated to a positive value (some stock arrived):

image

Oops! Now the positive quantity is in red.

We can fix this by abandoning the converter, and instead giving the Widget class a Foreground property of its own, calculated to return Red for negative quantities and White for positive. Make sure it fires a NotifyPropertyChanged event when updated. Now the Foreground property in <ListViewItemPresenter> looks like this:

Foreground="{Binding Foreground}"

It works:

image

I used this approach in my game in order to implement an Enabled property that indicates items which are unselectable. This changes dynamically according to the state of the play.

Note that you are unlikely to want a Foreground property in your business objects, but could create a DisplayWidget class for the purpose.

I realise that these are not the only ways to create a ListView which styles items differently according to their values, but they may be the simplest. Other suggestions and comments are welcome.

Update: Mike Taulty has some comments and suggestions here.

Embarcadero pre-announces AppMethod cross-platform development tool: Delphi repackaged?

Embarcadero is spilling the beans on a new development tool called AppMethod, which has its own site here and a little more information on TechCrunch. A fuller reveal is promised at SXSW, which kicks off on March 7 in Austin, Texas.

image

But what is AppMethod? The IDE looks very like Delphi, the languages are Object Pascal (like Dephi) or C++ (like C++ Builder), and target platforms include Windows, Mac, iOS and Android. It would be extraordinary if the GUI framework were not some variant of FireMonkey, the cross-platform and mobile framework in Delphi.

Just Delphi (and C++ Builder, which is Delphi for C++) repackaged then? In a comment Embarcadero developer evangelist David Intersimone says that is “way off base” though the only firm fact he offers is that AppMethod is less capable than Delphi for Windows, which presumably means that Delphi’s VCL (Visual Component Library) framework for Windows applications is not included.

Lack of a feature is not a compelling reason to buy AppMethod rather than Delphi so Object Pascal enthusiasts must hope there is more good stuff to be revealed.

I looked out for the Embarcadero stand at Mobile World Congress (MWC), which was a small affair tucked away in the corner of one of the vast halls.

image

The stand was hardly bustling and was overshadowed by a larger stand next to it for another app building tool, AppMachine. While I would not read much into the size of a stand at MWC, that accords with my general sense that while the recently added cross-platform and mobile capabilities in Delphi have won some take-up, it is a small player overall. Embarcadero may feel that a new name and a bit of distance between FireMonkey/Delphi and the original Windows-only tool will help to attract new developers.

Why you cannot prove software correctness: report from QCon London

I’m at QCon London, an annual developer conference which is among my favourites thanks to its vendor-neutral content.

One of the highlights of the first day was Tom Stuart’s talk on impossible programs. Using a series of entertaining and mostly self-referential examples, Stuart described why certain computing problems are uncomputable. He also discussed the “Halting problem”: unless you emasculate a computing language by removing features like While loops, you cannot in general answer the question “will this program ever finish”.

All good fun; but the dark side of the talk comes at the end, when Stuart proves with a flourish that a consequence is that you cannot prove software correctness.

In a world that is increasingly software-driven, that is a disturbing thought.

Microsoft improves its web app builder for Windows Phone, but where is it going with this?

Microsoft has improved its browser-based Windows Phone App Studio beta and added the ability to generate Windows Store apps. The changes are described here.

First, a quick tour. App Studio is carefully described as a tool for building “content-based apps”. The personal use case is an app to show off your recent holiday, favourite band, movie or team, and for businesses, a showcase for your company or a menu for your restaurant.

I find this curious. What is the point of this kind of app? If I want to create a fan project, wouldn’t a mobile-friendly web site or blog be better? And for businesses, what is the value of an app that lacks intelligence? For example, a restaurant might want an app linked to a loyalty scheme where you collect points towards a free meal or qualify for offers, but how many will want an app just to check a menu, which they could easily do online?

Still, I like the idea of an app that will make it easier to read this blog on Windows Phone, so I went in and built an app.

Microsoft is continuing its peculiar and infuriating aversion to proper documentation, but there is a a how to that is somewhat informative. “You can also create a custom action”, it says, but does not tell you what such an action can do or how to use it.

That said, the development environment is reasonably intuitive. There is no interface builder at the level of buttons and listboxes; rather, you drag high-level elements into sections and the user interface is built for you. For example, I added an RSS feed, entered the URL for this blog, and it built a UI to browse and read blog entries.

image

Everything is data bound, and the data can be stored either locally or else hosted by Microsoft, in which case you can amend it dynamically:

App Studio Data Services means the data is stored in App Studio and depends on an internet connection. If you update your data in App Studio, your app will automatically update. This allows you to create live apps that don’t need to be updated when you want to change data.

Large or sophisticated data sets are not the target here though. You could store a short list of addresses, for example.

You can also add elements including HTML text, RSS feeds, YouTube videos, Flickr photos, and Bing searches. You can add actions including initiating a phone call or email, searching Nokia music, or getting directions from Nokia HERE maps.

As you work, a live preview of the app appears alongside your work, a nice feature.

Once done, you can generate the app.

image

New in this version is the ability to generate a Windows Store App for Windows 8.1, as well as a phone app. Once in Visual Studio, you can do what you like, though there is no way back to the visual builder. Apps generated use XAML and C#.

image

App Studio also compiles a Windows Phone binary package (not yet for Windows Store apps) which you can install immediately, provided you have added the necessary certificate. You can install the app by scanning a QR code.

image

There is good work here, and if by any chance you do want to build a “content app” of the type envisaged, it is great.

I have a couple of reservations though.

First, it is too limited to be useful for real-world apps, unless you just use it as a starting point for a Visual Studio project. It needs the ability to write snippets of code, and the ability to link to business data sources like Azure Mobile Services and SQL Server. It also needs a login facility supporting at least Office 365 and Microsoft IDs.

Second, it seems to me that Microsoft is working simultaneously on several projects with overlapping purpose, which is to simplify app building.

Project Siena is a visual app builder implemented as a Windows 8 app; I looked at it here.

Visual Studio Lightswitch is a visual app builder in Visual Studio, which builds apps for Silverlight and HTML.

Access 2013 Web Apps let you build custom databases that hook into Office 365. I looked at these here. This is one easy app builder that really makes sense to me, allowing reasonably sophisticated data models and using Office 365 identities for log-in and permissions.

Windows Phone App Studio as described above.

Now, I appreciate that there are slightly different target markets in each of these. Lightswitch cannot build store apps, Access Web Apps require SharePoint or Office 365, Project Siena cannot build phone apps, and so on.

However, Microsoft needs to unify its development platform, and a proliferation of tools all going for the supposed non-technical app developer is not helping its cause. I also suspect that the demand for consumer “content-based apps” is vanishingly small.

Personally I think Microsoft should both improve and shout from the rooftops about the under appreciated Access 2013 web apps, scrap at least two of the other three, and integrate their functionality so that we have one easy to use app builder that can target Windows Store apps and Windows Phone apps.

What’s on at the QCon London software development conference (and a discount for readers)

The QCon London conference is on in early March (5-7). It is always a conference I look forward to since it is vendor neutral, though with an agile flavour. Although it covers high scale systems it is not the place to go if you think heavyweight Enterprise middleware from a big name vendor will solve your problems. In fact, it was QCon where I heard Martin Fowler and Jim Webber from Thoughtworks expound on Does my Bus look big in this? (what a great title) in which they argue that whatever software need you have, an Enterprise Service Bus is not the best way to meet it. You are not going to hear this kind of disruptive address at vendor-driven events.

So what is on this year? There are 15 tracks, some covering the buzzwords of the day like Big Data Architecture, DevOps, Internet of Things (two different tracks on this) and Bleeding Edge HTML5 and JavaScript (with case studies from Netflix and the Financial Times). Next Gen Cloud intrigues me because it covers multi-cloud services.

Java is almost conspicuous by absence (though it will no doubt show up throughout) but there is a track on Not Only Java which looks at performance tuning, garbage collections, lambdas and streams in Java 8, and more.

In the wake of Snowden’s revelations, Privacy and Security gets a track to itself, long overdue.

So how does QCon choose its tracks? It’s done by a committee of community experts, InfoQ CEO Floyd Marinescu told me.

Over 15 people came together, facilitated by QCon, and through an intensive multi-week process debated and voted down our tracks until we had these final 15.   We do place some constraints such as a desire to have a certain balance of tracks to cover areas of innovation of interest to different communities such as project managers, architects, engineers as well as operations people.

What really counts of course is the speakers, and this year they include Jafar Husain (technical lead at Netflix), Eva Andreasson who pioneered deterministic garbage collection, Graham Tackley, director of architecture at Guardian News and Media, Erik Meijer who created Microsoft’s LINQ, and Joe Armstrong, co-inventor of Erlang.

If you book with the code “itwriting50” you will get a £50 discount.

Microsoft and mediocrity in programming

A post by Ahmet Alp Balkan on working as a developer at Microsoft has stimulated much discussion. Balkan says he joined Microsoft 8 months ago (or two years ago if you count when he started as an intern) and tells a depressing tale (couched in odd language) of poor programming practice. Specifically:

  • Lack of documentation and communication. “There are certain people, if they got hit by a bus, nobody can pick up their work or code.”
  • Inability to improve the codebase. “Nobody will appreciate you for fixing styling or architectural issues in their core, in fact they may get offended.”
  • Lack of enthusiasm. “Writing better code is not a priority for the most”
  • Lack of productivity. “I spend most of my time trying to figure out how others’ uncommented/undocumented code work, debugging strange things and attending daily meetings.”
  • Lack of contribution to the community. “Everybody loves finding Stack Overflow answers on search results, but nobody contributes those answers.”
  • Lack of awareness of the competition. “No one I met in Windows Azure team heard about Heroku or Rackspace.”
  • Working by the book. “Nobody cares what sort of mess you created. As long as that functionality is ready, it is okay and can always be fixed later.”
  • Clipboard inheritance. “I’ve seen source files copy pasted across projects. As long as it gets shit done (described above) no one cares if you produced unmaintainable code.”
  • Using old tools. “Almost 90% of my colleagues use older versions of Office, Windows, Visual Studio and .NET Framework.”
  • Crippling management hierarchy. “At the end, you are working for your manager’s and their managers’ paychecks.”

There are a couple of points to emphasize. This is one person in one team which is part of a very large corporation, and should not be taken as descriptive of Microsoft programming culture as a whole. Balkan’s team is in “the test org”, he says, and not making product decisions. Further, many commenters observe that they have seen similar at other organisations.

Nevertheless, some of the points chime with other things I have seen. Take this post by Ian Smith, formerly a Microsoft-platform developer, on trying to buy a Surface Pro at Microsoft’s online store. From what he describes, the software behind the store is of dreadful quality. Currently, there is a broken image link on the home page.

image

This is not how you beat the iPad.

Another piece of evidence is in the bundled apps for Windows 8. The more I have reflected on this, the more I feel that supplying poor apps with Windows 8 was one of the worst launch mistakes. Apps like Mail, Calendar and Contacts on the Metro-style side have the look of waterfall development (though I have no inside knowledge of this). They look like what you would get from having a series of meetings about what the apps should do, and handing the specification over to a development team. They just about do the job, but without flair, without the benefit of an iterative cycle of improvements based on real user experience.

When the Mail app was launched, it lacked the ability to see the URL behind a hyperlink before tapping it, making phishing attempts hard to spot. This has since been fixed in an update, but how did that slip through? Details matter.

A lot is known about how to deliver high quality, secure and robust applications. Microsoft itself has contributed excellent insights, in books like Steve McConnell’s Code Complete and Michael Howard’s Writing Secure Code. The Agile movement has shown the importance of iterative development, and strong communication between all project stakeholders. Departing from these principles is almost always a mistake.

The WinRT platform needed a start-up culture. “We’re up against iPad and Android, we have to do something special.” Microsoft can do this; in fact, Windows Phone 7 demonstrated some of that in its refreshing new user interface (though the 2010 launch was botched in other ways).

Another piece of evidence: when I open a Word document from the SkyDrive client and work on it for a while, typing starts to slow down and I have to save the document locally in order to continue. I am not alone in experiencing this bug. Something is broken in the way Office talks to SkyDrive. It has been that way for many months. This is not how you beat Dropbox.

In other words, I do think Microsoft has a problem, though equally I am sure it does not apply everywhere. Look, for example, at Hyper-V and how that team has gone all-out to compete with VMWare and delivered strong releases.

Unfortunately mediocrity, where it is does exist, is a typical side-effect of monopoly profits and complacency. Microsoft (if it ever could) cannot afford for it to continue.

RAD Studio XE4 with Delphi for iOS is here. Who will use it?

Embarcadero has released RAD Studio XE4, its suite of development tools for Window, Web and for the first time, Apple iOS. iOS support first appeared in an earlier release, but in preview, and the current effort works using a new LLVM-based ARM compiler so is somewhat unlike the preview. Individual products such as Delphi XE4 are also available separately.

Looking at what’s new in Delphi and C++ Builder in XE4 it is apparent that iOS support is by far the main change since RAD Studio XE3, though there are two other significant changes:

  • Prism, a version of RemObjects Oxygene that compiles a Delphi-like language to .NET (and soon other targets) has been removed. Oxygene lives on at RemObjects.
  • FireDAC, a data access engine acquired from DA-SOFT, is now part of RAD Studio.

I ran up the new RAD Studio on a Parallels VM on a Mac, a VM on a Mac being the best way to try cross-platform development for OS X and iOS. The new IDE immediately presents you with instructions on setting up for iOS development (though I am not a fan of videos, preferring clear text instructions) but I no problems configuring the Mac agent (called PAServer) which makes this work. Start a new mobile app and you can pick a starter template or begin with a blank canvas.

image

I picked the Tabbed Application and was soon trying out my new app on the iOS simulator

image

So far so good, though the ability to run up a quick app is no proof of the quality of the development tool. Still, a few reflections.

As I noted earlier, it seems to me that Delphi developers are either Windows developers using the tried and trusted VCL (in which case there is very little for them in XE4), or developers who are targeting mobile platforms and using the cross-platform FireMonkey framework in order to share code between Windows, Mac and mobile. I guess it is also possible that developers targeting iOS alone will be so taken with Delphi or C++ Builder that they will come in as new users.

VCL developers now have 64-bit compilation and a mature framework, and given that the efforts of Embarcadero are now focused elsewhere, and that even Microsoft is going slow on new features for what it now calls “desktop Windows”, there is little reason for such developers to upgrade.

The key questions then are about the quality of the FireMonkey framework and the iOS support. It is hard for me to be objective, since I know Delphi from of old and it is a familiar environment. Delphi or C++ Builder for iOS has obvious attractions for such developers. I would be intrigued though to know what an Objective C or even a JavaScript developer would make of Delphi, coming to it fresh. I am sceptical whether an Xcode developer would find enough productivity benefit in Delphi and FireMonkey to want to move over, and suspect also that many would not be impressed by the FireMonkey approach to iOS controls, which are generally custom drawn rather than true native, or faked completely like the Segmented Control which you are meant to put together from SpeedButtons with segmented styling, as explained in the Delphi iOS tutorial:

image

Embarcadero is making a big play of being “true native” but native is not just about the executable code (I have written more about this elsewhere) and cross-platform always involves compromise.

There is also some disquiet in the developer community about the cost of keeping up to date with RAD Studio. The full RAD Studio XE4 Architect edition currently costs £2,892.60 ex VAT for a new user, or £1,927.80 to upgrade. If you just want basic Delphi, Delphi XE4 Pro is a more reasonable £642.60 for a new user, or £352.80 to upgrade – but you do not get iOS support for that, that is another £320.40 for the Mobile Add-on, and FireDAC if you need it a further £285.00. When XE3 came out, Embarcadero promised that iOS and Android support would be available later at a “low cost”; of course that is a relative and subjective term, but I can understand if some feel that the price is on the high side. Or you can buy software assurance and get upgrades free; I don’t have prices for that but the cost is significant.

It is unfortunate for Embarcadero that there is intense competition in the iOS tools space, not only from Apple’s excellent and free tools, but also from the likes of Xamarin and Titanium.

None of the above is intended to detract from the achievement of bringing Delphi to iOS, with Android promised, which is considerable.

How to test and debug an app on Surface RT in a hotel room

I wanted to test an app on Surface RT this morning, though I am out of the office with just a Samsung Slate (has Visual Studio), the Surface, and hotel wi-fi.

You can do remote debugging on Surface RT as explained here, however you need a private network.

I set up an ad-hoc network from the Samsung Slate as described here:

Open an elevated command prompt

netsh wlan show drivers

netsh wlan set hostednetwork mode=allow ssid="wireless name" key="password"

netsh wlan start hostednetwork

This allowed me to connect the Surface RT to a private network with the Slate.

Next, I needed to download and install the remote debugging tools for ARM from here.

I ran the remote debugger and was able to connect from Visual Studio on the Slate, but ran into a small issue. I needed a developer license for the Surface, but while on the private network it was not on the internet. When the remote debugger prompted to install a developer license, it could not retrieve it.

The solution was to disconnect, connect to the internet, then install the developer license using PowerShell. Run show-windowsdeveloperlicenseregistration from an elevated PowerShell window.

image

Then I returned to the private network and was able to launch my beautifully designed test app:

image

image

Note that for the actual test I did not run the app attached to Visual Studio. Rather, I deployed in release mode and then ran separately, to avoid the slowdown from the debugger. Once deployed, the test app remains in the Start screen for launching.

RIM hints at move to license BlackBerry 10 OS to third parties

RIM chief Thorsten Heins says in an interview that his company may license the forthcoming BlackBerry 10 mobile operating system to third parties. Here is the key quote:

We don’t have the economy of scale to compete against the guys who crank out 60 handsets a year. We have to differentiate and have a focused platform. To deliver BB10 we may need to look at licensing it to someone who can do this at a way better cost proposition than I can do it. There’s different options we could do that we’re currently investigating.

He goes on to talk about:

… us building a reference system, and then basically licensing that reference design, have others build the hardware around it – either it’s a BlackBerry or it’s something else being built on the BlackBerry platform

The big question: would the likes of Samsung and Sony leap to manufacture BlackBerry OS smartphones when they can offer Android for free?

A more nuanced question: even if OEMs were to license BlackBerry OS, to what extent would they really get behind it, as opposed to cranking out a few devices to see how they went? The latter is what happened to Windows Phone 7, with the exception of Nokia late in the day.

Samsung manufactures Windows Phone 7 devices, but you would hardly know it, since it is the Android-based Galaxy range that gets all its attention.

Another problem for RIM is negotiating the tricky waters of both manufacturing devices and licensing the OS to others. Apple did not enjoy having third-party manufacturers like Power Computing, Radius and Motorola release Mac clones. Here is what Walter Isaacson writes in his biography of Steve Jobs:

Apple got an $80 fee for each computer sold, but instead of expanding the market, the cloners cannibalized the sales of Apple’s own high-end computers on which it made up to $500 in profit.

Microsoft is now coming at this from the opposite end, going into hardware manufacturing with the Surface, which is another interesting experiment.

Still, listen carefully to what Heins is saying. “We don’t have the economy of scale to compete against the guys who crank out 60 handsets a year.” It is not just a matter of coming up with a fantastic mobile operating system or even a fantastic device; it is all about ecosystem, as Nokia boss Stephen Elop stated 18 months ago. RIM’s ecosystem is in decline, and the company will explore every avenue in trying to turn that around.