Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Node.QML Would Have Been the Key to the Ubuntu Phone's Success

DZone's Guide to

Node.QML Would Have Been the Key to the Ubuntu Phone's Success

The Ubuntu Phone was a bold, inspired idea. But it failed. Was Canonical's choice of technology ultimately the project's undoing?

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

According to this article, Ubuntu for phones and tablets is dead. At least, Canonical is abandoning it, and a volunteer group at UBPorts is going to attempt to take it forward.

I own a Meizu Pro 5 Ubuntu phone. I don’t use it because its 4G is not compatible with T-Mobile’s 4G frequencies in Manhattan, and I cannot exist in a shrinking 2G world. It is a really nice all-around device, though.

I’ve been tracking QML since 2009, and the Ubuntu Phone having support for it built in was a clever move. Here’s something I made previously on the Mac, a tiny QML music player (it runs as is):

#!/usr/bin/env /Users/paul/Qt/5.5/clang_64/bin/qml.app/Contents/MacOS/qml 
import QtQuick 2.2
import QtMultimedia 5.0

Rectangle {
    width: 200
    height: 100
    property bool playing: false

    Text {
        anchors.centerIn: parent
        // one way binding - neat!
        text: playing ? "Stop music" : "Start music"
    }
    Audio {
        id: playMusic
        source: "MemphisSlim-IJustLandedInYourTown.mp3"
    }    
    MouseArea {
        anchors.fill: parent
        onClicked: {
            if(playing == true) {
                playMusic.stop()
                playing = false
            } else {
                playMusic.play()
                playing = true
            }
        }
    }
}

Here's the app on Mac OS X:

There is a very elegant single-script potential for apps with that.

On the Ubuntu Phone, there was no ability for the end user to casually acquire QML apps. They were available from the app store, but not just over the internet copy/paste style. Similarly, there was no tiny IDE for QML apps on the Ubuntu Phone, where one could type QML to try things out. First class development for that would always be on a computer, but why wouldn’t you make a tiny editor with a “run-it” button?

Of course, QML is crippled by design. All the heavy lifting for it has to be done in a 3GL that you can link in. That would be C++ classically. Making a C++ module to link to the QML app is a thousand times more complicated and skill-demanding than the editing of QML for simple app construction.

In the case of my MP3 player above, I needed to use QFileSystemModel and QFileSystemModel::setNameFilters via some C++ glue. Ref to be able to let the end user pick a song to play, which is a glass ceiling. Why can’t there be a built-in function for a file dialog or getting a list of files?

Navigating the Qt documentation online is harder than it should be because the owners/leads have not done essential tagging with canonical html markers. In fact, all of the Qt documentation space is an information architecture mess, in my opinion.

Enter Node.QML


Oleg Shparber had the same thought about C++ complexity, and the QML’s missing functions. He ported Node.js to QML. The stroke of genius aspect to it was making the Node.js module ecosystem available to Node.QML apps too. In the case of the Ubuntu Phone, a way of pulling them down on demand would have needed to exist, and be made as safe as possible. Indeed, there is a larger sandbox issue too, but I’m sure that could have been overcome.

Oleg must have had it working at some stage, but gave up on it as he had other commitments and the Qt people kept diverging their APIs from where he needed them to be for interoperability with Node.QML. The last C program I wrote was 1991, and I’ve never written any C++, so me attempting to work through the rejuvenation of the ‘enhanced’ Qt library Oleg made was always going to reach a limit. Meaning, I gave up too as I don’t have any C++ buddies who’d pair with me on the completion of that.

A technology like Node.QML and a built-in editor on the Ubuntu Phone would have been the game changer that 3rd/4th/5th ranked phone platform needs to complete with the #1 and #2 of Android and iOS, especially as QML apps could be deployed to those two platforms too. At least, that’s the experience of the excellent V-Play in Austria.

Qt has an experimental Lisp binding here. No QML aspect to that though, as that wouldn’t by Lispy.

Much closer to what we’re looking for is QML-Rust. Jos van den Oever has some great examples from only a couple of months ago

Note too that I whined about QML’s squandered opportunity previously.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
qt ,ubuntu ,mobile ,ubuntu phone

Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}