
Create Desktop Apps with HTML5 and Go - folknor
https://www.phoronix.com/scan.php?page=news_item&px=HTML5-Golang-Desktop-Apps
======
rolleiflex
I'm doing something similar (Go-based desktop app) with Aether
([https://getaether.net](https://getaether.net)), without requiring any
additional tools.

The short version is, I have an Electron app, but the extent of my JS is just
skin — the UI. The JS talks to two Go daemons which do the 99% of the work.
It's also much more memory efficient than doing it in JS, and allows for
massive parallelism. So you get best of both worlds, speed / clarity of Go,
and well-developed JS UI patterns (Vue). It works well, with the caveat being
a tradeoff in complexity in incorporating gRPC to let daemons talk to each
other.

Here's the source code:
[https://github.com/nehbit/aether](https://github.com/nehbit/aether)

------
tracker1
Electron is too bloated and heavy, and doesn't meld with the desktop... hey,
lets create a new system that uses the same bloated/heavy bits as electron and
also the UI that doesn't blend well.

edit: okay, so it doesn't have to download as much since it uses the already
installed chrome, meaning you have to conform to ??? from an app perspective
to your JS... you may as well just use electron or carlo

~~~
kjksf
The project they describe IS a Go port of carlo (it's even named lorca).

carlo/lorca is meaningfully different than electron.

Electron takes chrome code base, adds node.js code, a bunch of other stuff and
makes it an SDK. As a result Electron-based app consists of a copy of chrome a
copy of node and maybe 2% of the total size is unique to the app.

carlo/lorca re-use Chrome instance already installed so 100% of the size is
unique to the app.

That removes the biggest complaint about electron i.e. bloat of shipping 100+
MB of SDK to deliver 100 kB of app.

~~~
chatmasta
I think the biggest complaint about electron is not bloat of shipping the app
(a one time download, not a big deal in modern times), but _running_ the app.
Since each electron program uses its own instance of Chrome, there is no
resource sharing and so memory consumption is high.

~~~
bpye
Absolutely. I don't really care about the size on disk, a little bit, but not
really. What I really care about is some application using far too much RA -
Chrome (and by extension Electron) is notourious.

------
JeanMarcS
Well, on one hand it will certainly lighten the ressources needed.

On the other hand, you don’t know on what version of Chrome/Chromium you’ll
land so you won’t be able to use specific API for sure.

But for having developed in the end of the 90’s a web kiosk software, based on
Internet Explorer (I think it was IE5 back then), software that still have
last versions running (no one, including myself, would thought it’ll survive
that long), I will sure have a look closer on the project if you can intercept
the before navigate event (or whatever the name is with Chrome)

~~~
johnisgood
> On the other hand, you don’t know on what version of Chrome/Chromium you’ll
> land so you won’t be able to use specific API for sure.

Is it just me, or the API changes and breaks way too often? I recently wanted
to make an extension and I Google'd here and there, and all the code posted
just a few months ago is now obsolete. It is crazy!

~~~
giancarlostoro
I think WebExtensions might be to blame for that, but without more information
as to what wasn't working I couldn't say.

------
candiodari
Man, that slidedeck is frightening for someone who wants functional
applications:

    
    
      Well-designed and attractive typographymakes content meaningful.
      Animation makes important parts standout and helps with micro-interactions.
      Onboarding, common for web andmobile apps, helps more than traditional"F1" button.
      Visual trends may change and it shouldnot be hard to update the UI withoutrewriting it all.
    

The result is what used to be described as "flash websites": everyone has
their own UI, with custom animations that mean something entirely unique to
that application which may or may not make sense to you.

But I could not explain this half as well as these articles about Flash. They
also apply to HTML5.

[https://www.nngroup.com/articles/flash-99-percent-
bad/](https://www.nngroup.com/articles/flash-99-percent-bad/)

------
zbruhnke
Every time I see these things I just sit in relative disbelief trying to
figure out how PWAs have somehow not taken off yet.

Perhaps this year when they finally come to Mac too (they already work on
Windows and Linux) it will finally happen. then again with the Mac App store
I'm not sure that fits the Apple "vision" (if you can call it that anymore)
either.

Either way its sort of maddening to see this as I think PWAs are the right
answer for these questions and yet people keep bringing new and unnecessary
solutions to the table

~~~
solarkraft
May I ask what you use to install a PWA on Linux? I am so far using WebPin,
but it doesn't offer some PWA APIs and is based on Chrome instead of Firefox.

~~~
enobrev
Chrome seems to allow it after enabling it in chrome://flags. The only
desktop-installable PWA I've been able to find thus far is pokedex. Pretty
cool to see it show up like any other app on ubuntu, though.

------
alexandernst
I fail to see how this is any resource-lighter than Electron. It still uses a
browser. It might or it might not be Chrome, but it's still a browser, so it
will certainly use, give or take, the same amount of resources the average
browser takes.

The only thing I do see as an advantage is the reduced size in the
distributable. But, imho, size really doesn't matter these days.

~~~
imustbeevil
What application renders HTML/CSS/JS using less resources than a browser?

~~~
opan
A document reader, perhaps. Something like zathura/mupdf that can read epub
files. I think epubs use html/css for formatting. I could be a bit wrong here.

~~~
shakna
Yes/no.

Epub 3.x does support a substantial subset of HTML5. However, there are only a
small number of core media types that can come with an expectation of working.

Atop of that, most styling can be expected to be ignored.

The CSS-section of the spec [0] lays out most CSS fits the spec, with a few
exceptions, and a few additions, but that most readers won't make use of them.
That is absolutely the case.

Most of the speed from an ereader over a browser comes from these parts:

\+ You can safely ignore most CSS, or all CSS and just use Author-Defined CSS
profiles.

\+ You can safely ignore any of the script tags you encounter, though they are
part of the spec.

\+ You don't need to support every media-type out there.

\+ Most documents won't be HTML - they'll be the well-defined XHTML, meaning
you need less cascading rules to transform the document into something well-
formed.

[0] [http://www.idpf.org/epub/31/spec/epub-
contentdocs.html#sec-c...](http://www.idpf.org/epub/31/spec/epub-
contentdocs.html#sec-css)

------
chenzhekl
In case you are interested, there is a flutter based GUI framework for Go,
which looks promising. [https://github.com/Drakirus/go-flutter-desktop-
embedder/blob...](https://github.com/Drakirus/go-flutter-desktop-
embedder/blob/master/README.md)

------
spacenick88
Can anyone tell me what mechanism would prevent any other software on the same
system from intercepting the connection to Chrome? This isn't really an issue
when running with X11 on Linux as any app can grab text from another window
but e.g. Wayland provides much better barriers between apps.

~~~
kjksf
The way this works: that the program locates chrome executable, launches it in
a special mode, chrome prints which port it allocated for that instance to
stdout, the program parses stdout to find the port and opens websocket
connection.

See:
[https://github.com/zserge/lorca/blob/master/chrome.go#L50](https://github.com/zserge/lorca/blob/master/chrome.go#L50)

How would that be intercepted? Only the program that launches that chrome
instance can read chrome's stdout.

It's no more or less secure than the same concern with a regular Chrome.

------
mikewhy
Webview seems interesting. Go/C++ to do native stuff and use the systems web
view to render the interface. Seems like the best of both worlds.

------
AnIdiotOnTheNet
It is a bit weird to me that people are so intent on reinventing HTAs.

~~~
jjtheblunt
HTAs ?

~~~
T-A
[https://en.wikipedia.org/wiki/HTML_Application](https://en.wikipedia.org/wiki/HTML_Application)

------
sfifs
This looks really interesting! I actually love browser/html/javaScript as a UI
significantly over "native" but creating Electron based stuff always has me
worried shipping a gigantic bloat and keeping it updated.

------
marticode
Alternative that uses the system webview rather than requiring Chrome:
[https://github.com/zserge/webview](https://github.com/zserge/webview)

------
zemnmez
the weakest point in systems like this is usually the mechanism by which the
local process communicates with the browser. it's very hard to secure such a
mechanism properly as there's no official API for it

this claims to use the chrome devtools debug protocol, which I believe is
usually entirely unauthenticated. i would not be surprised if someone can
compromise this system via this protocol

edit: this happened already with node in the case of CVE-2018-7160

------
chmike
HTML is really bad to create GUI applications, and it uses javascript. It's
not a pure Go desktop application.

A Qt equivalent in go would be worth considering.

------
irq-1
There is also [https://sciter.com/](https://sciter.com/)

It's non-free but you can "Use Sciter in binary form as it is published on the
site" so cgo with bindings and the downloaded binary.

[https://github.com/sciter-sdk/go-sciter](https://github.com/sciter-sdk/go-
sciter)

------
api
An alternative is this:

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

There are Go bindings here:

[https://github.com/andlabs/ui](https://github.com/andlabs/ui)

------
lucasmullens
Is it worth mentioning the 5 specifically anymore? It doesn't seem to be even
using HTML5 features.

~~~
itslennysfault
Still a buzz word...... apparently.

------
steve1977
Or, don't.

------
__alias
Electron is bad? Your website is bad and I don't trust anyone with a bad
website

