
Qt for WebAssembly Technology Preview - fantasticsid
http://blog.qt.io/blog/2018/04/23/beta-qt-webassembly-technology-preview/
======
freedomben
Really surprised and saddened by the negative comments here. Qt is an amazing
framework that has been around for nearly 30 years. Developing with it is a
great experience, probably the most enjoyable coding I've done.

I have faith that the Qt project won't spend time shipping this if it doesn't
offer advantages. Give them time, and a little benefit of the doubt based on a
very long history of excellence.

~~~
xpaulbettsx
I'm not sure I buy that, are you saying that the only reason that Qt hasn't
completely taken over writing native software on (even desktop! not to mention
mobile where Qt also works), is a marketing problem?

I would argue that Qt's problem is:

* Licensing is expensive (look it up, you can't just use it for free for large-scale commercial projects, contrary to what many people believe)

* Getting started with Qt is painful and integrating it into an existing codebase even moreso - get ready to suffer with C++ linker nonsense

* You have to write in languages that are not particularly enjoyable to ship a production application (C++, JavaScript but without The Nice Parts of modern JS web dev)

* The "deploy" bit is completely left to the reader, Qt doesn't help you write apps and ship them end-to-end. Contrast this with Electron which has a pretty strong (albeit a bit mysterious) packaging and auto-update pipeline

Qt experts will argue on all these points, "It's a library, it shouldn't do
XYZ", but at the end of the day, Qt is a _means_ to ship Desktop and Mobile
Software, and by ignoring the entire Developer Experience from end-to-end,
they miss the mark.

~~~
mehrdadn
My main problem with Qt is just that it doesn't feel native, it's as simple as
that. This trumps all other problems like the fact that it's a bazillion
exabytes and painful to set up etc.

~~~
flukus
It certainly feels more native than web/electron, swing, XUL, GTK and just
about every other cross platform technology. It's about as good as you'll get
without a native client for each platform, which will always be the best
option.

The only other options is the hybrid approach which uses native widgets like
wxWidgets, but this means you're limited by the lowest common denominator.

~~~
roryisok
I used to care about the native feel, but now as long as something has a good
UI I don't really care that much. Case in point, visual studio code. The file
menu is native and that's about it. The rest is html / JavaScript and it's a
great interface. I don't care that the buttons don't match whatever OS theme
I'm using. The web never has.

~~~
Can_Not
> Case in point, visual studio code.

I think most people consider visual studio to be an exception, not the norm.
Whether or not visual studio's performance success represents what the typical
developer should be expected to get when writing idiomatic JavaScript in
Electron has probably not been fairly evaluated in the face of popular
performance slugs like slack.

~~~
roryisok
I was talking about nicely designed non-native UX/UI. Why are you talking
about electron performance?

------
keyle
This reminds me of a time, when I used to work for a very large company. After
an unfortunate amount of meetings and powerpoint presentations about ubiquity
and compatibility, we ended up putting a Flash VM inside a Java client, to
read HTML.

Oh boy, sometimes you just walk away from a crash, but you're never the same.

~~~
alde
I think this is misdirected criticism. WebAssembly runs at almost native
speeds on a single very lightweight "VM".

~~~
ori_b
I think this is perfectly relevant criticism. Browsers are a huge amount of
overhead to add to a cross platform toolkit, for virtually no benefit.
Distributing full fledged programs like this via browsers is simply going to
be a shit user experience, on top of the already terrible user experience that
browsers give.

~~~
krapp
Webassembly isn't designed or intended to run exclusively in the browser,
though. A lot of people seem to assume that native webassembly apps would be
packaged with Electron but I think that when the language matures a bit, it
should be possible to get thinner native VMs without the unnecessary bulk of a
browser.

~~~
littlestymaar
Why would you package it in Electron? AFAIK, webassembly is mainly intended to
be run on the web, in the browser. The main goal being you don't need to
install anything.

Building a native app to wasm to package it into Electron sounds really weird
to me. OK there's a security benefit thanks to sandboxing, but using Electron
as a sandbox is really a strange idea.

And when it comes to portability, if you build you native app to webassembly,
it can run anywhere. But if you add Electron to the mix, you need to build a
different version for each platform, which destroy the portability benefit. If
your app can be built on wasm, it can probably be compiled for different
platform already. Adding Electron to the mix doesn't change any of that.

~~~
yoz-y
Browsers still can not access the filesystem correctly, can't communicate with
most of the devices you could plug into your computer, can't reasonably use
keyboard shortcuts and so on.

Electron can.

~~~
littlestymaar
But the native version already does that! What can electron do that the native
version cannot ? The point of electron is that it let you write code once (in
JavaScript or something that transpile to js, like TypeScript or Elm) and
built multi-plateform software. But if you have a native software that can be
built in wasm, it also can be built on Windows + Mac + Linux. Why using
electron in that case?

Electron is great if you don't want to write native code (and deal with the
debugging complexity of C or C++). If you already have a cross-plateform
native app in written with Qt, why the hell would you want to put that in
Electron?! And remind that if your C++ isn't cross-plateform already, you
won't be able to build to wasm.

