Category Archives: software development

Compile Object Pascal to JavaScript with Smart Mobile Studio

Here is an interesting project for Delphi developers: a compiler and IDE that takes your Object Pascal code and outputs HTML and JavaScript. 

image

Smart Mobile Studio, also known as OPJS (Object Pascal to JavaScript) is a project from Optimale Systemer AS, and supports not only the Object Pascal language. but also reusable components in true Delphi style. The goal is to bring Object Pascal programming to mobile platforms, using PhoneGap to wrap the generated code as a native application for iOS, Android or other platforms.

According to the developers, “The Smart object pascal dialect is more or less identical to Delphi 7”. That said, there are no pointers, and ASM blocks contain normal JavaScript instead of machine instructions. This enables use of JavaScript libraries such as JQuery from Smart Mobile code:

You can access native JS through an ASM section, create an instance of it to a variant, and then access its methods directly.

Smart Mobile Studio is currently in closed Alpha so not ready for most of us just yet. Note that there are other options for mobile development with Delphi, including Embarcadero’s official FireMonkey project which can be used with the Free Pascal iOS compiler. Embarcadero has promised its own compiler for IOS in a future version, as well as an Android option.

Mysteries of trapping errors in PowerShell

As everyone in IT knows, sometimes tasks that you think are quick and easy turn out to take longer.

Today I experiences a small example. I have a scheduled PowerShell script that copies a large file. I wanted to enhance the script so that I would receive an email stating whether the copy succeeded and when it completed.

The original script, for the sake of the example (it is actually a little more involved) is this:

Copy-Item somefile somefile.bak
"Clean up"

where “Clean up” represents some code that runs after the copy completes.

Now, by default a PowerShell may continue if it hits an error other than a syntax error. Again for the sake of the example, I will add a line which echoes text to represent the code that send an email. If you run this script:

Copy-Item somefile somefile.bak
"Clean up"
”Send email: File copied successfully”

then the email gets sent whether or not the copy succeeds. Here is what happens if somefile does not exist:

image

Not much use. The solution, I thought, was to use PowerShell’s trap statement. This catches the exception you specify, or all exceptions, and runs some code. You can also use the break or continue keywords to determine whether the block of code in which the exception occurred continues with the next statement, or exits immediately. You can read about trap here. I therefore wrote a script that looks like this:

Function CopyIt {

trap {return "Error copying file: $_"; break;}

Copy-Item somefile somefile.bak
return "Copy successfully completed"
}

$result = CopyIt
"Clean up"
”Send email: $result”

What I could not figure out though was that even when the copy failed, the script still sent me a success message:

image

I assumed I was misunderstanding how trap works. The output shows, in this example, that an ItemNotFoundException is thrown, so the trap should be triggered, right?

Wrong. In the case of non-terminating errors  (PowerShell jargon) you have to specify the ErrorAction. The default ErrorAction is “Continue”. Therefore I had to modify the script like this:

Copy-Item somefile somefile.bak -ErrorAction stop

Now I get an email with a failure message if the copy fails:

image

All very obvious to PowerShell experts; but it seems to me that PowerShell makes it easy for the unwary to write scripts that fail silently. You are unlikely to see the red text when your script is running on a server.

Windows on ARM fixes much that is wrong with Windows, but lack of apps makes it Microsoft’s big risk

Vendors who create new platforms work hard to attract developers, because high availability of apps is seen as essential for success. This is why, for example, RIM is offering free PlayBooks to developers who submit apps to BlackBerry App World.

image

Why then would Microsoft deliberately and consciously choose to release a new family of Windows machines on which existing Windows applications cannot run, even when recompiled? This is what is happening with Windows on ARM (WOA), as Windows President Steven Sinofsky makes clear in his lengthy post on the subject:

Developers wanting to reach WOA with existing apps have two options. Many apps will be best served by building new Metro style front ends for existing data sources or applications, and communicating through a web services API … Other existing applications will be well served by reusing large amounts of engine or runtime code, and surrounding that with a Metro style experience.

This restriction means that WOA cannot benefit from what what might otherwise be its biggest advantage versus the competition: huge numbers of apps that could easily be ported.

Microsoft’s reasoning is that the existing Windows software deployment model is broken so badly that it cannot be fixed:

