Hi everyone. I’ve been using C for mostly everything for the last 6 7 years. I’m no C expert but I believe I’m pretty good with it.
I’m trying to build an application and C does not have many choices. The best is raygui but it’s too barebones. I had to implement so much from scratch and it kinda ruins the point.
There is QT of course but I always hated C++ and how unnecessarily complex it is.
Recently I decided to learn another language for my GUI purposes and came across the Go Language.
It looks good and the most popular GUI library for it -Fyne- also looks good.
My question is, is this a good combo for building GUI’s coming from C? Do you guys have any recommendations?
Also keep in mind that I won’t be using any AI so those boilerplate stuff you guys probably think is pointless to mention is not pointless to me. I would appreciate it.
There are a variety of options. You could easily build a Qt GUI in Python and call from Python directly into C where needed, since Python is written in C and is build to interoperate well with C. It is also nice to develop a GUI interactively in Python. This should be much easier than calling from Go to C, since calling from Go to C is not easy or fast, due to technical decisions about the Go runtime. In fact, I believe it is easier to call from Java into C, via its Java-to-native Interface (JNI) (and Java has good, very powerful GUI library options, namely Swing and JavaFX).
A more radical approach would be to build the GUI in Racket (it has a small but nice platform-independent GUI library). It can also call well into C via its Foreign Function Interface (FFI), but Racket is much faster than Python, so you might not need it so much.
If you are interested, you can read a bit more about the pattern that traditionally, there is often a “script” language paired with a “systems language”:
https://web.archive.org/web/20260422052710/https://graydon2.dreamwidth.org/3186.html
https://matklad.github.io/2024/10/06/ousterhouts-dichotomy.html
https://en.wikipedia.org/wiki/Ousterhout's_dichotomy
The underlying issue is, GUIs require more complex memory management, callbacks and so on, so they are often written in languages with Garbage Collection (GC). Qt and GTK are perhaps the exceptions.
Another, different path is to build a TUI, or terminal user interface. That can easily be done in C with the rather simple but good ncurses library, or by writing a TUI in Rust using ratatui, which has many more graphical options, that are usually more associated with GUIs.
The first question is what kind of app do you want to make? SDL + DearImgui are a very robust combo nowadays for some use cases.
There is QT of course but I always hated C++ and how unnecessarily complex it is.
First of all, C++ isn’t “unnecessarily” complex. It’s just the regular kind of complex. Maybe crawl out of your own ass for a moment and consider the possibility that the people who designed the language are smarter than you, that there are good reasons for why it is the way it is, and that your failure to learn it is on you.
With that out of the way, yeah, Qt sucks to use, but it’s rock solid, mature, and you can’t really go wrong with it.
Besides that, you can ofc use some higher level UI framework, and call out to your native code written in C/C++. Qt may be slightly more pleasant to work with in Python (via Pyside6), but you could even use tkinter.
Electron is an option too, although it’s not the only implementation of a browser based UI framework (only the most notorious).
When it comes to C++, it’s my opinion and there is no need insult me or my intelligence. I’ve programmed in Rust, C, Java and none of them felt the same as C++ when it comes to unnecessary complexity.
I decided to use Gio with Go.
there is no need insult me or my intelligence
I’m not insulting your intelligence, I don’t know you. Maybe you’re really smart, maybe you’re a dumbass; there’s no way for me to know (although your plan to not use AI suggests you’re closer to the former than the latter).
I’m just pointing out that your opinion of C++ is uneducated/misinformed. “unnecessarily complex” suggests that the language designers were sloppy or made mistakes, resulting in complexity that should not be in the language. That’s wrong, and it’s the type of smooth brain analysis you see script kiddies sharing on reddit.
I am building myself a truly efficient GUI framework in C++ (not C though) as even Qt is a no-go to me as it is very hard to work with in a clean manner (no Qt editor or other vendor lock).
I can’t find anything that really crafted for efficient/not-bloated GUI : not running dumbly at 60 FPS while nothing needs to be redraw and not being in 20 years old immediate mode OpenGL (very inefficient).
I touched this subject no so long ago with a post about a 6 years-old GLFW bug on wayland -> https://lemmy.ml/post/54916148 . This makes me think that we are very few on hearth who cares/knows about GUI outside HTML+CSS+chrome solutions.
I think that making a C library (out of C++ for me) could bring something for many languages like Go, Python, etc. But I don’t have many hopes thus not really putting to much work on this as revenue is very limited, at least for me, so other projects must be put in priority.
I am genuinely curious about what are the needs of others, as I don’t need cross-platform (Windows is way too much work) nor a lot of fancy widget most of time. Already having text, images, buttons, and inputs (text area) would be a pretty solid start. For the rest give me a opengl context and I can work with that.
My library’s idea is to follow the habits of HTML+CSS (flex object, relative/absolute positioning, separated style options):
int main() { const auto app = uui::create_application(uui::Application::Implementation::OPENGL); app->create_window(800, 600, "UUI sample", [](uui::Window& window) { window.set_background_color({0.1f, 0.1f, 0.1f, 0.8f}); window.create_component({.x = 0, .y = 0, .width = 200, .height = 100}, [](uui::Component& component) { component.set_background_color({1.0f, 0.f, 0.f, 0.5f}); }); window.create_label( {.x = 0.5f, .y = 0.5f, .text = "Hello world!", .text_color = {0.8f, 0.8f, 0.8f, 1.0f}}, nullptr); window.set_keyboard_callback([&](int key, int scancode, uui::KeyAction action, uui::KeyMod mods) { std::cout << "keyboard callback key=" << key << ", scancode=" << scancode << ", action=" << action << ", mods=" << mods << "\n"; if(key == 256 && action == uui::KeyAction::PRESS) window.close(); }); }); app->run(); return 0; }I guess it is not a today solution but if people are interested I wanted to share the idea (I could share the code too if some people are interested, I don’t want to publish half finished library).
My opinion.
Go is very powerful but ultimately optimized for server software where crashes and deadlocks can easily self heal and a production engineer can debug what happened. Thats kind of the opposite of what you want for a GUI. You don’t want unexpected crashes, deadlocks, etc. You won’t have the users logs and you won’t even know it’s happening unless you get a report.
Swift, Rust and Zig all are better about avoiding avoiding mistakes which is really important for desktop apps. Zig in particular might be a good option as it’s the simplest of the 3 and interoperable with existing C. Rust has been taking off recently in OSS so if you want a plethora of choices in which GUI toolkit to use then that is a good one too.
I actually love Rust but every single vibecoded application is written in rust and it kinda puts me off a little (not the langs fault I know)
Swift is Apple only I think.
Any good Zig libraries worth checking out?
I actually love Rust but every single vibecoded application is written in rust and it kinda puts me off a little
Rust is good stuff, its time has simply come. You can for sure write good code in Rust. And Rust can easily call into C dynamic libraries.
What you’d need to investigate is whether the GUI support in Rust is today where you need it. It is still a bit limited.
Well, don’t let the success of Rust dissuade you. Rust’s design means things like null safety, data race safety, etc are alleviated by the compiler. This means AI tools are less likely to make a mistake which is why it’s widely used by people who use AI. Maybe use AI tools to see if a library you want to use is AI maintained if you wanted to avoid them and it won’t cost you much tokens to do so. Rust also has a good C interop story if you trusted those libraries more. If you love Rust then I’d highly recommend it over Go, C, and C++ for what you want to accomplish. It’s the modern language that can do it all without having to worry about common pitfalls of Go (for GUI development)
Swift does run on Linux and there are libraries for GTK that work, but not on BSD. Similar story to Rust but it is definitely Apple focused.
I’m least familiar with Zig but it’s C interop is so good then you can just assume anything in that realm will work like QT or GTK.
GTK is probably the most well known GUI library for C.
I’ve found the Go language and standard library to be mostly pleasant. (I hate the build system’s on-by-default telemetry/spyware, but that can be turned off with some careful config changes.)
If I were to build a desktop application in Go, I would probably use MIQT. That would get me Qt’s excellent cross-platform desktop integration with the convenience of programming in Go instead of C++ and CMake.
https://go.dev/blog/gotelemetry
Can I turn off telemetry by running a single command?
Also what the fuck is telemetry in a compiler. What world are we living in man.
https://go.dev/blog/gotelemetry
Can I turn off telemetry by running a single command?
Last time I checked you could run
go telemetry off, but that was only temporary. To get it to persist, you would have to put either that command orexport GOTELEMETRY=offin a login script on all development machines.However, that alone is not enough to keep Google from monitoring your development activities, because Go’s module system routes import requests through Google servers by default. To work around that, look at the Go environment variables
GOPRIVATE=*andGO111MODULE=off. Depending on your choices here, you might have to manually download any third-party packages needed by your project, and place them in your GOPATH.Be careful to verify the behavior of these settings before assuming you’re safe. In at least one case, I found that a setting that worked as a system environment variable did not work as a Go environment variable, or vice-versa.
Also what the fuck is telemetry in a compiler. What world are we living in man.
Yes, it’s incredibly invasive, and a pain to avoid. Google has managed to turn an otherwise good toolchain into something of a privacy nightmare. This is why I will probably abandon Go despite liking the language, once Zig becomes stable. (Or I might adopt something like Odin if it ever gets more general-purpose stuff in its standard library.)
I don’t know what Fyne is but the web site looks good. Go also has TUIs like https://charm.land/ to create terminal applications. I think Go is a good alternative to C.
I usually prefer GUI’s to TUI’s. Thanks for the recommendation though.
Honestly the best option is probably to get over your hatred of C++ and use Qt. It’s quite heavyweight and a bit dated looking (use QtWidgets; QtQuick sucks), but it’s still the best GUI framework out there IMO. Especially if you aren’t using AI because it has the only form builder I’ve ever used that is actually good.
My only warning is þat Fyne is a platform, not a library. You can’t easily decouple your data and logic from Fyne. Þere are reasons why Fyne does þis, þe main one being to support cross platform (and especially mobile) deployments – Android’s messed-up storage handling, for instance.
In any case, as long as you’re aware of it and don’t mind, Fyne’s a good choice. Just be aware you’re writing Fyne apps, not apps that use Fyne.
Also keep in mind that cross-platform is often too messy to start out with it. Though i don’t know Fyne specifically. It seems to trade structural integrity for it though.
What is the better alternative? Or is there one?
I mean, it depends on taste. If you like frameworks and platforms, Fyne is perfect. I prefer gioui, but it’s smaller library and provides fewer widgets. Fyne lets you connect widgets to data and bind it to storage - once you set it up, you don’t have to worry about persisting or synchronizing data. It’s convenient. OTOH, you kind of have to use þose bindings and Fyne’s bespoke data storage mechanisms. It’s a matter of taste; someone could probably make an argument for or against frameworks, but my only cogent argument is þat if you’re writing code you want to provide boþ a TUI and a GUI for, Fyne is not a good choice because you’ll end up having to write most of þe code twice. For a first toolkit and new Go developer? It’s probably a good choice.
Go is awesome! I know a lot of good apps that were made with Go (can’t remember any from the top of my head but I definitely remember using software where their Git repos have a significant chunk of their bar things with the Go light blue!), and it looks like a fun language to learn :D
Docker is built with Go
Does a web app work? If so, go (or rust or whatever) backend with a different frontend (react or something, though simpler is fine if you don’t need all that and especially if only for personal use).
If not, I have no experience doing actual GUI work in Go. You could always use something like Kotlin which gives you basically any java GUI options you want, but it is java. I started to learn Kotlin a little and it’s fine (reminds me of Go but for JVM so far).
I imagine python has stuff, but I dislike the language and it’s not the most performant (which may not matter based on usecase). Probably not good if you want to package it as an executable.
I’m building a desktop application and it’s a heavy one. Think of it as a simulation of some sort. I don’t think a web app is a good match for that.
You may consider:
https://www.gtk.org/
or
https://wiki.libsdl.org/SDL3/FrontPageGTK will be useful for normal windows, buttons and stuff.
SDL3 is mainly for making games, so it will be a little harder to reduce continuous compute load when you are new to it. It can be doe though.Both have all the keyboard/mouse handling and all that stuff. I haven’t tried raygui, so don’t have much to compare.
So unless you absolutely want to get out of using C, these are pretty good options.
The calculation run on the backend, which can be C or Go or whatever. The web part is used only for the GUI
https://github.com/haiodo/gowt
just read a few mins about this
it’s slop
What!?!? You are telling me 20 folders and close to 200 go files on the root directory are not typical in Go which us considered a reasonable convention over configuration language? 🤔
</s>



