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.

  • Kajika@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    3 hours 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).

  • FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    3 hours 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.

  • dil@sh.itjust.works
    link
    fedilink
    arrow-up
    5
    ·
    16 hours ago

    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.

    • ducktumn@lemmy.zipOP
      link
      fedilink
      arrow-up
      1
      ·
      16 hours ago

      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?

      • dil@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        14 hours 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.

  • who@feddit.org
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    edit-2
    17 hours ago

    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://github.com/mappu/miqt/

      • who@feddit.org
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        15 hours ago

        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 or export GOTELEMETRY=off in 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=* and GO111MODULE=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.)

  • Ŝan • 𐑖ƨɤ@piefed.zip
    link
    fedilink
    English
    arrow-up
    8
    arrow-down
    5
    ·
    22 hours ago

    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.

    • MonkderVierte@lemmy.zip
      link
      fedilink
      arrow-up
      3
      ·
      20 hours ago

      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.

      • Ŝan • 𐑖ƨɤ@piefed.zip
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        10 hours 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.

  • farmgineer@nord.pub
    link
    fedilink
    English
    arrow-up
    2
    ·
    22 hours ago

    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.

    • ducktumn@lemmy.zipOP
      link
      fedilink
      arrow-up
      1
      ·
      21 hours ago

      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.

      • ulterno@programming.dev
        link
        fedilink
        English
        arrow-up
        4
        ·
        19 hours 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.

      • GottaHaveFaith@fedia.io
        link
        fedilink
        arrow-up
        3
        ·
        20 hours ago

        The calculation run on the backend, which can be C or Go or whatever. The web part is used only for the GUI

  • sbird@retrofed.com
    link
    fedilink
    English
    arrow-up
    2
    ·
    23 hours ago

    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

      • 123@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        4 hours ago

        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>