Email or username:

Password:

Forgot your password?
Christine Lemmer-Webber

Rust dev: "Rust is the most superior systems programming language! If you care about performance, you need Rust. Always replace C with rust."

Me: "Oh okay! Most of the places C has taken off and I've used it is in terms of 'performative code lingua franca' libraries like image rendering, etc. Is Rust good for that?"

Rust dev: "OMG Rust is PERFECT for that! You can get the performance characteristics of C but with the safety you need."

Me: "I like safety. So, this means that from my other languages I can dynamically link to rust code right?"

Rust dev: "OMG, dynamic linking is terrible. The mindset in Rust is: always only statically link."

Me: "So how do you want me to link to the Rust library from my other language?"

Rust dev: "Oh I don't want you to link to the rust library, I want you to rewrite the rest of the program in Rust too!"

72 comments | Expand all CWs
Christine Lemmer-Webber

Like, Rust is pretty cool, I'm excited about it sometimes, but people, if you want to be the replacement for C you *HAVE TO EMBRACE DYNAMIC LINKING*. That is the primary role that C has played in the last few decades, being a lingua franca library system. Don't fight it, embrace it!

Pilum::🌞

@cwebber Agreed!

Craig Maloney ☕

@cwebber (trolling)

I'll embrace Rust when I can use it as a scripting language under gcc.

Christine Lemmer-Webber

Since people keep bringing it up yes I know about cbindgen yes I know it's possible, this is me pointing out the irony and downfall of a toxic and self-defeating cultural practice in the Rust community which I have experienced firsthand

ansuz / ऐरन

@cwebber I wrote about this behaviour in the rust community back in 2016 (transitiontech.ca/random/RIIR) and I guess not much has changed since then :blobcat_thisisfine:

bgtlover

@ansuz @cwebber luckily, this is slowly being reverted, in some ways, look at the export attributes and extern crabi rfcs, though I'm not sure about the name of the first one. Thing is, we don't want to rewrite your entire program in rust, but the reason for which it's harder to use dynamic linking in this context is that we don't want to submit to guaranteeing ABI stability, in order to allow maximum leaway for the compiler team or the compiler itself to perform optimisations. Of course, this means that, checksum wise, no two builds would ever be the same, as the compiler might have optimised some things differently. You can always make your crate cdylib and link with it from c, but you have to export the functions manually, upholding the invariants as best as you can. I mean, c++ has to declare something like that, so does swift, which managed better than rust in this regard so I dk what else we could do

@ansuz @cwebberluckily, this is slowly being reverted, in some ways, look at the export attributes and extern crabi rfcs, though I'm not sure about the name of the first one. Thing is, we don't want to rewrite your entire program in rust, but the reason for which it's harder to use dynamic linking in this context is that we don't want to submit to guaranteeing ABI stability, in order to allow maximum leaway for the compiler team or the compiler itself to perform optimisations. Of course, this means...

Arne Babenhauserheide

@ansuz Freenet actually got hit by its decade-long-inactive founder suddenly starting to rewrite something adjacently similar in Rust while gutting the essential features ("privacy is not a goal of …") and putting in crypto-contracts … hyphanet.org/freenet-renamed-t @cwebber

witch hat hacker 🎃 types ver

@cwebber

Me: "I don't like safety. So, this means that from my other languages I can dynamically link to C code right?"

C dev: "Of course! As long as you support the C ABI in your other language specifically, for example using the ctypes module in python, or ffi module in racket, or if you painstakingly write your own C wrappers for library calls that integrate the library you want to call with the language runtime for Java and nodejs"

Me: "wait that sounds awful. how is C the 'lingua franca' again?"

C dev: "maybe you should just write the rest of your code in C too /shrug"

@cwebber

Me: "I don't like safety. So, this means that from my other languages I can dynamically link to C code right?"

C dev: "Of course! As long as you support the C ABI in your other language specifically, for example using the ctypes module in python, or ffi module in racket, or if you painstakingly write your own C wrappers for library calls that integrate the library you want to call with the language runtime for Java and nodejs"

imyxh

@haskal @cwebber I mean yeah, any sort of dynamic linking is going to need some ABI, and supporting that is inevitably going to be some work for someone somewhere. but I think the point stands that dynamic linking still allows for some cross-language compatibility that static linking doesn't really allow at all.

Vertigo #$FF