If we enabled the broad porting of existing code we would fail to deliver on our commitment to longer battery life, predictable performance, and especially a reliable experience over time. The conventions used by today’s Windows apps do not necessarily provide this, whether it is background processes, polling loops, timers, system hooks, startup programs, registry changes, kernel mode code, admin rights, unsigned drivers, add-ins, or a host of other common techniques. By avoiding these constructs, WOA can deliver on a new level of customer satisfaction: your WOA PC will continue to perform well over time as apps are isolated from the system and each other, and you will remain in control of what additional software is running on your behalf, all while letting the capabilities of diverse hardware shine through.

says Sinofsky. It is a view that has merit, particularly when you consider how badly Windows has been damaged by poor quality OEM software.

Note that he is even promising an end to Windows “cruft”, as memorably described by Verity Stob in State of Decay:

Cruft Force 7. Wounded. Description: No longer able to logon using original account as the system freezes, so must logon as "Verity2" or similar

and the like. “Your WOA PC will continue to perform well over time,” Sinofsky promises.

Another reason to like this approach is that the Windows Runtime (WinRT), the platform for which third-parties are allowed to develop, is in my view a great piece of work. The WinRT apps in the Windows 8 Developer Preview perform well, even though they are simple things put together quickly, many of them by students as I recall. The insistence on asynchronous calls for any system API that might be slow to return should ensure responsive applications.

At the BUILD conference last September we were told that the Windows team sat down to create a new platform that avoids the mistakes of the past and while it introduce frustrations of its own, some of which we know about and some of which developers will discover, it does appear to be well thought-through.

Microsoft Office itself is not the best performing of software, particularly Outlook which is prone to long hangs. Fortunately, Outlook is missing from the version of Office 15 which will ship for WOA, and journalist Adrian Kingsley-Hughes reports positively on a recent glimpse at the software.

The big risk

A sure-fire success then? No, because the downside of WOA is that right now there are no apps for it, beyond what we have seen in the developer preview. It is a brand new platform; and the history of personal computing is littered with good products that failed because they could not achieve sufficient momentum.

I am just back from RIM’s BlackBerry conference in Amsterdam, impressed by what I have seen of the PlayBook and forthcoming BlackBerry 10 platform and its tools for developers, but thinking, is this enough to persuade a customer to buy a BlackBerry tablet instead of the safe choices of Apple iOS or Google Android?

Microsoft has the market presence to make this work, you may think; but the Windows Phone 7 story so far shows that this is not enough. The new phone OS has only a tiny market share after a year, and if it recovers, it will be more to do with Nokia than with Microsoft.

WOA also has interesting competition in the form of Windows 8 on x86, which will also have WinRT, but without the restrictions on desktop apps. If partners focus on Intel Windows 8, as the “full” version, it could be hard for WOA to find its market.

There are problems with Windows 8 on x86 too. Most of existing Windows apps will need a keyboard and mouse to work properly, and expect to find large amounts of storage, not the 16 or 32 GB in a typical tablet. Windows 8 Intel devices may end up like the Samsung tablet given to attendees at BUILD: powerful, but heavy, expensive, with short battery life, and complete with the clutter of a separate keyboard. Such devices have their place, but they are not an answer to the iPad.

It is WOA, not Windows 8 x86, that has to win market share from Apple.

Microsoft is choosing to do WOA right, rather than opening it up to the kinds of problems which have afflicted Windows in the past. That does makes sense, because it is those problems which have made users gladly move away from Windows now that compelling alternatives are available.

I also believe that OS vendors work too hard to pump up the app numbers, and not hard enough to ensure quality, resulting in app stores full of poor to indifferent apps. This is why schemes like the BlackBerry effort mentioned above do as much harm as good, enticing developers to submit rubbish in order to win a new gadget. An app store with 10 great apps is better for users than one with a thousand poor ones.

It is nevertheless true that apps make or break a platform. BUILD attendees and those who have downloaded the Windows 8 developer preview have had the tools to make WinRT apps for a few months now, but my impression is that most are waiting to see how it progresses before investing seriously in WinRT development. Another problem is that Windows 8 developer preview works nicely on a real tablet, but not so well in a virtual machine or on a PC without a touch screen.

