Lessons Learnt Moving a GTK Application from Go to Ada
github.com
github.com
Webview works ok, and you can get a lightweight Electron-like thing going that uses your existing browser. This reduces binary size greatly. I didn't try any JavaScript frameworks with it, just vanilla JS. You can bidirectional bind between JavaScript and Go too.
What I liked the most was gothic, since Tk looks good enough and runs on Windows 7 easily. Gothic is a Tk binding for Go that is quite simple to use. However, you are writing the GUI in Tk now, and you will either love it or hate it. I do have a bias for Tcl, so it was appreciated.
My use case scenario was supporting an old machine running Windows 7 with mediocre video. I ended up just using Tcl/Tk without Go since it was simpler and reduced a layer (Tcl->Go->C). When it comes to writing small and/or inhouse stuff, I found it easy and fast to just slap out a Tcl/Tk app and call it a day. I can develop on my Linux/BSD box and then just Windows specific bits if necessary and it usually Just Works(tm).
Oh, it should be noted that Python + Tkinter is a decent alternative for those of you needing executables. Pyinstaller is basically a "one-click" and works with bundling Tkinter. Roy Keene has done good work putting together kitcreator for Tcl, but pyinstaller is simpler if you don't understand the magic.
Fyne-cross is a really nice tool that can cross-compile Fyne applications for most popular systems (including android).
The libGL1 dependency under Linux is a fair tradeoff for wide compatibility - the drivers don't have stable ABI so dynamic linking to libGL1 is a must[0].
Python + Tkinter + Pyinstaller works, but does not support cross-compilation, and I've personally had some portability issues with it (e.g. under Linux, the GUI mainloop doesn't work outside of the main thread; under Windows, if you start a Process after setting up GUI, each process will create its own window, so you must start all the Process-es beforehand).
Is it because desktop gui is not as supported in modern times and Go is a recent language that is carrying that attitude or is it because Go attracts more web developers in general and they already have web applications as their solution for a gui?
Maybe something else?
The first is organizational. Maintaining a cross-platform GUI library takes a lot of time, effort, and reasonable knowledge of the platforms it targets, so that would need a dedicated team of at least a few people. Which is not impossible, but you need to actually do this. The closest thing to such project seems to be Gio, but I haven't tried it, so I don't know if it's any good.
The second is technological. Most ways of interacting with (native) GUIs involve FFI, and in particular C. And cgo has known limitations and performance issues, to say nothing about the fact that using cgo make cross-compilation significantly harder. So a lot of Go projects tend to just avoid any project that involves cgo.
Again, that's just my opinion as a Go developer.
Interestingly, Rust originally used a similar memory model to Go, but then when they hit this problem decided to take another route.
This has the unfortunate side effect of making most machine learning also not practical in Go.
That said, I'd like to know more about the limitations regarding machine learning. Presumably most machine learning stuff isn't implemented in C?
The language absolutely is a generalpurpose language, and making great GUI libs with it is certainly possible, as shown by Fyne (yes, I know it's still new, give it time).
That being said, most people using Go build server side code and frameworks with it, aka. things that live as daemons in some rack or in a docker swarm. If there is an front-end to these kinds of applications, it's usually web based.
My impression of the Fyne toolkit was similar to the authors. Overall I'm disappointed in Go's gui situation. After a lot of screwing around with Go's various native gui bindings, I ended up using Webview again, which is a nice package, but has the standard shortcomings of the approach.
Lazarus was a great crossplatform GUI framework to have a native GUI on each platform. You put a button on a form window, and then it calls Win32 on Windows, Gtk on Gnome, Qt on KDE, ... to get their native button.
Unfortunately, it is really lacking maintainers. It still works best on Gtk 2. They have been working on a Gtk 3 version for years. I am not sure if they have been making any progress. I guess the modern way for a Linux GUI is to have a Qt5 version or a Win32 version on WINE.
If Lazarus were more popular and had a better library ecosystem, I’d probably use it a lot more.
About Gtk i'm not sure if it is lack of maintainers or simply lack of interest in the Gtk3+ backends, i remember a discussion from not too long ago in the mailing list where people weren't happy with the breakage introduced by Gtk every major versions. It can be very disheartening to spend years building the Gtk2 backend only to have to make a new one for Gtk3 and before that is finished, out comes Gtk4 breaking things yet again.
But IME the Gtk2 backend works fine. At least personally i wouldn't bother with Gtk3 or Gtk4 as these feel like a waste of time now (though personally i did submit a patch recently with fixes for the Gtk1.2 backend[0] that didn't work for some time now :-P but that was mainly for fun - there might be some practical use for it though as all the necessary .so files are like ~2.5MB, so perhaps it could be used for simple GUI apps on Linux to minimize external dependencies).
There's https://alire.ada.dev/ which is sort of like NPM or Rust crates for Ada. Obviously the number of libraries is much lower and the quality may be unpredictable.
[1]: https://gioui.org/
Overall it’s a terrible advertisement for the UI toolkit and seems typical of most immediate mode GUIs.
[1]: https://github.com/oxplot/raspberrypi-archlinux-installer
The state of their website isn't exactly reassuring. Not so much as a screenshot of their toolkit in action.
If I were writing GUI code in Ada I'd probably use the GTK bindings (GtkAda). They're maintained by AdaCore and are used by the GNAT Studio IDE so the 'dogfooding' factor is there.
How is GNOGA advantageous with future-proofing?
Language bindings for any GObject powered are usually automatically generated from their introspection data (.gir) generated from g-ir-scanner.
So that wouldn't be the issue.