~~~
yoz-y
You are right, in this case it does not make sense since you can already
distribute the Qt compiled version.

~~~
littlestymaar
And even if you want to ship native code within your Electron app, why would
you use wasm instead of the native code with ffi ?

~~~
yoz-y
This would of course have to be tested but there might be less overhead? I
haven’t used FFI but they mention that it is significant. I have written a V8
add-on using NAN and the performance is very good (as in passing relatively
large arrays between C++ and Node is in the few microsecond range)

------
mappu
Note that Qt has two separate technology previews for porting Qt apps to run
in the web browser:

Qt WebGL streaming (qplatform/qpa plugin):

The Qt binary runs on your PC as normal, but instead of opening an X11/Win32
window, opens a network port. You can open the URL in a browser to see the
interface. Only one connection is allowed / only one user can interact with
the app at a time.

Technology preview since 5.10, will be "TP2" status in 5.11. See
[http://blog.qt.io/blog/2017/11/14/qt-webgl-cinematic-
experie...](http://blog.qt.io/blog/2017/11/14/qt-webgl-cinematic-experience/)
and [http://blog.qt.io/blog/2017/07/07/qt-webgl-streaming-
merged/](http://blog.qt.io/blog/2017/07/07/qt-webgl-streaming-merged/)

Qt for WebAssembly:

The entire QtWidgets / QML libraries are compiled to WASM and run clientside.
There is no server-side component.

Will be released as a technology preview in the upcoming 5.11 release.

~~~
bhouston
They should port the rendering of the qt components to Dom/css with a web
assembly backend. That would seem like a web app but allow for c++ code reuse.

~~~
mwcampbell
I think that would be more feasible with something like wxWidgets or libui
[0], which already use each platform's native widgets.

[0] [https://github.com/andlabs/libui](https://github.com/andlabs/libui)

~~~
bmn__
GTK isn't native on a huge number of users' desktops, including mine. It
wouldn't be so bad if the GTK CADTs would stop breaking style configuration
with each release.

------
giancarlostoro
Say what you will, we need these kind of projects in order to push forward
WebAssembly (and eventually JavaScript may not be the only dominant language
for front-end web development). I'm curious how much of the canvas they're
taking advantage of if any of it. It's quite exciting. I might wind up porting
one of my existing Qt applications just to try this out and see what that
would be like.

~~~
k__
Wasn't it more like: most people know JS so everything (server, mobile/desktpp
apps, etc) was made with it.

And not like: JS is so shitty, better we make everything with it, even if
there are better alternatives.

?

~~~
Xuper
It was the latter I am afraid. Then the general hype started and now we have
insanity like Electron etc. Don't worry web assembly is here to help JS, not
to replace it ;-).

~~~
giancarlostoro
I wouldn't be surprised to see WebAssembly only applications once WebAssembly
matures and can "stand on it's own free" honestly. JavaScript for sure will
hold dominance for many, many years however.

~~~
yoz-y
WebAssembly can not manipulate the DOM though no? Web applications got popular
also because creating UIs with HTML and CSS is easy.

~~~
k__
It probably will be able to do this in the future.

------
emilsedgh
I could find a few live demos [0] although some are broken

[0] [https://msorvig.github.io/qt-webassembly-
examples/](https://msorvig.github.io/qt-webassembly-examples/)

~~~
realusername
I just have "NetworkError" for all of them.

~~~
car_invasion
It's rare I have to disable ublock, but that helped me.

~~~
realusername
aaaah, thanks a lot! I did not made the link with the error name...

------
emilsedgh
I'm seeing a ton of snarky comments, but isn't this what exactly WebAssemly is
about (which I see people praising everyday as it opens up possibilities)

~~~
k__
I had the impression WASM was about writing parts of web apps in it, so they
get more performance.

I can't imagine many people would like to download a 60GB AAA game or
something like Photoshop to run it in the browser.

~~~
eslaught
Actually, if I could have Photoshop run in a browser, with its full feature
set, and running at >90% of full native speed, that would be pretty awesome.
And I'd even be willing to wait for the multi-GB download as long as it only
happened once (with small deltas thereafter).

Not saying we're there yet, but it's not hard to see where WASM could take us.

~~~
ori_b
I can see where web assembly could take us, but I am confused about why people
seem to want to go there.

~~~
pjmlp
Because Flash, Applets, .NET, Silverlight, ActiveX, NaCL,....

Difference being that WASM is kind of blessed format.

~~~
ori_b
The problems with the alternatives you listed wouldn't have been reduced with
more blessing.

~~~
pjmlp
So what makes Flash => WebAssembly more acceptable than Flash?

~~~
ori_b
When did I say webassembly was more acceptable than flash?

------
kodablah
There is emscripten-qt that built Qt apps w/ Emscripten for a while now[0]
(since asm.js and WASM should not change anything even though it hasn't had
updates in a few years). Appears this uses Emscripten as well. I wonder how
this compares at a tech level.

0 -
[http://vps2.etotheipiplusone.com:30176/redmine/projects/emsc...](http://vps2.etotheipiplusone.com:30176/redmine/projects/emscripten-
qt)

~~~
TazeTSchnitzel
Thank you for pointing to this, I'd seen it before and was reminded of it.

It's impressive and exciting it can run a full app like KATE. It feels as if
you're running a Linux VM inside the browser, but no!

------
brian_herman
[https://www.destroyallsoftware.com/talks/the-birth-and-
death...](https://www.destroyallsoftware.com/talks/the-birth-and-death-of-
javascript) The end is neigh

~~~
pier25
Is it common for people to call it YavaScript?

~~~
pier25
Apparently it's a joke: [https://www.quora.com/JavaScript-programming-
language-Why-do...](https://www.quora.com/JavaScript-programming-language-Why-
does-Gary-Bernhardt-say-YavaScript-instead-of-JavaScript-in-his-talk-The-
Birth-and-Death-of-JavaScript)

------
mwcampbell
Unfortunately, this port seems to lack accessibility for blind people and
others that require assistive technology. My conclusion is based on the demos
linked elsewhere on this thread. [0] I have no idea how to make a conventional
GUI toolkit accessible with ARIA, but I hope the Qt developers figure it out.

Edit: Forgot to mention that I tested on Windows with a screen reader and
Chrome.

[0]: [https://msorvig.github.io/qt-webassembly-
examples/](https://msorvig.github.io/qt-webassembly-examples/)

~~~
kuschku
Accessibility like that likely won't be possible, as the only way to get
accessibility in browsers is with the DOM, which is very limited in
functionality.

If you wish to have accessible applications, you'll need to run the native
applications instead.

~~~
mwcampbell
What if some application developers don't make a native version available?
Accessibility should be the default on all platforms, not something that
application developers have to go out of their way to support.

~~~
kuschku
> Accessibility should be the default on all platforms, not something that
> application developers have to go out of their way to support.

Complain to the browser developers then, they’re the reason why this is so
hard for Qt running on the web.

------
arusahni
So, you're saying I could use a QTWebView in the browser?

~~~
codetrotter
No no no. Obviously you should compile your existing Qt application to
webassembly, put that in a QTWebView and have that be your application.

~~~
gpm
And we will run this all on nebulet, an OS being written for a pure web
assembly user space [0].

But seriously, you say this like it's horrible, but a bytecode/VM that allows
us to abstract over code that runs in a browser/code that runs a native
app/code that runs in a device driver is really exciting. The fact that it
allows infinite nesting is a inevitable mildly beneficial side effect to
having interoperability.

[0] [https://github.com/nebulet/nebulet](https://github.com/nebulet/nebulet)

~~~
infinite8s
So basically Squeak, a 25 yr old technology that still runs bitexact across
all it's virtual machines.

------
solarkraft
This (assuming it's Qt Quick) opens the door for a competitor to HTML for web
apps.

~~~
gmueckl
Except this looks like it would be a big download, wouldn't it? And how would
this UI interact with assistive applications like screen readers?

~~~
candiodari
According to my chrome network tab cnn.com now comes to 1.7 megabyte. Without
ad blocking, over double that.

Let's say 20% of that is images (it's actually less) ... it is not a problem
to fit quite an extensive C++ program in that.

~~~
gmueckl
Have you checked the sizes of the Qt libraries lately? QtCore or QtWidgets
larger than 5MB each. Qt is simply an enormous amount of code. I currently
can't get any of the wasm files for the demos to load to compare those,
though.

------
jkollross
How long until someone uses this to make an Electron app?

~~~
weberc2
Once we compile Chromium to webassembly, we can run Qt in Chromium in Chromium
in Slack!

~~~
cmsj
See also [https://www.destroyallsoftware.com/talks/the-birth-and-
death...](https://www.destroyallsoftware.com/talks/the-birth-and-death-of-
javascript)

You jest, but this sort of thing probably is the death of almost all native
software, sadly.

~~~
oblio
There are some things we mourn. Nobody mourns cross platform distribution of
native apps. Anyone who does hasn’t had to manage the insanity of installer
apps and of papering over a million different OS versions and app versions.

It’s 2018 and we still don’t have a common, wide spread, OSS framework for
self-updating native apps that runs on all the major desktop operating
systems. And let’s not even go into app store territory...

~~~
pjmlp
Well it would be great if there weren't hundred of FOSS desktop variants....

~~~
michaelmrose
This seems to be a common complaint as if we were all standing on a life raft
pushing it down with the collective weight of our respective keisters.

If only some people would stop contributing to creative work you don't see the
value of and distributing it for free on the internet!

At present you have

Debian and a bazillion ubuntu derivatives using a debian package.
ubuntu/debian are going to have different versions of some libraries but you
can package deps with your app.

Arch and derivatives have a pkgbuild. This is quite simple if anyone cares
about your app your arch users will probably upload one for you to the arch
user repo.

Fedora and suse have rpms. These will be similar but not identical.

3 packages and you can cover most of your potential users.

In the future you reasonably may expect to be able to distribute a flatpak and
be done with it.

~~~
pjmlp
It is not only about package formats, since even when the format is the same,
the expected directory layouts or installed libraries will be completely
different.

No one really took FHS seriously, each installation is a special snowflake
with its own GUI and dynamic libraries story across Linux variants is even
worse than it was on other OSes.

------
grondilu
Looking at software that uses Qt[1], I'd say I'll be impressed once they have
compiled one of them, say for instance Stellarium, to Wasm. It'd be great to
see how a full software, not just a toy demo, behaves in webassembly.

1\.
[https://en.wikipedia.org/wiki/Qt_(software)#Applications_usi...](https://en.wikipedia.org/wiki/Qt_\(software\)#Applications_using_Qt)

~~~
davidkhess
On a comment to the article:

> To give an example, the app I’m working on
> ([https://github.com/OSSIA/score](https://github.com/OSSIA/score)) is
> roughly 300kloc of Qt / C++ code and compiled in WASM almost from the first
> try. I’m still having freezes in some places but overall it’s working great.

------
alex7o
If everybody has a problem with Qt why don't we see gtk on more systems. The
last time I checked you can use gtk on win/Linux/Mac it is free, and it sort
of works.

------
IncRnd
[https://github.com/msorvig/qt-webassembly-
examples](https://github.com/msorvig/qt-webassembly-examples)

------
chuckdries
Honestly, I can't wait to try it. This is exciting.

------
zengid
It would be great if this could be done with JUCE too!

~~~
CyberDildonics
Also FLTK, both would be very small compared to Qt.

------
thomasfl
No demo page?

------
keyle
"Because you can doesn't mean you should." -common sense.

But then again, since 2017, anything that can happen will.

~~~
ehsankia
On the one hand, I find it funny that people are using bloated electron to
avoid writing Qt code, and now you can write Qt code even on the web!

On the other hand, if you already do have a Qt application, then you can maybe
get a webapp for almost free?

~~~
joezydeco
See, this is what I get for procrastinating.

I've been asked by a customer to port my recent Qt app to iOS. Got the
equipment, was about to get the development environment set up, got XCode
installed....and now this.

This is pretty exciting if it all works as expected.

EDIT: aaaaaaand after trying some of the demos at
[https://github.com/msorvig/qt-webassembly-
examples](https://github.com/msorvig/qt-webassembly-examples) using a brand
new iPad (iOS11/A10 Fusion core) using Safari, half the examples run out of
memory, and the other half aren't touch enabled. Hmm.

EDIT2: Firefox iOS, same set of crashes.

~~~
joezydeco
EDIT3: got it to cross compile and load off a server. And....ugh. It's got a
long way to go. It works, at least. Still too large for a mobile device
however.

