13 ms·
Lessons Learnt Moving a GTK Application from Go to Ada
- zerr 5y agoNo GTK 4?
- smoldesu 5y agoWhy would it be?
- Conan_Kudo 5y agoGTK 4 is not available on any released Debian version. The author stated he's working on Debian, so there's no way he could choose GTK 4.
- pavon 5y agoAt the time the author started this port GTK4 likely hadn’t been released at all let alone have bindings for languages like Ada.
- sp1rit 5y ago> let alone have bindings for languages like Ada. 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.
- FredPraca 5y agoThe problem is that GtkAda is called a thick binding which means that a lot of C-like code is refactored to Ada-style one. So it's just not a simple generation.
- Jtsummers 5y agoThick bindings aren't refactored code, they're a different interface. "Thin binding" means a shallow interface, possibly even autogenerated from C header files. "Thick binding" is usually abstracted, creating proper Ada data types (including the normal restrictions on them), different functions and procedures (perhaps bundling common sets of activities that would be a series of calls in the base C library), adding Ada tasks if its sensible to the system (which it may be, like wrapping around a network library, you can have the network connection handled in its own task).
- FredPraca 5y agoI know but I didn't want to dive into details but you're right, this may need clarification
- _vdpp 5y agoIt’s also worth mentioning that gcc has a command-line flag -fdump-ada-spec that will generate an Ada spec (.ads file - Ada version of a .h) from a C header for easy binding with C libraries.
- mftb 5y agoI really liked this write-up and I'm getting curious about Ada, after completely ignoring it for a very long time. 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.
- ainar-g 5y agoA reasonable write-up. I would really like them to elaborate on what GUI libraries besides Fyne they used and what issues they've encountered. Gio[1] has been fairly popular, and Tailscale's Android client is written in it, iirc. [1]: https://gioui.org/ https://gioui.org/
- davb 5y agoThe demo on the Gio page is badly broken for me (Chrome 99 on Windows 10) - it’s mostly black, with what appears to be a text area in the middle with black text on black background. Triple clicking text doesn’t work. There’s no right click menu (as in native text areas) to show copy/paste/select all. There’s no visible scrollbar so it wasn’t obvious I could scroll down to see more UI controls. Overall it’s a terrible advertisement for the UI toolkit and seems typical of most immediate mode GUIs.
- badhombres 5y agoI'm curious why there isn't a push for more support in desktop gui for Go. 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?
- Thaxll 5y agoOne thing is probably that FFI in Go is not on the same level compared to other languages, so binding to existing in C/C++ is not that popular.
- ainar-g 5y agoIn my opinion, there may be two types of problems. 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.
- oxplot 5y agoThere seems to be a POC that attempts to load dynamically linked libraries on linux (and elsewhere on windows) without CGO: https://github.com/golang/go/issues/18296#issuecomment-468477837 https://github.com/golang/go/issues/18296#issuecomment-46847...
- badhombres 5y agoValid points about FFI. That makes me think if Go devs cared enough about Desktop GUI, then they would try to make that weak point stronger. Their focus is elsewhere (networking, cli tools, web) which doesn't rely on FFI as much.
- mrlemke 5y agoI have goofed around a little bit with GUI programming for Go. Fyne is incomplete, but I did find it relatively simple to slap something together. It may turn out to be a good cross-platform toolkit in the future, but I didn't like the requirement on OpenGL. Not my choice, but the utility needed to run on Windows 7 and I don't like updating drivers on the machine (risky). 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.
- oxplot 5y agoMy Archlinux installer [1] uses fyne and I found it to be quite easy and straightforward to use. My use case is quite trivial though so not sure how that scales. [1]: https://github.com/oxplot/raspberrypi-archlinux-installer https://github.com/oxplot/raspberrypi-archlinux-installer
- henning 5y ago> There does not seem to be a generally agreed-upon central repository for such information in Ada. There's https://alire.ada.dev/ 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.
- pyjarrett 5y agoIt's being built up a bit at a time and some of the older more mature libraries have been or are being put into it.
- benibela 5y agoI have been doing my GUI programming in Pascal 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.
- jonpalmisc 5y agoI love doing UI programming in Pascal, but I miss sane build systems and package management from other languages when I use Lazarus or Delphi. If Lazarus were more popular and had a better library ecosystem, I’d probably use it a lot more.
- badsectoracula 5y agoFor Lazarus at least you can download and install packages from inside the IDE using the Online Package Manager found in the "Package" menu.
- benibela 5y agoUnfortunately, they seem to have the attitude: we have standard libraries. Any library you need is already bundled with the default install of FPC/Lazarus
- Arnavion 5y agoQt is at Qt6 now, haha.
- lights0123 5y agoQt6 still doesn't have a lot of modules ported to it though, as it really hadn't been around that long.
- 5y ago
- cdelsolar 5y agoHas anyone used Wails? Would this be a good choice? It looks great: https://github.com/wailsapp/wails https://github.com/wailsapp/wails
- dbotton 5y agoI’d take look at GNOGA for Ada (or CLOG it’s Common Lisp brother) to future proof your GUI.
- MaxBarraclough 5y agoIt's helpful to include a link: http://www.gnoga.com/ http://www.gnoga.com/ 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?
- dbotton 5y agoSince it uses a browser for rendering, new innovations are likely to show up in browser before gtk (can use GNOGA with browser apis for tts, web rts, speach rec, etc) and same with likelihood to a new platform. For example GNOGA can be used on mobile (there is at least one mobile app currently using it) it is used on embedded platforms for UIs etc.