I still think WOA may work.

  • If Microsoft does a good job with WOA Office, giving it an unique selling point against the competition.
  • If the WOA devices are competitively priced.
  • If the battery life is good.
  • If there are at least a handful of truly worthwhile third-party apps at launch.
  • If there is not some obvious problem with stability, or an annoyance that spoils the experience, like the one I found on the PlayBook when the virtual keyboard failed to pop up when trying to author a tweet in the web browser.

That is a lot of ifs though, and the progress of WOA will be a fascinating tech story throughout 2012.

Windows on ARM: Microsoft can write Desktop apps, but you cannot

Microsoft’s Windows chief Steven Sinofsky has written a long post describing Windows on ARM (WOA), which he says is a:

new member of the Windows family, much like Windows Server, Windows Embedded, or Windows Phone

There are many point of interest in the post, but the one which stands out for me is that while the traditional Windows desktop exists in WOA, third party applications will not be allowed there:

Developers with existing code, whether in C, C++, C#, Visual Basic, or JavaScript, are free to incorporate that code into their apps, so long as it targets the WinRT API set for Windows services. The Windows Store can carry, distribute, and service both the ARM and x86/64 implementations of apps (should there be native code in the app requiring two distributions).

says Sinofsky. He writes with extreme care on this issue, since the position for which he argues is finely nuanced. Why have the Windows desktop on WOA at all?

Some have suggested we might remove the desktop from WOA in an effort to be pure, to break from the past, or to be more simplistic or expeditious in our approach. To us, giving up something useful that has little cost to customers was a compromise that we didn’t want to see in the evolution of PCs

he says, while also saying:

WOA (as with Windows 8 ) is designed so that customers focused on Metro style apps don’t need to spend time in the desktop.

From a developer perspective, the desktop is more than just a different Windows shell. Apps that run on the Windows Runtime (WinRT) are isolated from each other and can call only a limited set of “safe” Windows APIs, protecting users from malware and instability, but also constraining their capabilities. The desktop by contrast is the old Windows, an open operating system. On Windows 8 Intel, most things that run on Windows 7 today will still work. On WOA though, even recompilation to target the ARM architecture will not help you, since Microsoft will not let desktops apps install:

Consumers obtain all software, including device drivers, through the Windows Store and Microsoft Update or Windows Update.

What if you really want to use WOA, but have some essential desktop application without which you cannot do your work, and which cannot quickly and easily be ported to WinRT? Microsoft’s answer is that you must use Windows on Intel.

That said, Microsoft itself has this problem in the form of Office, its productivity suite. Microsoft’s answer to itself is to run it on the desktop:

Within the Windows desktop, WOA includes desktop versions of the new Microsoft Word, Excel, PowerPoint, and OneNote, codenamed “Office 15”.

No Outlook, which I take to imply that a new WinRT-based Exchange client and PIM (Personal Information Manager) is on the way – a good thing.

Microsoft’s aim is to give customers the security and stability of a locked-down machine, while still offering a full version of Office. If you think of this as something like an Apple iPad but with no-compromise document editing and creation, then it sounds compelling.

At the same time, some users may be annoyed that the solution Microsoft has adopted for its legacy desktop application suite is not also available to them.

The caveat: it is not clear in Sinofsky’s post whether there may be some exceptions, for example for corporate deployments, or for hardware vendors or mobile operators. It will also be intriguing to see how Office 15 on ARM handles extensibility, for example with Office add-ins or Visual Basic macros. I suspect they will not be supported, but if they are, then that would be a route to a kind of desktop programming on WOA.

It will be interesting to see how Microsoft locks down Explorer, which Sinofksy says is present:

You can use Windows Explorer, for example, to connect to external storage devices, transfer and manage files from a network share, or use multiple displays, and do all of this with or without an attached keyboard and mouse—your choice.

By the way, this is a picture of the Windows ARM desktop as it looked at the BUILD conference last September. The SoC (System on a Chip) on this machine is from NVIDIA.

On BlackBerry 10, Cascades UI and Adobe AIR

I spoke to Jeff Lejeune, RIM’s Advanced User Interface Director, here at BlackBerry DevCon Europe in Amsterdam.

