Email or username:

Password:

Forgot your password?
Top-level
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

18 comments | Expand all CWs
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 @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...

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!

@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*...

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.

Go Up