Anders Hejlsberg on functional programming, programming futures

At TechDays in Belgium Micrososft’s C# designer and Technical Fellow Anders Hejlsberg spoke on trends in programming languages; you can watch the video here.

I recommend it highly, not so much because of any new or surprising content, but because in his low-key way Hejlsberg is a great communicator. The talk is mostly not about the far future, and much of what he covers relates directly to C# 4.0 and F# as found in Visual Studio 2010. Despite his personal investment in C#, Hejlsberg talks cheerfully about the benefits of F# and gives perhaps the best overview of functional programming I have heard, explaining what it is and why it is well suited to concurrency.

image

I will not try and summarise the whole talk here; but will bring out its unifying thought, which is that programming is moving towards a style that emphasises the “what” rather than the “how” of the tasks it encodes. This fits with a number of other ideas: greater abstraction, more declarative, more use of DSLs (domain-specific languages).

The example he gives early on describes how to get a count of groups in a set of data. You can do this using a somewhat manual approach, iterating through the data, identifying the groups, storing them somewhere, and incrementing the count as items belonging to each group are discovered.

Alternatively you can code it in one shot using the count keyword in LINQ or SQL (though Hejlsberg talked about LINQ). This is an example of using a DSL (Domain Specific Language), and also demonstrates a “what” rather than “how” approach to code. It is easier for another programmer to see your intention, as there is no need to analyse a set of loops and variables to discover what they do.

There is another reason to prefer this approach. Since the implementation is not specified, the compiler can more easily optimise your code; you do not care provided the result is correct. This becomes hugely important when it comes to concurrency, where we want the compiler or runtime to utilise many CPU cores if they are available. He has a screenshot of Task Manager running on a 128-core machine which apparently exists in Redmond (I can’t quite read the figure for total RAM but think it may be 128GB):

image

Hejlsberg says there was a language doldrums between 1995 and 2005, when many assumed that Java was the be-all and end-all. I wonder if this is a tacit admission that C#, which he was working on during that period, is not that different in philosophy from Java? The doldrums are over and we now have an explosion of new and revived languages: Ruby, Groovy, Python, Clojure, Boo, Erlang, F#, PowerShell and more. However, Hejlsberg says it makes sense for these to run on an existing framework – in practice either the Java or .NET runtime – since the benefits are so great.

Hejsberg also predicts that distinctions such as dynamic versus static languages will disappear as each language absorbs the best features from other languages. “Traditional taxonomies of languages are breaking down as languages pick paradigms from each other,” he says. The new language paradigm is multi-paradigm.

Just as C# has now acquired dynamic features, we can expect it to get better support for immutability in future (borrowed from functional languages).

Slow JavaScript on Apple iPad?

Charlie Wood reports that his MacBook Pro is 26.7 times faster than his iPad at the SunSpider JavaScript benchmark.

I thought it would be interesting to put the iPad up against something more comparable, the Atom-powered Toshiba NB300 Netbook I’ve been using and enjoying for the last few weeks. I installed Safari and ran SunSpider, running on batteries. The result: the Toshiba is 4.52 times faster.

TEST                   COMPARISON            FROM                 TO             DETAILS

=====================================================================

** TOTAL **: 4.52x as fast 10999.0ms +/- 0.7% 2434.6ms +/- 4.7% significant

A lot slower than the MacBook Pro of course. Still, the iPad starts at $499. The NB300 is around $325.00 – though lacking that lovely touch screen. By way of compensation, it has a rather good keyboard, on which I am typing this post.

Note: I do not yet have an iPad so I’m relying on Wood’s test.

Jewels from the loft: launch of Delphi, Netscape’s Constellation, HTML to die, Longhorn for developers

It’s the Easter holiday in the UK and I’ve suffered a bout of spring-clean fever. It is time, I decided, to clear out a mountain of old books and magazines.

A job like this always prompts reflections, the first of which is the sad decline of print journalism in the field of software development. It hurt to send piles of Byte, Exe, Dr Dobbs’s Journal, Application Development Advisor and others off for recycling.

