Paul Hammant's Blog: Node.QML would have been the key to the Ubuntu Phones's success
An article re news that Ubuntu for phones and tablets is dead. At least Canonical are abandoning it, and a volunteer group at UBPorts is going to attempt to take it forward.
So I own a Meizu Pro 5 Ubuntu phone. I don’t use it because its 4G is not compatible with T-Mobiles’s 4G frequencies in Manhattan, and I cannot exist in a shrinking 2G world. It is a really nice all round device, though.
Consider a tiny QML app
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 make 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
}
}
}
}
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?
Glass Ceilings
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 1000x 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 m opinion.
Enter Node.QML
Oleg Shparber had the same thought re C++ compexity, 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.
Other QML possibilities
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.