We have moved to a new Sailfish OS Forum. Please start new discussions there.
2

JavaScript API for app development [answered]

asked 2014-03-01 13:43:26 +0300

tokaru gravatar image

updated 2014-03-02 14:16:35 +0300

I wonder whether there is any chance to see a JavaScript API (or wrapper application), allowing acess to SailfishOS's backend (or at least most important parts of it) without the need to write C++ code, like

  • Subscribing to phone events
  • isolated file system and database access
  • Controlled access e.g. to contacts, gallery, location, camera...
  • register timers
  • etc.

Advantages

  • Spread: a lot of people know how JavaScript
  • Easiness: getting started with JavaScript is very easy, whichever technical background people come frome
  • Security by default: apps can only access what is published through the API and can easily be isolated (they definitely should be); implementing a fine-grained permission control for apps on top of this API would be easy to do
  • Clarity: the limitations of JavaScript and a well-structured API would make it easy to spot the possibilites/functionalities to be used
  • If I understood correctly, there is already JavaScript support in Qt, so this language would fit perfectly into the technology stack

As a consequence, I would expect more developers to contribute apps for SailfishOS. Maybe app security would even be out of question then - why not have isolated apps based on JavaScript (with strong limitations) and mightier programs allowing additional functionalities with C++ programming (and thus, requiring more trust into the developer, like current applications)?

Not sure whether all of this is feasible, but if so.... I'd love to have it :)

Edit: as pointed out by @Fuzzillogic and @MartinK below, Qt Project already offers a substancial API for QML, allowing access to backend functionality via JavaScript.

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by foss4ever
close date 2014-03-02 03:27:08.846877

1 Answer

Sort by » oldest newest most voted
5

answered 2014-03-01 16:07:24 +0300

Fuzzillogic gravatar image

QML is a Javascript based language, and as such all your requests are already fulfilled. However, I've once read that QML is what HTML5 should have been for apps, and as former web developer, I totally concur. Pure web tech (HTML, CSS, plain Javascript) is an mediocre platform at best for writing apps.

But if you really insist, from the FAQ:

Q:Will you support HTML5?

A: Yes we are studying Cordova Qt which is an open source version of PhoneGap.

edit flag offensive delete publish link more

Comments

all your requests are already fulfilled

Hmmmm - I don't think so (even though I'd love to be taught otherwise :)) - e.g. is there a JavaScript method to retrieve the geolocation or let the user take a photo with the camera?

Today people are building really nasty things with JavaScript, so I wouldn't call it "pure web tech"... and why do you regard it as mediocre? Not that I am a big fan of JavaScript, but it is getting it's job done... and for those who like typed languages etc. there's also TypeScript or Dart :)

Please note that I don't suggest to replace QML with HTML.

Cordove Qt might be interesting, but the project does not seem to be that active, last commit was one year ago...

tokaru ( 2014-03-01 16:42:26 +0300 )edit

You mean something like the QtQuick Positioning and the Camera elements ? :)

MartinK ( 2014-03-01 18:59:48 +0300 )edit
2

@tokaru: I have plenty of HTML/JS/CSS experience, but once I worked with QML on the N9 and now Jolla, I'm confident to call webtech "mediocre" for app development. Even more specialized variants, like Tizen, don't cut it. Admittedly, it's been a while since I've seen that code. But using QML was the first time I actually had fun while creating a nice, consistent GUI.

QtQuick does provide a familiar JS runtime, including stuff as XMLHttpRequest. And there's also HTML5-like Canvas support.

Fuzzillogic ( 2014-03-01 19:51:50 +0300 )edit

@Fuzzillogic@MartinK wow, looks as if you both really taught me better, somehow I managed to overlook the QML examples :-/ This seems to be what I have been looking for, great :) And @Fuzzillogic it wasn't my intention to suggest app development with HTML/CSS/Javascript for Sailfish. From what I saw so far, QML is fine - I just had the impression that I need to back it with C++ code to access backend funtionality. Thanks for proving me wrong, actually this is exactly the thing I intended to request :)

tokaru ( 2014-03-01 21:03:54 +0300 )edit

Question tools

Follow
2 followers

Stats

Asked: 2014-03-01 13:43:26 +0300

Seen: 654 times

Last updated: Mar 02 '14