News for hackers. Stuff that matters.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by WanderPanda on Saturday August 19, 2023 @08:27PM (#37194770)
Would be really nice if there also is a „library mode“ without relying on callbacks in addition to the „framework mode“ [1]

[1] https://www.brandons.me/blog/libraries-not-frameworks

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by MobiusHorizons on Saturday August 19, 2023 @08:49PM (#37194895)
This is typically not possible in gui programming, because the underlying display library typically owns the event loop, which fundamentally makes it framework like
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Saturday August 19, 2023 @10:00PM (#37195306)
You cannot really get rid of callbacks (or well, you can, but there is no practical benefit and it can be very messy) for things like widget events (e.g. when the user clicks a button).

But you could provide an API that allows the toolkit user to do their own main loop instead of having the toolkit do that. There isn't really that much of a benefit though - in theory it makes mixing with other libraries that might handle UIs easier, but in practice (having worked in a codebase that did that by mixing two toolkits - because of migration that never finished) tends to become a mess and for anything else an "idle callback" will work just fine.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by PaulDavisThe1st on Saturday August 19, 2023 @10:50PM (#37195602)
GTK relies on the Glib event loop, which is in a separate library (and also used by Qt, at least optionally).

You can, if you want to, reimplement the abstract API of the Glib event loop, and use that with GTK instead.

Note also that on macOS, GTK has to integrate both the Glib event loop and the event loop used by NeXTStep/Cocoa, because it is not always the case that the same one is in control (e.g. during drag-n-drop processing). It handles this "just fine", for some definition of "just fine".

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Sunday August 20, 2023 @07:45AM (#37198215)
Yeah i was referring that is possible that toolkits to do that in general (not just GUI toolkits, AFAIK even something like Freeglut which normally uses callbacks has an API for manual main loops), not specifically about Gtk.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by hsjqllzlfkf on Sunday August 20, 2023 @12:48AM (#37196207)
You CAN try get rid of call backs if you have nice language like Julia that can inline the call back
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Sunday August 20, 2023 @07:43AM (#37198202)
You mean using anonymous functions? This is still a callback, it is just a bit nicer (at least assuming the callback code is short).
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by hsjqllzlfkf on Sunday August 20, 2023 @12:20PM (#37200552)
No, I mean by inlining.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by mostlylurks on Sunday August 20, 2023 @01:21AM (#37196344)
"Not possible" is an exaggeration. For a retained mode GUI library, you could, for instance, have the event loop of the library run on a separate thread, and provide functions to modify the widget tree and read events that have occurred since the last time events were read, allowing the user of the library to operate the library without being coupled to the event loop in any way. For an immediate mode GUI library, things are even simpler, because the library doesn't even have an event loop in the first place, placing the responsibility of implementing one on the user of the library.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Sunday August 20, 2023 @07:56AM (#37198269)
No need to mess with threads in retained mode libraries, just have a call or two to run a single iteration of the event loop, e.g. Freeglut has glutMainLoopEvent() which only handles a single event. A toolkit of mine has ff_pump_events(), ff_has_events(), etc. Normally applications are expected to do a call like "return ff_run()" at the end of main() but they could do their own main loop if they want using these functions.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by bmitc on Sunday August 20, 2023 @05:06AM (#37197402)
What do you mean by "library mode" with respect to GUI functionality? How would you use a GUI library different than a framework in a way that you couldn't do with a framework?
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by timw4mail on Saturday August 19, 2023 @08:48PM (#37194890)
Why is it always the worst library wrapped? GTK is terrible for anything other than Linux.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by MobiusHorizons on Saturday August 19, 2023 @08:50PM (#37194899)
What would you rather? If you want something else, why don’t you make it?
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by mpol on Saturday August 19, 2023 @09:57PM (#37195294)
That is a bit unfair, a GUI library is a huge undertaking. I did see some projects move to Qt, but not many. It is with C++ quite different from GTK. Not sure how FLTK fares, but I don't see many projects using that.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by PaulDavisThe1st on Saturday August 19, 2023 @10:48PM (#37195593)
Gtkmm is the canonical C++ wrapper for GTK, and 98.32489% of it is lovely.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by MobiusHorizons on Saturday August 19, 2023 @11:14PM (#37195750)
My point is that if you think the wrong things are being wrapped, it may be profitable to self reflect. It may mean what you want is not aligned with what people with the time and ability to build things like this want. If you think everyone else is wrong (which to be clear is not necessarily a bad thing) it can be worthwhile to attempt to do that thing yourself, and find out why no one else has done it. In the best case, you get what you wanted. In the worst case you learn why it hasn’t been done.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by dragonwriter on Saturday August 19, 2023 @11:18PM (#37195768)
> That is a bit unfair, a GUI library is a huge undertaking. I

But its not about a GUI library, its about a wrapper for one. After all, if its “the worst” library getting wrapped, then obviously there’s a lot of easy opportunities to wrap a better library.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jdiff on Saturday August 19, 2023 @08:53PM (#37194918)
If it's always the worst that's getting all the indie dev attention there's probably something to it that you're ignoring or prioritizing lower than the people putting in the legwork.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Saturday August 19, 2023 @10:07PM (#37195346)
There aren't really that many GUI toolkits in C[0] (which is what makes it easy to make bindings to other languages) - it is pretty much Gtk and... Motif. Ok, XForms too, probably.

Toolkits in other languages need some C intermediate - e.g. Lazarus has a Qt backend for LCL and since Free Pascal can only use the C ABI there is a "qt5pas" library written in C++ that exposes a C API that programs must link against. This can be annoying.

[0] ignoring Win32 as that is Windows-specific... unless you consider writing against libwine but i don't think anything uses that as a toolkit

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by seabass-labrax on Sunday August 20, 2023 @06:47AM (#37197893)
Your [0] is actually a pretty neat idea - Wine is small and well-supported, and kind of cross-platform by definition. Even better if you explicitly ensured compatibility with both Linux and Windows, for instance with CI testing every build for API errors. After all, GTK kind of has a Wine-style compatibility layer when running on Windows; it's just often statically linked into the binary rather than installed separately.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Sunday August 20, 2023 @08:14AM (#37198382)
Winelib (not libwine, my bad) isn't really that great for non-Windows stuff, it is really meant for porting applications that use Windows API calls and it really takes over everything.

For example you need to compile the program using "winegcc", which creates a shell script that calls Wine to load the application (the application is compiled as a .so so it can use Linux libraries and calls, it isn't a Windows program). This in turn loads the full Wine server with its various services and Windows compatibility layers. And chances are you'll need to use "winemaker" to build the code (it generates a Makefile for you).

Just as a test, compiling and running a very simple "hello, world" program that calls MessageBoxA to show a message box and exits still loads a bunch of processes (checked via ps -A) and dumps a bunch of diagnostics to the terminal.

Also, IMO while Wine's GUI bits generally work, they do have a lack of polish even compared to their Windows 95 counterparts.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by smoldesu on Saturday August 19, 2023 @09:28PM (#37195130)
> for anything other than Linux.

I bet you have fun opinions on Cocoa and WinUI too.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by bmitc on Sunday August 20, 2023 @05:11AM (#37197431)
Those don't make any claim to be able run on other OS platforms, though.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Saturday August 19, 2023 @09:49PM (#37195245)
IMO Gtk4 (the one being wrapped) is terrible even on Linux :-P. Gtk peaked at Gtk2 and Gtk3 is passable with the right theme but i can't say i liked any Gtk4 program i've seen (fortunately Gtk4 doesn't seem to have much of an uptake so far).
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by circularfoyers on Saturday August 19, 2023 @10:57PM (#37195648)
There are hundreds of apps on Flathub that already use GTK 4. Bottles, Easy Effects, Mission Center, Amberol, Celluloid, are all popular (more than 60,000 installs from Flathub) examples of apps that are using GTK 4. I personally use all of them and think they are some of the best looking apps available on Linux.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by ekianjo on Sunday August 20, 2023 @03:36AM (#37197000)
They are popular because they fill a need. Not because their UI experience is stellar or something.

Its not like you have a choice to run them with a non Gtk4 UI anyway

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jdiff on Sunday August 20, 2023 @08:55AM (#37198660)
You have a choice to install a non GTK4 program with an identical function. And yet 60K people chose the GTK4 option. You may not like the UI, totally fine, but clearly plenty of people do when they're looking through a catalog of just screenshots and pick the GTK4 option.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by ekianjo on Sunday August 20, 2023 @09:01AM (#37198704)
please give me examples of programs that have exactly identical functions
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jdiff on Sunday August 20, 2023 @10:21AM (#37199402)
Amberol? Celluloid? Mission Center? Practically every toolkit out there has one of each these apps before it even hits version 1.0 just as a demo of its capabilities. There's dozens if not hundreds.

Bottles has PlayOnLinux or Lutris. I'm not familiar enough with the Linux audio landscape to know any Easy Effects alternatives for it off the top of my head. Nobody's locked into anything or being forced into GTK4. Heck, Celluloid is just straight up a wrapper around MPV.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by ekianjo on Sunday August 20, 2023 @11:03AM (#37199847)
Bottles is much better designed than PlayonLinux (which is a dead project) or Lutris which have absolutely dreadful UX paradigms. They are not even equivalent piece of software, and that has nothing to do with GTK4.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jdiff on Sunday August 20, 2023 @11:20AM (#37199986)
Then let's take that one example off our friend upthread's list and I fully believe their point still stands very strong. Users use the GTK4 apps that devs chose GTK4 to build with, and that stands even when an app has competition in its space. The evidence given demonstrates that pretty clearly.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Sunday August 20, 2023 @08:04AM (#37198317)
> There are hundreds of apps on Flathub that already use GTK 4

Might be that i also avoid flathub, but i haven't seen much use of Gtk4 in the applications i use myself.

> think they are some of the best looking apps available on Linux.

Ok, thanks for the information but i think otherwise, i dislike how Gtk4 looks. TBH i also think Gtk3 looks bad but i've got a theme for that. Perhaps i might find a decent Gtk4 theme too.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by lockhouse on Saturday August 19, 2023 @09:59PM (#37195304)
GTK is a C library, which makes it much easier to make language bindings for compared to libraries written in C++.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by cozzyd on Saturday August 19, 2023 @11:11PM (#37195718)
It's amazing how "modern" languages don't bother having a stable ABI, relegating themselves to being silos.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by dragonwriter on Saturday August 19, 2023 @11:15PM (#37195755)
Languages generally don’t have ABIs. Including C.

(A particular C implementation on a particular platform may have an ABI, and that may be stable, but that’s not a language feature.)

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by badsectoracula on Sunday August 20, 2023 @08:01AM (#37198295)
That is pointless hairsplitting, in practice in every mainstream platform where programs can use shared libraries there is a C ABI. That it is not defined by the C standard doesn't mean it doesn't exist, it only means that the C standard cannot be relied on for the ABI - and that is all that it means wrt. to the C standard. But very few programs limit themselves only to what is defined by the C standard.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by josefx on Sunday August 20, 2023 @06:39AM (#37197859)
Almost as amazing as C programmers acting as if they had some kind of official ABI spec. when they also just get whatever their compiler writers feel like.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by duped on Sunday August 20, 2023 @09:52AM (#37199138)
A stable ABI ties you down in a lot of ways that compiler and language authors don't place a ton of value on early in the lifetime of a language. And to be honest, the necessity of one is a bit over played. Dynamically linked system libraries are going the way of the dodo.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by cozzyd on Sunday August 20, 2023 @12:29PM (#37200626)
Well, there's a reason why GTK has bindings to every language and most other GUI frameworks don't.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by PaulDavisThe1st on Saturday August 19, 2023 @10:48PM (#37195590)
It's so terrible that we've been using it for more than 20 years for a 600kloc cross-platform digital audio workstation.

It's so terrible that it's FLOSS-iness encouraged us to fix problems with the macOS (then OS X) and windows aspects, and contribute them back (mostly) to the project.

It's so terrible that when I meet other developers we swap stories about their chosen cross-platform GUI toolkit, and things seem to pretty much even out.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by HexDecOctBin on Sunday August 20, 2023 @03:26AM (#37196963)
GTK doesn't have accessibility on Windows and macOS, correct? Do you implement your own a11y? Because music as a profession seem to have a higher proportion of visually-impaired people, and I would have though that any DAW, etc. would make sure to cater to them to be competitive in the market.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by zogrodea on Sunday August 20, 2023 @05:31AM (#37197551)
I think that was the case, but I remember hearing that GTK4 has made accessibility a priority and introduced some kind of system similar to what ARIA is on the web. Not sure if those accessibility plans were fully realised though.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by seabass-labrax on Sunday August 20, 2023 @06:49AM (#37197907)
Looks like the accessibility features are really extensive now:

https://docs.gtk.org/gtk4/iface.Accessible.html

Look at how many widget classes are listed in the 'implementations' subsection!

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by dragonwriter on Saturday August 19, 2023 @11:16PM (#37195766)
> Why is it always the worst library wrapped?

Because libraries, like languages, come in two groups:

(1) Those that people complain about, and

(2) Those that nobody uses.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jweir on Sunday August 20, 2023 @12:31AM (#37196141)
Fantastic.
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jrm4 on Saturday August 19, 2023 @11:51PM (#37195948)
No, seriously, though -- it does seem bizarre that "a newish library" is one you wrap like this.

I get that its touchy saying that GTK4 is bad -- but I genuinely don't understand why GUI libraries like this appear to break backward compatibility SO OFTEN, with nearly zero (apparent and obvious useful) innovation?

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by seabass-labrax on Sunday August 20, 2023 @06:41AM (#37197861)
GTK4 certainly comes with a lot of breaking changes[1] compared to Gtk+ 3.0 - not least the naming change :) - but you'll probably only need to update a few things in the average GTK application to upgrade. It's not like they've changed the constructor function signature for a GtkButton or something.

The most obvious change to a non-technical observer is of course the new default theme, which I am rather unhappy about because they didn't back-port it to Gtk+ 3.0, so in the context of a GNOME desktop it's now half-and-half old and new theme depending on whether someone has bothered to migrate the application in question. This is slightly unfair of me though, since compared to a mixed Qt/GTK desktop or the average Electron app or even Microsoft products since Windows 8, GNOME is super consistent visually.

[1]: https://docs.gtk.org/gtk4/migrating-3to4.html

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by jrm4 on Sunday August 20, 2023 @12:33PM (#37200656)
I don't develop, but "a few things" DRASTICALLY contrasts with my experience actually trying to use GTK as a user. Number changes in GTK BREAK ALL THE THINGS ALL THE TIME.

It REALLY doesn't make sense to me how badly, e.g. themes break between versions. Offhand, I can't think of too many "standards" that break that badly, it just makes no sense to me that GTK2, GTK3, GTK4 apps simply CANT co-exist. Like AT ALL, without severe uglification.

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by notyoutube on Sunday August 20, 2023 @12:25AM (#37196123)
I'd like to see a comparison to GTK4.jl [1] and GTKObservables.jl [2].

[1] https://docs.juliahub.com/Gtk4/rFcBQ/0.5.0/ [2] https://juliagizmos.github.io/GtkObservables.jl/stable/

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by hsjqllzlfkf on Sunday August 20, 2023 @12:53AM (#37196232)
If you like guis and Julia, this one is outstanding

https://github.com/Gnimuc/CImGui.jl

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by ducktective on Sunday August 20, 2023 @03:45AM (#37197032)
What's the latest status of Windows support for GTK4? Can a binary be cross-compiled for Windows on a Linux machine?
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by seabass-labrax on Sunday August 20, 2023 @06:30AM (#37197820)
Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by asg on Sunday August 20, 2023 @07:00AM (#37197973)
Yes, the Julia ecosystem provides cross compiled binaries for many platforms

https://docs.juliahub.com/GTK4_jll/XRLGj/4.10.5+0/#Platforms

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by lukeh on Sunday August 20, 2023 @05:55AM (#37197662)
Some interesting stuff happening here [1] and here [2] too.

[1] https://github.com/stackotter/swift-cross-ui/tree/main [2] https://github.com/TokamakUI/Tokamak

Re:Mousetrap.jl: a GUI library for Julia and C++ that fully ... by 3abiton on Monday August 21, 2023 @06:02AM (#37207377)
I wasn't aware Julia had such a support on HN!