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.

all 24 comments

sorted by: hot top controversial new old
[–] 10 points 2 days ago

GTK is probably the most well known GUI library for C.

  • source
  • [–] 5 points 1 day ago (2 children)

    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.

  • source
  • hideshow 2 child comments
  • [–] [S] 1 point 1 day ago (1 child)

    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?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 1 day ago

    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.

  • source
  • parent
  • [–] 7 points 2 days ago (1 child)

    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.

  • source
  • hideshow 1 child comment
  • [–] 3 points 2 days ago* (1 child)

    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

  • source
  • hideshow 1 child comment
  • [–] 2 points 2 days ago (3 children)

    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.

  • source
  • hideshow 3 child comments
  • [–] [S] 2 points 2 days ago (2 children)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 1 day ago*

    You may consider:
    https://www.gtk.org/
    or
    https://wiki.libsdl.org/SDL3/FrontPage

    GTK 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.

  • source
  • parent
  • [–] 3 points 2 days ago* (3 children)

    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.

  • source
  • hideshow 3 child comments
  • [–] [S] 5 points 2 days ago (1 child)

    What is the better alternative? Or is there one?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 1 day ago* (last edited 1 day ago)

    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.

  • source
  • parent
  • [–] 2 points 1 day ago

    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).

  • source
  • [–] 1 point 20 hours ago (2 children)

    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).

  • source
  • hideshow 2 child comments
  • [–] [S] 2 points 19 hours ago (1 child)

    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.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 18 hours ago

    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.

  • source
  • parent
  • [–] 0 points 2 days ago (2 children)
  • [–] -1 points 1 day ago

    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.

  • source