image

A few things caught my eye. Exe June 1995, and there is a young Anders Hejlsberg talking to Will Watts about his new creation: Borland Delphi:

Before Delphi, you always had to make a choice. Do I go for the performance of a native code compiler, or the ease of use of a visual development environment? Do I go for a powerful object-oriented language, or a proprietary 4GL client/server tool? What programmers really want is all of the above, in one package. That’s what we set out to do.

What is striking about Delphi is that this was not hype. It delivered on that promise. It was better than its obvious rival, Microsoft’s Visual Basic, in almost every way (I will give VB a point for sheer ubiquity, especially in VBA guise). Delphi is still with us today, not bad after fifteen years. However, it never came close to VB’s market share, which shows that quality has never been the sole or even the most important determinant of sales success.

Next up is Byte, March 1998. “Reinventing the Web”, the cover proclaims. “XML and DHTML will bring order to the chaos”.

image

Inside there is a breathless description of how XML will change everything, and a quote from Jon Bosak:

HTML, this so-called ‘hypertext markup language,’ implements just a tiny amount of the functionality that has historically been associated with the concept of hypertext systems. Only the simplest form of linking is supported – unidirectional links to hard-coded locations. This is a far cry from the systems that were built and proven during the 1970s and 1980s.

Indeed. “We need to start replacing simple HTML with more powerful alternatives”, the article concludes. “The migration to XML must begin. The future of the Web depends on it.”

Here’s one thing that mostly did not work out as planned. The W3C tried to retire HTML, failed, and is now belatedly engaged in specifying HTML 5.

Byte March 1997 is also intriguing. Netscape’s Marc Andreessen smiles out of the cover.

image

Jon Udell, in the days before he disappeared into some Microsoft corridor, writes about Netscape’s “Constellation: the network-centric desktop”:

Netscape’s Constellation takes a less Windows-centric approach and puts more emphasis on location-independent computing, regardless of the platform. No matter what kind of system you’re using or where you are, Constellation presents a universal desktop called the Homeport. Although the Homeport can appear in a browser window, Netscape usually demonstrates it as a full-screen layer that buries the native OS – certainly one reason Microsoft is not embracing Constellation.

Netscape got a lot of things right, a true pioneer of what we now call cloud computing. What went wrong? Well, Microsoft went all-out to conquer Netscape by removing its browser dominance. Microsoft’s weapon was the free Internet Explorer.

It is all a pre-echo of what is happening now with Google and Microsoft, the difference being that Google has huge financial power thanks to its marriage of internet search and internet advertising. Unlike Netscape, Google is winning.

This blog is long enough; but I’ll give a brief mention to another jewel from the archives: a book given out at PDC 2003 entitled Introducing Longhorn for Developers.

image

It describes Microsoft’s vision for Longhorn: a radical new application model for Windows, building on XAML, WinFS and “Indigo”, the communication framework. It bears little resemblance to what eventually appeared as Vista, which is a shame as it was compelling in many ways.

Review: Broken bells

I’ve listened to this CD by James Mercer (ex The Shins) and Brian Burton (half of Gnarls Barkley) numerous times and can’t shake off the feeling that this could have been much better. That said, it’s good in lots of ways. The sounds are inventive, the melodies are strong, the talent is obvious.

The sound is a little dated, though I’m guessing that’s deliberate; there are echoes of eighties-style new romantic crooning plus electronica.

What’s missing then? Well, one of the songs is called "Sailing to nowhere" which sums it up nicely. The CD is lacking in passion or any real sense of direction.

If you like what James Mercer and Danger Mouse have done before, then you’ll likely enjoy this, though I doubt you will find it their best work. For others, there’s little compelling reason to grab this CD, though it passes pleasantly enough

Microsoft accused of failure to observe Open XML standards process