He is part of the team responsible for the Cascades UI, a native code UI framework for the forthcoming BlackBerry 10 OS. One of the things he told me is that the Cascades name is actually being used for parts of the API beyond the user interface. It is a major part of the new operating system.

I had not appreciated until today the extent of the likely difference between BlackBerry 10 and the current Tablet OS 1.0 or Playbook OS 2.0. Since the PlayBook OS is already based on QNX, I had assumed that BlackBerry 10 would be an incremental update rather than a radical new direction.

Certainly there is less difference between PlayBook OS 2.0 and BlackBerry 10 then there is between BlackBerry 7.0 and the PlayBook OS, so my assumption was not completely wrong. That said, the introduction of the Cascades UI acquired with The Astonishing Tribe is a major change. Lejune told me that Cascades UI will be in effect the native UI of BlackBerry 10, and the built-in apps will use it.

The first version of the PlayBook uses both native code and Adobe AIR for its built-in apps.

RIM has given full backing to Adobe AIR at this event, presenting it as one of the supported development platforms and saying that it will support AIR for as long as Adobe does and maybe even longer. Even so, it would be fair to say that RIM is moving away from AIR and towards native code and Cascades UI in BlackBerry 10.

Further, Adobe itself has changed direction since the launch of the PlayBook last year. Adobe has made it clear that while Flash, Flex and AIR are still important, its strategic direction is HTML 5 when it comes to development platforms. Some aspects of Flex, the code-based approach to AIR authoring, are being wound down, including the visual designer in Flash Builder.

My sense therefore is that AIR is not the best choice if you are considering how to develop for BlackBerry 10 – and BlackBerry 10 is the future of RIM’s platform. The primary choice should be between Cascades UI, for best performance and integration, or WebWorks (PhoneGap), for development in HTML and JavaScript and cross-platform code.

Cross-platform Windows and Mac lifts Delphi sales by 54%

Embarcadero has announced 54% growth in sales of Delphi and C++ Builder, its rapid application development tools, in 2011 vs 2010. These tools primarily target Windows, but in the 2011 XE2 edition also support Mac and iOS applications. XE2 also added a 64-bit compiler, making this the most significant Delphi release for years. The company says that the 2011 figures come on top of 15% year on year growth in the previous three years.

This is encouraging for Delphi developers, and well deserved in that Delphi still offers the most productive environment for native code development on Windows. The cross platform aspect is also interesting, though the FireMonkey framework which enables it is less mature than the old VCL, and there are many other options out there for cross-platform apps. FireMonkey does not yet support Android or other mobile platforms apart from Apple iOS.

2012 is also the year of Windows 8, raising the question of whether Delphi and C++ Builder will support the new Windows Runtime (WinRT) in future, and if it does, whether this will be FireMonkey only, or whether it could work with a XAML-defined user interface.

Will Nokia’s Qt come to Windows Phone?

When Nokia acquired Trolltech back in 2008, it made perfect sense as a way of supporting development on Symbian, its smartphone operating system, and nudging the Qt project, which provides a cross-platform framework for native applications, more towards mobile rather than just desktop application support. It also made sense as Nokia worked on Maemo and then Meego, its Linux for mobile project.

Then came February 2011 and CEO Stephen Elop’s announcement that Nokia would partner with Microsoft and make Windows Phone its primary smartphone operating system. Windows Phone 7 does not support native code development, other than by operators, manufacturers, and of course Microsoft itself. What future for Qt at Nokia now?

Here at Blackberry Devcon Europe, Nokia’s Lars Knoll, Qt Chief Maintainer, has been introducing Qt to Blackberry developers. Qt forms a critical part of RIM’s Blackberry 10 (BBX) platform, based on the PlayBook tablet OS and set to come to Blackberry phones later this year. The Cascades UI framework, for hardware-accelerated 2D and 3D rendering on BBX, uses Qt core and an adaption of QML (Qt Modeling Language). You can use Qt with or without Cascades on BBX.

Lars Knol, Nokia

Given that Nokia makes mobile devices which are in competition with RIM’s devices, it may seem odd that Nokia is supporting Qt on Blackberry. I asked Knoll about the status of Qt within Nokia following the move to Windows Phone.

