@michalfita @skade @jannem @mjg59
Move semantics, elephant in the room, ...
@jannem @mjg59 that’s a good read. Thank you for sharing!
Also: I now hope much more that C stays around.
Because xcb tried to establish a different path. A machine-readable protocol definition that Guile actually used directly to create bindings¹. But xcb hadn’t even reached widespread adoption when Wayland broke it.
So one reason why C is around is that C stayed around. And seeing the lifetime of xcb, attempts to replace C bindings give me more worry than hope.
@ArneBab @jannem @mjg59 As the author of XCB, I'm a lot more optimistic about that particular story. I do wish more people had migrated Xlib-based code to use XCB directly, and it's unlikely to happen now since most new development is going into Wayland; that's all true. But:
In the context of FFI, there are lots of examples of equivalent ideas. I like IDLs in general, and the WebAssembly Component Model as a specific case study. We have alternatives to relying on C as the least common denominator for cross-language interop, if we choose to use them.
@jamey It’s not the approach of xcb I dislike, it’s the volatility of the infrastructure.
xcb solved the latency problem of X11 and the protocol description made it possible to build a solid API in Guile by creating a language parser that uses the description directly as code.
But Wayland broke tools using it by not preserving compatibility, so now that API can’t be used anymore.
While one idea lived on, they broke the most important concept from C: don’t break other programs.
@jannem @mjg59
@jamey Any new format that wants to challenge C headers must provide stability.
Otherwise programs using it will die frequently when the API they use changes and the original dev no longer has as much time as during original development.
I like the idea xcb championed, but as long as those using it embrace volatility (just one more breakage, promised!), sticking to C bindings will be a more future-proof strategy.
@ArneBab @jannem @mjg59 I'm not going to disagree with your general conclusion: I agree that if you want cross-language function calls, you need a way to do it that's going to stay pretty stable over time. (Although, as the original essay points out, C headers do not provide complete stability either.)
But I will say that invoking XCB is not an argument that supports your conclusion. If you hand-write Guile X-protocol bindings that use C FFI to call libXCB, what you get will not be better than what you could produce by using the XCB protocol descriptions. You'll still have an X protocol client, and that still won't let you talk directly to a Wayland compositor!
@jamey My point is: I loved how XCB did it.
The problem that causes newer approaches to actually bring more problems than benefit is not that they aren’t better. (sorry for the double negation)
It’s that they aren’t given the time to get sufficient adoption because the time between breaking infrastructure changes is shorter than the time needed to get wide adoption, so every new approach will worsen the fragmentation.
(I need to find a clearer way to make that point)
1/2
@jannem @mjg59
@jamey As long as a philosophy of breaking stuff pervades free software infrastructure, a new communication description can’t spread widely, because the new tools using it get broken again before the new way is established, so C remains the one that works for most tasks.
So: I loved how XCB did it. But the ones who committed to it (guile-xcb) got the short end of the stick, because their work was destroyed by infrastructure changes that didn’t come from xcb but still hit.
@jamey Correction: SDL eats *parts* of the changes …

Yet another urban myth re-appeared on social media the other day, one which regularly does the rounds and has done so for many years since about 1937. In essence a series of connections are made to establish that the huge solid rocket boosters used by NASA had to be transported by rail whose rails were set a certain distance apart, a standard width first determined by the ancient Romans. The historical connections espoused are tenuous at best and do not really stand up to critical thinking. So,
@mjg59 /me fondly recalls that paper from Drepper from 20 years ago.
Aaaanyway the point that C is a protocol is very true.
But the flip side to that is: there are no pervasive cross-platform, multi-language protocols other than it.
If you e.g. see WASI as an attempt to rectify this, for one it's basically XKCD 927 (https://xkcd.com/927/).
But even if it catches on, an IDL based approach basically concedes that some underlying protocol is *forever*.
Might still be the practical way "out".
@jens @mjg59 @kyle_pegasus something something that old paper about how fork() is terrible but shapes OS design if you need to support POSIX
(ah, https://www.microsoft.com/en-us/research/wp-content/uploads/2019/04/fork-hotos19.pdf )
@mjg59 I have a bunch of thoughts about that, half formed.
But I reference WASI also because it's one of those things with some potential on the one hand, but it fails for much the same reason other tech does: how it's actually supposed to work is well hidden.
The best I've gotten out of it is that it implies WASM is the new protocol to replace C, and for that specific purpose, it's a pretty flawed choice.
All they seem to write about it is the sugar on top.
@mjg59 @iris_meredith unless we also create a cffi alternative for Fortran (fffi?) and ftypes.
(I am old and lack a proper sense of humor. Going back under my rock now)
@mjg59 @iris_meredith @gabriel
If you write all the needed functions the libc library provides into a language specific system library, you can escape a lot of C APIs, until you need to communicate with kernel ABIs. Then you're back at wrapping the language native APIs into a C ABI to be able to the syscalls.
And what will make it even more fun ... You'll need to do that for each single OS platform you want to support, to have something being portable.
This kind of stunts is something you only can afford to do on specialised embedded single purpose systems where you need to have as little code running as possible, to be able to fully audit all possible call chains - like in criticial secure systems for aviation or nuclear power plant systems and such like. It won't ever happen on general purpose systems at all.
We're basically stuck with C ABIs until the day someone is successful replacing it something new and better AND provide all the applications people need and want to use at the same time. It will be a revolutionary paradigm shift if someone is capable of pulling that one off. And I'm not holding my breath.
@mjg59 @dazo @iris_meredith @gabriel I have an idea! Let's wrap all this ABI stuff in XML!
*runs away veeeerrrry fast*
@dazo @mjg59 @iris_meredith I am a fan of cffi and ctypes. Saved my behind lots of times. The effort needed to replace it is untenable in my view and not sure it is worth someone spending the next 20 years to do it just for the sake of replacing things. At least not if it doesn't become some fundamentally limiting factor in software evolution.
Pardon the social awkwardness on full display in my previous comment.
@BenAveling @jenesuispasgoth @mjg59 @iris_meredith
… aside from multidimensional arrays being in the opposite order between C and FORTRAN. 🙄
@BenAveling @mjg59 @iris_meredith @JeffGrigg
That one isn't that hard to adapt to. Just use linearized arrays! 😁
How I imagine the Fortran gods in their slumber:
https://www.scientificamerican.com/article/how-do-whales-and-dolphin/
@LapTop006 @mjg59 @jwz that sounds scary, can you summarise?
The only modification I had in any of my code was an two byte sequence that makes a null, which is technically not utf8 valid but works as a way to code a null in a C style utf8 string when needed.
@LapTop006 @mjg59 @jwz Wow, well I guessed the null, and in some ways it is a shame that is not valid UTF8 as putting a null in a string is hard, but it would mess sorting to do it that way. The lack of longer sequences, and hence using surrogates is, err, interesting.
But as @jwz says, Oh my god! (or someone's god)...