@imyxh @haskal @cwebber Unless it's built for that purpose. AmigaOS libraries are all statically linked, and they're shared across a wide variety of programs and languages. The OS itself is written as a collection of these libraries (most in C, dos.library in BCPL at one time), which nearly all apps use. Apps take on a variety of languages from BASIC to BCPL to Modula-2 to C to interpreted languages like ARexx.

It's not impossible. Just not done under WIndows or Linux.

Amir Livne Bar-on

@imyxh @haskal @cwebber there's the windows way, that every dynamic library is accompanied by a static library that dlopen()s it and calls it. or at least it used to be this way two decades ago. i'm not sure why they did that but these static libraries can be translated to different languages and implement an ffi internally.

Stroad Warrior

@haskal @cwebber Yeah, it's so annoying that for the C ABI to be the standard, it's necessary for other languages to *actually support the standard *. We should only ever adopt standards that are already supported.

Christine Lemmer-Webber

@cholling @haskal I do think it's annoying that C has become the lingua franca. Rust could provide an alternative, that would be a good initiative on its part. It would still require dynamic linking. Support for the C ABI isn't the primary thing I'm advocating for, it's pointing out that dynamic linking is where C has had the most success.

witch hat hacker 🎃 types ver

@cwebber i don't think i understand your point. currently it's straightforward, using standard tooling, to make a rust dynamic linked shared library and export C headers for it. a lot of mozilla projects are doing this

Christine Lemmer-Webber

@haskal yes, you can do it. but you aren't having conversations with the same people in the Rust community as I have, clearly.