There’s not too much I can say right now. The only thing I can repeat is that we’re still investing in Qt. We’re actually hiring more people to work on Qt. Qt is an essential part of the strategy for the next billion. That’s all I can say right now, but stay tuned, in time you’ll hear more.

He added later that Nokia is in business to make money; in other words, there are strong business reasons for Nokia to continue with Qt. The “next billion” reference refers to Nokia’s stated intention to bring apps to the next billion.

One possibility is that Qt will in fact support a future version of Windows Phone. It is already clear that Windows Phone 8 will use the same kernel as Windows 8 and we can expect a unified development platform build on the Windows Runtime (WinRT), which does support native code development.

It is not too much of a stretch then to expect a future Qt framework that will target Windows Phone and Windows 8 tablets. Nokia’s Elop has also hinted that it is interested in Windows tablets as well as phones in future.

A quiet revolution in UK government IT: open source ousting big-vendor lock-in

The most striking and surprising presentation at the Monki Gras developer event in London earlier this week was from two quietly spoken men from the UK government’s Cabinet Office. James Stewart and Matt Wall work on the Government Data Service (GDS), and what they are doing is revolutionary.

What is the GDS? “It’s a new branch of the cabinet office which exists to deliver public services, public sector information in-house, rather than the traditional out-sourcing model,” they explained, though it turned out to be rather more than that.

Wall described his experience of talking to government workers about their IT needs.

A common thing you see from very small to very large is someone in government who wants to get something done, who has a business problem or a user need that they want to serve, surrounded by a complex array of integrators, vendors, contractors, suppliers, and all of that, kind-of locked into that, their ability to manoeuvre or deliver services [is limited].

he explained. The only solution is to reform the way software is procured. They described their boss Mike Bracken’s goal:

We want to move from government procuring systems to government commissioning them, whether we build them ourselves, or just that we know what it is we’re asking for. We need that knowledge.

This is also about breaking the hold of the large vendors and finding ways to work on a smaller scale.

If you want to buy something in government, traditionally, some software or some system, the amount of momentum that you have to get up, the amount of people you can easily engage with, they tend to be from companies that are absolutely vast and they tend to take projects that are absolutely vast, the whole mechanism of working is stultifying for everyone involved. It is not just us, a small group of developers sitting in an office able to write some stuff, because that’s not scalable, you can’t do that for everyone. It’s finding small to medium sized companies, partners, out there in the market and finding ways to engage them … why should five very large companies get all the work?

Mike Bracken and the Cabinet Office minister Frances Maude are currently on the West Coast of the USA, they said.

They were invited to meet the usual suspects, Oracle, the major systems integrators. They cancelled it. They’re visiting Joyent, they’re visiting 10Gen, they’re visiting Twilio [applause]. It’s a wholesale change. We’re looking at how great web services are built.

There is also a commitment to open source. “All of the code that we’re producing is open source and out on the Internet,” they said.

What tools do they use?

Most of the core apps are in Ruby, with a mixture of Sinatra and Rails, and some Scala. We’re using a mixture of MySQL and Mongo for the database,

they told us.

The GDS is currently only about 30 people, 10 of whom are developers. How much impact can such a small team have?

We’ve just started and we’re very small. We’re already having a significant impact in some quite large and some quite small projects. The incoming demand that we face across central government and local government is absolutely astronomical, and one of the things that’s important to resolve over the coming years is how to manage that demand and provide services, abilities and communities for people . . . we never want to parachute into somewhere, rewrite all the systems and then go off somewhere else., that’s not sustainable.

Can this small group really change government IT so profoundly? That is an open question, and perhaps in the long term they will fail. There is no doubting though that this particular team is doing inspiring work. This blog post from GDS yesterday describes how open source participation was used to fix a government web site; it may seem a small thing, but as a new and different approach it is significant.

For more information see Mike Bracken’s post This is why we are here, and take a look at the team’s early work on GOV.UK, which is in beta.

image

How to brew better software: The Monki Gras in London

I attended The Monki Gras in London yesterday, a distinctive developer event arranged by the analyst firm RedMonk.

