• 0 Posts
  • 138 Comments
Joined 1 year ago
cake
Cake day: June 15th, 2023

help-circle
  • I think you dont fully understand how c compilers ( gcc specifically ) work when using multi file projects

    They don’t. C compilers compile single files produced by the c preprocessor (resolving all #includes), they have no concept of multi-file projects. That’s a thing for the build system, such as make, and it needs dependency information from the preprocessor to do its job (cpp -M), and once it has that it has to act correctly on them which is often completely broken because people don’t understand make. Like using it recursively, bad idea. In the wild, a random C project at work you’ll come across needs a full rebuild to build cleanly. Things have gotten better with things like cmake getting more popular but the whole thing is still brittle. GNU autohell certainly makes nothing better, ever.

    Also, anything using IL will always have an abi,

    Everything will always have an ABI because ABI is just API in the target language, whatever that may be. If your program is compiled and can run it uses an ABI.

    Wasm is wasm, and you only need an exposed interface

    The core wasm abi is less capable than the C abi: You get scalar values and pointers, that’s it. No structs, no nothing, memory layout is completely unspecified. The component model allows compilers to say “so I’m laying out strings like this and structs like that” giving linkers a chance to say “yeah I can generate glue code between you two”.

    Again, i like the idea of rust, but it has a long way to go to be viable atm.

    C isn’t even close to being viable according to your standards people just have gotten used to the jank.

    And it has many pitfalls to avoid so it doesnt become the hot mess that is any framework based on node.js

    Rust doesn’t have portable dylibs precisely because it isn’t a hot mess. Because it’s actual work to do it properly. Unlike everyone else. Meanwhile It speaks the local C ABI fluently (they differ by architecture and operating system, btw), which isn’t a thing that can be said about many languages that aren’t C.


    Differently put: What, precisely, do you want to do? Have you any actual use-case for your doubts, or are they spooks?


  • It’s a lacking point yes but unless you want to use a closed-source library it’s also a non-issue, which is why it has never been given priority. It’s not like language semantics would prevent portable dylibs it’s that there’s more important fronts to improve Rust on. A proper solution would take quite some engineering effort, and do note that C doesn’t have a proper solution either it just lets you link stuff up willy-nilly and then crash. Rust is actually in a better position to implement a proper solution than C is.

    The “big project” thing is a red herring given that rust compiles incrementally. I know it is technically possible to not rebuild everything from scratch in C but the code has to specifically written to not break assumptions your build system makes while rust is happily re-using the compilation results for one function in a file while discarding those of another because actual dependencies are actually tracked. Out of the box.

    Speaking of large Rust projects and proper type-safe linking: The WebAssembly folks are hashing out their Component Model which isn’t really limited to compiling to wasm, in principle: Big picture it’s a way to programmatically specify ABIs and even derive ABI translation code. That might be a good option as a rust-specific solution would be, well, rust-specific and when you engineer something that can support multiple versions of a language you can just as well engineer a bit more and have something cross-language.



  • The Rustinomicon has a chapter on it. The basics are quite simple: Declare non-opaque types to use layout matching the C ABI, export/import functions, some wibbles around name mangling. Option<T> vs. null pointers. Where things get a bit more involved is unwinding, but then you’re at the end of it, nothing should be shocking to anyone having written C.

    As to how Rusty it is… not very. I mean Rust has first-class FFI support, but the way FFI stuff is written is necessarily unidiomatic because you’re basically writing C in Rust syntax and you won’t get out of declaring your own functions `unsafe’ before you read the rest of the Rustinomicon to understand what properties you need to ensure because the nice and shiny parts of Rust assume them.



  • Data after dst+n is unchanged.

    Sure but that means the part before that is garbage because you have a null terminated string without terminator.

    Or at least that’s how I see it. If your intention isn’t to start and end with a null-terminated string you should be using memcpy. Let us not talk about situations where CHAR_BIT != 8 that’s not POSIX anyway.

    Even better, just avoid doing string manipulation in C.



  • How on earth should a newcomer know that the letter “n” in that word stands for number without having to google it?

    By looking at the difference between strcpy and strncpy. Preferably, though, you should simply learn C before writing C.

    The gist of is is that strcpy takes a null-terminated string and copies it somewhere, while strncpy takes a zero-terminated string and copies it somewhere but will not write more than n bytes. strncpy literally has exactly one more parameter than strcpy, that being n, hence the name. If n is smaller than the string length (as in: distance to first null byte) then you’re bound to have garbage in your destination, and to check for that you have to dereference the pointer strncpy returns and check if it’s actually null. Yay C error handling.

    In retrospect null-terminated strings were a mistake, but so were many other things, at some point you just have to accept that there’s hysterical raisins everywhere.


  • That’s just Algol instead of B. Most languages use the one or the other, then there’s sexpr-based languages (lisp, scheme), lua (technically Algol but not needing semicolons while also not needing newlines so it’s definitely special), and layout syntax (Haskell, or, if you want a bad implementation, python).


  • It’s not just old Haskell code that’s how you write Haskell if you want explicit braces. Well, mostly generate, but it’s still the idiomatic formatting (and when you generate you always generate braces because it’s easy to get layout subtly wrong when generating).

    Haskell also does the whole

    data Foo = Bar
             | Baz
             | Quux
    
    foo = [ Bar
          , Baz
          , Quux
          ]
    

    thing, makes sense to apply it to braces especially as they’re seen only very rarely. Single-line, yes, but not multi-line.


  • barsoap@lemm.eetoLemmy Shitpost@lemmy.worldMildred
    link
    fedilink
    arrow-up
    5
    ·
    4 months ago

    Deep into that darkness peering, long I stood there wondering, fearing,
    Doubting, dreaming dreams no mortal ever dared to dream before;
      But the silence was unbroken, and the stillness gave no token,
      And the only word there spoken was the whispered word, “Lenore?”
    This I whispered, and an echo murmured back the word, “Lenore!”—
           Merely this and nothing more.






  • If you’re taking photos on a nude beach in Europe you’re getting decked. Kid, adult, doesn’t matter.

    There’s a massive fucking difference between sitting naked in a sauna with other naked people and sitting on public transit, fully dressed, gossiping about non-consensual nudes of children. How is that even a question. How are you capable of equating those things.


  • Help them remove the stigma around their bodies and sex, and empower them to speak and be heard when something they don’t like happens.

    This. So much this. If auntie wants to give them a kiss and they don’t want to get slobbered then tough fucking luck auntie, I’ll back the little shits up when they bite you. Predators are, by and large, able to do what they do because people don’t teach kids that they do, in fact, have bodily autonomy.

    And while I’m at it bodily autonomy of kids also implies that parents don’t parade photos around like some fucking trophy or something. Have some basic fucking regard for your own kids and what they want. How would you feel when they’re showing nude pictures of you to their classmates yeah I thought so.


  • barsoap@lemm.eetoLemmy Shitpost@lemmy.worldIroning
    link
    fedilink
    arrow-up
    3
    ·
    5 months ago

    Oh that’s easy (and probably disappointing): None. Not really a hobby of mine, more of an extension to doing the laundry and being a cheapskate who can’t fathom buying something new when you can fix it in the time it takes to listen to a podcast episode.


  • barsoap@lemm.eetoLemmy Shitpost@lemmy.worldIroning
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    5 months ago

    The other really valid reason is linen. Kinda unrelated to sewing itself and it’s not about stopping the stuff from crinkling (that’s right-out impossible), but to make sure that crinkles don’t always appear in the same place so the fabric has a chance of wearing down evenly.

    Found this out the hard way because my linen duvet covers are oversized – nominal size is correct, but they’re made for down blankets, not flat ones. Blanket slides inside, generally towards the bottom, leaving a fabric flap on the top that really tends to crinkle as you sleep, wash, hang up, the crinkles don’t straighten out, exact same crinkles appear in the exact same spot and get chafed while sleeping, rinse and repeat for two years the first hole starts appearing, a month later there’s more than you can be bothered to patch.

    Luckily it was a simple matter of running a stitch down the length of the thing to shorten it a bit, but given that an iron and ironing mat (not a full table, mat is completely sufficient) is significantly cheaper than linen covers or just the material for them, definitely worth the investment and time.

    Oh and yes linen covers are definitely worth it because moisture regulation. It’s also nice and soft – not in the silky smooth sense, it has definitive grip to it. So are linen kitchen towels because they actually dry stuff instead of spreading water around. Half-linen is already a massive upgrade over cotton in that area and it’s much cheaper (the main reason why full linen is so expensive is because it’s a bugger to weave, not because the yarn is that much more expensive. Weaving linen wefts into cotton warps OTOH is pretty uncomplicated).


  • Azov has gotten completely diluted by a gigantic influx of ordinary people, its hardcore Nazi times were over before they were even rolled into Ukraine’s overall command structure which came along with some more denazification. The Wolfsangel isn’t recognised as a far-right symbol in Ukraine by the general public so they kept it. It’s also not a clear-cut Nazi symbol even in Germany, you see it on plenty of coat of arms, it also has plenty of use in forestry which is its original source: You hang it with bait onto a branch to kill wolves in a rather gruesome manner. That’s outlawed nowadays but you still see it on border forestry border stones, to mark wood, etc. The heraldic use derives from that, it symbolises presence or importance of forestry in the area the coat of arm represents. Not much forest around the Azov sea, though.

    Those are not the Nazis you’re looking for. If you want to see, well not exactly nazis but the hot-bed of ultranationalists in the Ukrainian army have a look at the right sector regiment. Dylan Burns did an interview.

    Next up: Someone’s going to claim that the Ukrainian army uses the “Iron Cross”. First off, the Bundeswehr still uses it, secondly, no the Ukrainians don’t use it you’re looking at the Cossack Cross, derived independently from the Templar Cross, unlike the Iron Cross not via the Teutonic Order. They’ve been using that thing for centuries.

    EDIT: Oh wait I just remembered I’m completely banned from lemmygrad they won’t see this. Well, whatever.