(Notably all the annoying Rust developers are cis dudes, and most of the cool ones are trans girls, who don't typically share this same attitude. Despite the fediverse's reality distortion field, that's not the majority of Rust devs in the wild)

witch hat hacker 🎃 types ver

@cwebber i mean i could write an imagemagick in rust today and export even fully imagemagick-compatible C bindings and have a drop in replacement shared library
i guess i still don't understand the use case you're criticizing here

Christine Lemmer-Webber

@haskal okay I will be very specific about the criticism: it's a criticism of a *cultural* attitude that is anti dynamic linking that I have encountered in Rust. That's not a *tooling* or *technical* criticism. But it is pointing out that this *cultural attitude*, among many but not not all participants (but enough of them), is actually detremental to the goals of being a systems language that upends the problems with C. The counterpoint then is that the Rust community is *encouraged* to *embrace* dynamic linking; this could even be trying to push forward an alternative to the "C ABI" (which doesn't really exist), which I think would be a positive action!

@haskalokay I will be very specific about the criticism: it's a criticism of a *cultural* attitude that is anti dynamic linking that I have encountered in Rust. That's not a *tooling* or *technical* criticism. But it is pointing out that this *cultural attitude*, among many but not not all participants (but enough of them), is actually detremental to the goals of being a systems language that upends the problems with C. The counterpoint then is that the Rust community is *encouraged* to *embrace*...

lonjil

@cwebber @haskal many many Rust libraries have C bindings and no one minds, so I reckon you've had the misfortune of bumping into a shitty minority.

Zumi | nki

@haskal @cwebber I feel like it’s how being the lingua franca like, isn’t it?

Let’s say a you’re a French person who wants to talk to a German person. English being a lingua franca means you are more likely to be able to talk to them in English than forcing them to learn French or vice versa. The problem explodes if you also have a Japanese person in your group, without the lingua franca you’re wasting O(n^2) time learning all the languages to communicate…

Now English being the lingua franca doesn’t mean an Englishman would understand every native language; you’re giving everyone some pain for the forementioned benefit. Even worse it’s not equality, an Australian just has to unlearn some accent words while Japanese people would need to learn a new alphabet, new sentence structure, … But is it worth it? Yea, if you tend to work with other people…

Finally I don’t think that English being the lingua franca means you should be living in the UK (teaching wages suuuuck I’m sorry); being elsewhere has its own benefits, with an obvious downside of having to pick up English…

@haskal @cwebber I feel like it’s how being the lingua franca like, isn’t it?

Let’s say a you’re a French person who wants to talk to a German person. English being a lingua franca means you are more likely to be able to talk to them in English than forcing them to learn French or vice versa. The problem explodes if you also have a Japanese person in your group, without the lingua franca you’re wasting O(n^2) time learning all the languages to communicate…

ليلى النحلة

@cwebber langs that are supposed to be better but don't support like
dynamic linking
distro package management
custom build tooling

irritate me so fucking much. I don't want to download another fucking package manager and repository and deal with all that shit!! just let me use the tools that Already Exist and Work

Diane 🕵

@lunabee @cwebber

What about Ada? It's been considered a safe, high reliability language for decades.

Years ago my university decided use Ada as their intro language, and we all hated it and wanted something more commercially useful. As time has progressed Ada is looking more and more interesting. I think most of the resistance is C programmers get frustrated with the Pascal like syntax.

It looks like it's possible to create dynamic libraries with Ada.

gcc.gnu.org/onlinedocs/gcc-3.3

@lunabee @cwebber

What about Ada? It's been considered a safe, high reliability language for decades.

Years ago my university decided use Ada as their intro language, and we all hated it and wanted something more commercially useful. As time has progressed Ada is looking more and more interesting. I think most of the resistance is C programmers get frustrated with the Pascal like syntax.

Mark Eichin

@cwebber
Ahh. My one brief interaction with rust a few years back was someone (who I don't think considered themselves part of the *rust* community) getting a simple "subvert a c function" via LD_PRELOAD to work in pure rust, which i took as an indication of technical parity; it didn't occur to me that was probably an "outsider" perspective.

Haelwenn /элвэн/ :triskell:
@cwebber Yeah, it's pretty much why we're probably still going to have ImageMagick/GraphicsMagick for the next bunch of years.

Rust honestly feels like they make their own bubble instead of taking operating systems as an existing whole and just replacing bricks from it.
Sean

@cwebber Does Rust not use platform libraries at all? Or is the stance “oh we do dynamic linking when we need to but you don’t get to do that.”

2️⃣tali

@complexmath @cwebber rust uses platform libraries, allows you to build dynamic libraries with C ABI's, etc. the main issue with dynamic libraries in rust is that the story for building dynamic libraries with rust ABI's and using them in your rust code is poorly supported. so usually even when you build a dynamic library you statically link all of your rust dependencies

2️⃣tali

@complexmath @cwebber i definitely agree that rust's ecosystem tends to be hostile to dynamic linking, but it seems like from this thread that a lot of people are getting the impression that rust doesn't allow dynamic linking at all, and that just isn't true

Christine Lemmer-Webber

@iitalics @complexmath Yeah. I added a followup clarifying that it's a cultural problem most especially octodon.social/@cwebber/110707

(And a lot of this comes from inheriting the LLVM toolchain, where that attitude also exists.)

Sean

@iitalics @cwebber C++ tends to have the same issue, though for technical reasons. If it's really just a cultural thing in Rust... well I suppose that's not unexpected, given programmers.

2️⃣tali

@complexmath the technical issues are the same since rust more or less copied c++'s compilation model, down to using the same backend (llvm)

:solar: vivi

@cwebber so. Thoughts on Zig, which can do dynamic linking afaik? And it's also a lot more directly compatible with the c abi due to explicit keywords for it?

Christine Lemmer-Webber

@vv Zig is really cool! I love that the design doc is really short.

:solar: vivi

@cwebber i want to get back into working on the toy game engine i was porting to it

Efraim Flashner

@cwebber
I think that's basically been my experience with rust developers too. I don't care how narrow the constraints are, let me reuse build artifacts and give me something to link to.

F4GRX Sébastien

@cwebber i am horrified that THIS is considered a systems language. Everytime i have approached this ecosystem my feeling has been atrocious. The syntax. The runtime. The restrictions. The myriad of nodejs like online packages. The emptiness of the core libs that require these packages. The number of "unsafe" required to make it work in the kernel. This might not be a shared feeling, whatever

eater

@cwebber oh god I feel you using rust both ways is awful. I have made so many patches for crates so it can dynamically link

and also their insistence on running their own TLS stack and then compiling that in statically to my programs, I love to now be responsible for updating this singular TLS stack, in my application, that is statically built-in, putting all the responsibility on me and requiring me to update

eater

@cwebber is OpenSSL bad? possibly, but at least it doesn't become my responsibility to maintain it, which is placed on the distribution instead

shrimp eating mammal 🦐

@cwebber now I understand why there are 24 bajillion projects like "X, written in Rust", where X is some common thing written in C/C++ that we've taken for granted for years.

mia

@cwebber@octodon.social you can link to rust libraries just fine. you can generate dynamic libraries. they work just like any other language.

Fries

@cwebber rewrite everything in rust 🚀 /sarcasm

João Santos

@cwebber the ability that programming languages have to materialize religious cults around them never ceases to amaze me.

Eragon

@cwebber Yup… why does the rust core team don’t work to get dynamic-linked code working as well as statically linked code ?

(And for once it’s coming from someone who love rust)

aeva

@cwebber the main reason why I haven't started using rust (besides their extremely irritating community who I hate so much that I might develop pyrokinesis) is that I can't just rewrite a few critical systems in it and then statically link it with the rest of my big C++ program, and it's uncertain whether I'd be able to port it to anything besides all of the flavors of PC and presumably mobile, because game console APIs are all C++

aeva

@cwebber someone pointed out to me recently that a big reason as to why rust evangelists are all super irritating is because a significant number of them are also cryptocurrency grifters and it's poisoned their community norms and now I can't unsee it

Audrey MP [Astatide]

@aeva @cwebber I started using Rust, then quickly learned how terrible their leadership is and noped out. No sense in working to help them establish a language that treats people that terribly.

And I didn’t even get to know the community, so this only further validated my decision to nope out.

Christine Lemmer-Webber

@aeva I think you will like Zig btw

aeva

@cwebber I have heard wonderful things about Zig and its definitely a language I'm keeping an eye on.

aeva

@cwebber I'm also somewhat curious to have another go at learning more about Haskell now, since the main dialect can compile to ANSI C so in theory I could incrementally introduce it into Tangerine without dynamic linking hax, and it seems like all of the creeps in their community seem to have abandoned it for rust, but I don't know enough yet to make an informed decision one way or another

:solar: vivi

@aeva @cwebber it's been a while since I've haskelled, I'm curious about how it's changed, now

Mike Kasprzak 🦖

@aeva @cwebber FWIW yes Rust can interface with C libraries. It wouldn't be very useful if it couldn't 😉. There is a working group focused on the needs of game developers, but thanks to NDAs, how well supported each device is is extremely ambiguous. Behind the scenes Rust uses LLVM, so if a console doesn't support LLVM (Xbox?) it's probably a bigger headache.

By now I would imagine somebody has shipped a Rust game on all 3. 🤷‍♂️

aeva

@mike @cwebber until that I know someone has actually successfully ported a rust title to all the major game consoles, I must assume that it's a significant amount of work to do so. Yes, it should be possible, but the real concern is not whether it's technically possible but how much work it would be to do it. My time is very finite.

aeva

@mike @cwebber a theme I notice in a lot of these kinds of conversations is that there seems to often be an assumption that my time and attention are of low value 😔

Brion Vibber :blobcatcoffee:​

@cwebber imho rust is ok for making a .so with a C API, but interacting with C++ is MUCH harder. And I've tried cbindgen and bindgen and they "work" but ye gods ;)

Fundamentally Rust-the-source-language is like modern C++ header-based libraries. Good fucking luck making a .so without shipping the .h source. ;)

Jens Finkhäuser 🌻

@brion @cwebber Header based code may be fine, but I find I can't call it a library.

Be

@brion @cwebber cxx is much better for getting Rust and C++ to talk to each other, but there's currently no good way to integrate it into C++ build systems.

nebunez
@cwebber
Have you posted about this topic before? I actually experienced deja vu scrolling through this thread, specifically the Zig comments.
stereo griever

@cwebber I'm a rust dev but also contributing to a distro and this goes so hard. like, rustls looks cool, but there's no way to get it dynamically linked! which just gets me to keep using openssl instead! so many crates just try to for whatever reason silently build C dependencies for me! why?!

Be

@selfisekai @cwebber I hate when crates just assume the downstream user wants to build a C library and statically link it! I don't think language toolchains should try to overtake the work of other languages' toolchains.

kuna

@cwebber@octodon.social
Libraries were not supposed to be replaced at runtime.

YEARS of PROGRAMMING and NO REAL-WORLD USE of messing with a program's innards.

Want to do that anyway for a laugh? We had a tool for that, it was called "recompiling".

"Download my software from FlatHub", "Give me something.snap" - statements dreamed up by the utterly deranged.

"cannot open shared object file", "error while loading shared libraries; file too short" - REAL errors spat out by REAL ldd.

they had us for absolute fools.

Elias Mårtenson

@cwebber I'm sorry if you already saw this. But it's so perfect. youtu.be/TGfQu0bQTKc

🏴 Lispegistus 🧠➕🖥️

@loke @cwebber That whole channel is gold. The emacs episode knocked me on my ass for a week.

prozacchiwawa

@loke @cwebber the emacs one was just wacky, but honestly this one was like

[x] i'm in this picture and i don't like it

Fanny Matrice

@cwebber Oh! I see you haven't read this suckless.org rant on "dynamic linking considered harmful" 😋

Mike

@cwebber your complaints about rust are much more knowledgeable and well thought out than mine are.

Go Up