This was not only a developer event, with the likes of Andre Charland and Dave Johnson from the PhoneGap team at Adobe, Mike Milinkovich the executive director of the Eclipse Foundation, and Jason Hoffman with Bryan Cantrill from cloud services (and Node.js sponsors) Joyent. It was also a serious beer event, complete with a range of craft beers, a beer tasting competition with nine brews to try, and a talk plus a free book from  beer expert Melissa Cole. An unusual blend of flavours.

image

In charge of the proceedings was RedMonk co-founder and all round impressario James Governor. I am a big fan of RedMonk and its developer-focused approach; it has been a fresh and heady brew in the dry world of IT analysts.

image

The Monki Gras did seem like an attempt by a regular IT conference sufferer to fix problems often encountered. The Wi-Fi worked, the food was fresh, unusual and delicious, the coffee was superb; though brewing good coffee takes time so the queues were long. Not everything scales. Fortunately this was a small event, and a rare treat for the couple of hundred or so who attended.

That said, there were frustrations. The sessions were short, which in general is a good thing, but left me wanting more depth and more details in some cases; we did not learn much about PhoneGap other than a brief overview, for example.

Nevertheless there was serious content. Redmonk’s Stephen O’Grady made the point succinctly: IT decision makers are ignorant about what developers actually use and what they want to use, which is one reason why there is so much dysfunction in this industry. Part of the answer is to pay more attention, and several sessions covered different aspects of analytics: Matt LeMay from bitly on what users click on the Web; Matt Biddulph (ex BBC, Dopplr, Nokia) gave a mind-stretching talk on social network analysis which, contrary to what some think, was not invented by Facebook but predates the Internet; and O’Grady shared some insights from developer analytics at RedMonk.

I had not noticed before that github now gets nearly double the number of commits than does Google Code. That is partly because developers like git, but may also say something about Google’s loss of kudos in the open source developer community.

Kohsuke Kawaguchi, lead for Jenkins Continuous Integration and an architect at CloudBees, spoke on building a developer community. His context was how Jenkins attracted developers, but his main point has almost limitless application:  “Make everything easy, relentlessly.”

Something I see frequently is how big companies (the bigger the worse) place obstacles in front of developers or users who have an interest in their products or services. Examples are enforced registration, multiple clicks through several complex pages to get to the download you want, complex installs, and confusing information. It all adds friction. If the target is sufficiently compelling, like apps on Apple’s app store, developers will get there anyway; but it all adds friction, and if you are not Apple that can be fatal.

The Joyent guys did not speak about Node.js, sadly, but rather on the distinction between a VP of engineering and a Chief Technology Officer. Sounds dry and abstruse? I thought so too, but the delivery was so energetic that they were soon forgiven. Hoffman and Cantrill moved on to talk about management antipatterns in the software industry, prompting many wry nods of recognition from the audience. “It is very hard for middle management to add value,” said Cantrill.

Milinkovich made the point that the most valued open source projects generally make their way to a software foundation; PhoneGap to Apache is a recent example. He then gave the talk he really wanted to give, noting that as new software stacks emerge they have a tendency to re-implement CORBA, a middleware specification from the Nineties that tackled problems including remote objects, language independence, and transactions across the Internet. CORBA is remembered for drowning in complexity, but Milinkovich’s point is that the creators of exciting new stacks like Node.js should at least research and learn from past experience.

Milinkovich also found time to proclaim that “Flash is dead, Silverlight is dead, browser plugins are dead.” Perhaps premature; but I did not hear many dissenting voices.

I tweeted the conference extensively yesterday (losing at least one follower but gaining several more). Look out also for a couple of follow-up posts on topics of particular importance.

NVIDIA releases CUDA Toolkit 4.1 with LLVM compiler

NVIDIA has released version 4.1 of its CUDA Toolkit for general purpose GPU computing.

image

There is a lot in this release, including a compiler based on LLVM, which will make it easier to support other programming languages; 1000 new imaging functions; and a re-designed visual profiler.

There is also an update to Parallel Nsight, for debugging and profiling CUDA applications in Visual Studio. This is free, though you have to register as an NVIDIA developer. You need this update to work with the 4.1 toolkit.

You do have to update your graphics card driver:

image

using a new build which NVIDIA has not gotten around to signing:

image

Still, lots of goodies here and a must-have for developers wishing to put their NVIDIA GPU to work for more than just games.