XML specialist Alex Brown, who was involved in the ISO standardisation of Microsoft’s Open XML – still perhaps best known as OOXML – says Microsoft has failed to honour the commitments it made when the standard was approved. In particular, it seems little progress has been made between Office 2007 and Office 2010. The key problem is that Microsoft implemented Open XML before it was standardised. There were numerous changes made during the standardisation process, but what to do about the existing implementation? Loosely, the existing unacceptable format was given a “Transitional” status, while the more satisfactory, corrected format was called “Strict”. Microsoft promised to implement the “Strict” variant as soon as it could. Brown adds:

I was convinced at the time, and remain convinced today, that the division of OOXML into Strict and Transitional variants was the innovation which allowed the Standard to pass. Enough National Bodies could then vote in good conscience for OOXML knowing that their preferred, Strict, variant would be under their control into the future while the Transitional variant (which – remember – they had effectively rejected in 2007) would remain purely for the purpose of accurately specifying old documents: a useful aim in itself.

It is now two years since Open XML was approved, and Microsoft is on the brink of releasing a new version of Office. So does Office 2010 implement Open XML Strict? Apparently not – it’s the Transitional version. That is bad enough; worse still, according to Brown, it does not even conform correctly to that:

It is also a worrying commentary on the standards-savvyness of the Office developers that the first amateur attempts of part-time outsiders find problems with documents which Redmond’s internal QA processes have missed. I confidently predict that fuller validation of Office document is likely to reveal many problems both with those documents, and with the Standard itself, over the coming years.

Note that Brown is basing his remarks on the preview of Office 2010; we have not seen the final release yet. I can believe that Microsoft may fix some issues, but it looks vanishingly unlikely that Office 2010 will implement the “Strict” standard which ISO approved.

Brown’s remarks shed light on something I noticed when reviewing the preview:

As for Open XML, it’s notable that Microsoft neglects to mention it at all in its Reviewer’s Guide, even though this is supposedly the release that will fully implement ISO/IEC 29500. It is odd how this has gone from a cause to campaign for, to not-worth-mentioning in just over a year. To be fair, few users ever cared about XML formats themselves: it is only when documents get scrambled or fail to open that such things become important.

No wonder Microsoft said nothing about it, if in reality it has lost interest in conformance.

I think it is a good thing for Microsoft to standardise its Office formats. Selfish manipulation of standards committees on the other hand is not acceptable. One thing is for sure: if Brown is right and

without a change of direction, the entire OOXML project is now surely heading for failure.

then the company will only have itself to blame. Its nightmare will re-emerge: entire governments mandating OpenOffice for the sake of  standards conformance.

That said, and despite the hype, I regard Office 2010 as a minor release. 64-bit Excel, a few tweaks, and a first foray into browser-hosted versions. Microsoft often displays this pattern, following up a release with major changes – Office 2007, for example – with one that is really just a refinement of what went before. It is not impossible that somewhere in the corridors of Redmond a team is working on a new Office that does a much better job with the Open XML standard.

Over to Microsoft – serious about Open XML? Or just doing the minimum necessary to protect a lucrative market dominance – maybe a bit less than the minimum?

Update: Microsoft’s Doug Mahugh has replied to Brown’s comments here. I am writing separately about this.

Android the new Windows?

I’ve just reviewed the LG GW620 Android phone. I was impressed by its features but disappointed by its usability – it’s not that bad, but scrolling web pages accurately with touch I found almost impossible – it’s hard to avoid scrolling too far and missing out a chunk – and why does LG supply the device with four different email clients?

Apple’s iPhone is much more expensive and compares badly on features, but has the usability and polish that the LG phone lacks.

OEM Android versus Apple iPhone – it reminds me of Windows vs Apple on the desktop.

One is for the mass market, cheap, feature-rich, a bit chaotic, always a few annoyances, but you put up with them because you can still get things done, and it’s an open platform which lets you do what you like.

The other is premium-cost, single-vendor, less annoying, and you spend more time getting on with what you want to do and less time fighting the machine.

I don’t intend this as a  complete parallel. There are more than two popular operating systems in the SmartPhone market right now – Symbian, Meego, WebOS, Blackberry; and Microsoft has big hopes for Windows Phone 7. That said, it is hard to see all these platforms thriving long-term.