• ExLisper@lemmy.curiana.net
    link
    fedilink
    arrow-up
    4
    ·
    2 months ago

    This is what most people who complain about Rust rewrites don’t get. It’s not just about memory safety and some new language features. Rust simply did a lot of things right and is nice to work with. New developers actually join Rust projects while old tools written in C struggle to survive.

    • Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      Yeah, I enjoyed when fish shell did their rewrite and people were arguing whether it makes sense technologically, like it’s a mature codebase, so it’s not likely to reduce the number of bugs and yadda yadda yadda.

      None of this mattered, because fish is developed by a group of hobbyists. They didn’t want to continue developing in C++, because it was a pain in the ass. And for sure, one of the reasons they wanted to switch to Rust is because it’s new and exciting.
      These reasons are perfectly valid, because they’re volunteers. If they’re not having fun, then they will just developing.

    • abc@suppo.fi
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      Yup. I’m an old fart who learned C as my first real language. Rust is just fun.

  • Gonzako@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    I’m actually looking into learning zig. The deal is that I don’t really have an use case for it. My work vastly prioritizes development speed over actually fast programs

      • sunbeam60@feddit.uk
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        Arguably Zig has a simpler approach to memory management (which can also lead to more errors, arguably) which makes the transition from C somewhat easier. Downside is that the language is still under heavy development and you definitely have to be up for the ride.

        • SorteKanin@feddit.dkOP
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          Agreed that it makes the transition from C easier, but I’d also say it makes the transition from C more pointless. I don’t really know that much about Zig but from what I’ve heard, I don’t really get the benefits - if you want a fast systems-level language without guard rails, why aren’t you just writing C (or C++, if that’s your thing)?

          • kewjo@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            2 months ago

            zig does have guard rails, they’re just different approaches. zig defaults to optional types where null must be handled. and memory safety is checked through unit testing and exposing debugger memory allocators that check for different memory corruption bugs.

            rust takes a shift left approach where all declarations drive safety whereas zig takes a more laid back shift right where it’s expected you’ll have written tests. rust will force all developers to conform to produce good code where zig requires a bit more though, i mean every dev writes test cases right?

            • SorteKanin@feddit.dkOP
              link
              fedilink
              arrow-up
              0
              ·
              2 months ago

              Saying that “memory safety is checked by tests” is basically saying “memory safety is not checked”. Yes, you can write tests. How do you know the tests cover all cases? How do you know the tests aren’t buggy?

              Also, what about memory safety across threads? Are you testing multi-threaded scenarios? Are you ensuring you have no data races?

              I also don’t understand how this is an argument for Zig over C. You can also test memory safety of your C code via various means, but it’s never a guarantee. Zig is the same. So again, it seems a bit more pointless to go from C to Zig. Going from C to Rust brings actual tangible guarantees of memory safety (outside of any unsafe usage, obviously).

              • kewjo@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                2 months ago

                in c code you will see malloc, alloc, free w/e scattered through the code base, most static tools lack because they don’t control the memory and just analyze address spaces or do static code analysis. they look top down and try to catch errors.

                zig’s design forces you to create a memory allocator before any object initializations (alloc/free) and is typically constructed at the top level and passed through to functions. this allows you to swap implementation easily and use the allocator to claim memory or return an error to the caller if it can’t.

                you can do some simple static allocator, general purpose allocator (can grow memory space as you allocate more objects) or in this case to test memory safety a debug allocator which you use in your tests. This moves the memory inspection inside of where your program allocates memory. this is more of an inside out approach where the analysis is produced by controlling the memory allocations and frees through a standard interface.

          • FizzyOrange@programming.dev
            link
            fedilink
            arrow-up
            0
            ·
            2 months ago

            Zig is way better than C in many other respects, so if you want a modern sane language and you’re either a Rust luddite or working on a project where memory safety isn’t that important, it might be attractive.

            Like, if the choice is C or Zig, then Zig is pretty much a no-brainer (or it will be when it hits 1.0). It just fixes so many insane things about C that have been broken for literal decades.

            • SorteKanin@feddit.dkOP
              link
              fedilink
              arrow-up
              1
              ·
              2 months ago

              working on a project where memory safety isn’t that important

              I can’t really imagine anything where this is not the case, unless you’re doing like… I dunno, small scripts for personal use or something? But why would you use Zig or C or even Rust for that, just do Python or even bash at that point? Python is memory safe and perfectly suitable for very small programs where static analysis gives little benefit.

              • FizzyOrange@programming.dev
                link
                fedilink
                arrow-up
                3
                ·
                2 months ago

                There are definitely some cases where memory safety isn’t especially important:

                • Single player games
                • Apps that don’t process external data (e.g. a simple calculator).
                • Lots of things running on microcontrollers, where the form of input could never possibly cause any security issues. E.g. a motor controller or a basic syringe pump or a (non-smart) washing machine or something.
                • Tests, e.g. I’ve considered writing RISC-V tests in Zig. They’re traditionally written in C or assembly.

                In cases like those, memory unsafety mainly leads to non-security bugs and annoying debugging sessions. But I wouldn’t say it’s as much of a deal breaker compared to e.g. writing a video codec or font renderer or web browser or DNS server or whatever.

                I still think Rust is a better choice than Zig in most cases anyway, even ignoring memory safety. But in these cases it’s at least a defensible choice.

      • kewjo@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        2 months ago

        i like the way zig interfaces with c. even though it’s a “newer” (not 1.0) language you can import native c which means you have access to already really fast libraries. the build script and macros are the same language you write your code. the best part is you can interface with normal code (not unsafe) and can create boundaries where sure in the c side you can’t enforce memory safety, but where you interface you can convert into memory safe types.

        to talk more about memory safety i think rust does a great job, however there are some inconsistentcies where a lot of memory allocations can throw out of memory errors that will crash the app whereas zig you could gracefully handle it. this is probably more important for lower level things like kernel than an app where not recovering means everything goes down.

        honestly i wish there was an opt in borrow checker as some patterns are easily expressed, but honestly i would opt out for async code as it just gets verbosely over-declarative imo. also the new async in zig is really really cool.

        • BB_C@programming.dev
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          You can trivially use C libraries in Rust, or any system language that supports the C ABI for that matter, and this includes many hobbyist languages. Zig is not special.

          • FizzyOrange@programming.dev
            link
            fedilink
            arrow-up
            0
            ·
            2 months ago

            No Zig definitely is special. You don’t have to do any extra busy work to call C code - you can pretty much just #include the header and that’s that. It’s similar to calling C from C++.

            In any other languages - including Rust - you have to do some work declaring functions, wrapping them and so on. It’s not hard but it definitely is a non-zero amount of tedious work (especially before AI). There’s absolutely no way you could describe it as “trivial”, unless someone else has already done that work for you.

            But I don’t think it is a significant Zig advantage really. When I’m writing Rust, it’s extremely rare that I want to call any C code that someone else hasn’t already done the tedious wrapping for.

  • Angryhumanoid@fedinsfw.app
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    Look, undeniably some coding languages are miles better than others, but I don’t think any of them would fall under my personal classification of what the word “fun” means…

    • _hovi_@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      2 months ago

      Different strokes I guess. Personally, I do have a good time writing Rust and fun feels like the right word

      • FizzyOrange@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        2 months ago

        C is firmly in the “not fun” camp with PHP, JavaScript and Bash. I’d say even assembly is more fun, in a puzzle challenge sort of way.

        The most fun language I’ve used is QuakeC, because the only thing you can do with it is write Quake mods. It was a pretty neat language too from what I remember. It even automatically detected infinite loops!

        • SpaceNoodle@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          We all have different definitions of “fun.” C won’t surprise you when you try to add a string and an array; it’ll do exactly what you told it to do, which then translates to assembly code with a very predictable pattern.

          On a different note, bash scripting is well-defined and mostly consists of understanding that common tools can be chained together to provide useful output; combined with the very well-defined string operations, I’ve found that bash scripts can address over 99% of cases people try to throw sed and awk at. It’s almost surprisingly powerful.

          JavaScript is just a hot fucking mess.

          • FizzyOrange@programming.dev
            link
            fedilink
            arrow-up
            2
            arrow-down
            1
            ·
            2 months ago

            C won’t surprise you…

            Lol… I’m sure there’s a meme or graph for where you are in learning C to believe this.

            then translates to assembly code with a very predictable pattern.

            Even this is a stretch. Modern C compilers can do some wild transformations. I assume you’ve seen the classic one where UB makes it jump to a function that you never actually call.

            bash scripting is well-defined

            Yeah I mean Bash’s problem isn’t that it’s poorly defined - it’s that the definition is awful!

          • BB_C@programming.dev
            link
            fedilink
            arrow-up
            2
            arrow-down
            1
            ·
            2 months ago

            translates to assembly code with a very predictable pattern.

            the portable assembly meme

            🤣🤣🤣🤣🤣🤣🤣

    • ∃∀λ@programming.dev
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      2 months ago

      It was fun when knowing programming was almost a superpower that you had to learn by reading lots of books, etc. Now a computer can do much of the job. The computers are even solving long-open Erdos problems. We’re all just mediocre meatbags.

  • Venia Silente@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    3
    ·
    2 months ago

    Isn’t also half the point behind Rust the ability to evade the GPL and make Linux more vulnerable to takeover by corporate? Last I checked Ubuntu is replacing some GNU stuff like coreutils with Rust.

    • terabyterex@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      are you claiming that a program written in rust evades thr gpl? thats not a thing.

      or…

      are you saying , things are being rewritten (regardless of language) with a different license. scary but not a rust thing.

        • communism@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          2 months ago

          Do you seriously think that’s how IP law works? If you weren’t able to write GPL Rust code, Rust would not be free software. That would require the Rust project to issue software licences to programmers that stipulate that you must not create GPL-licensed software using Rust.

          Rust is free and open-source, like most programming languages. That means you are allowed to make whatever software you want with it, including GPL software. There’s nothing stipulating that you can’t…

          • BeardedGingerWonder@feddit.uk
            link
            fedilink
            English
            arrow-up
            0
            ·
            2 months ago

            You can write GPL rust code, you can also write non-gpl rust code. Gnu coreutils are gpl, if I choose to write functionality compatible with coreutils from scratch in rust I can relicense that as I please (ie not GPL) OP is postulating the driver behind rust rewrites is not for the language features but to allow coreutils functionality to be relicensed as closed source software.

            • communism@lemmy.ml
              link
              fedilink
              arrow-up
              1
              ·
              2 months ago

              I mean, you can create a GPL fork of the Rust coreutils if you so please. Or you could do a rewrite in any programming language of your choice and license permissively.

              In any case, I profoundly cannot bring myself to care about the fact that you can legally create a proprietary fork of permissively licensed FOSS. I don’t think it’s right to impose any restrictions on what people can do with software/code, which of course conflicts with the fact that other people can take your code and restrict what other people can do with it. So choosing between copyleft and permissive licensing is a balancing act of that contradiction. I don’t think it’s wrong to end up on the side of permissive licensing.

            • ISO@lemmy.zip
              link
              fedilink
              arrow-up
              1
              ·
              2 months ago

              OP is postulating the driver behind rust rewrites is not for the language features but to allow coreutils functionality to be relicensed as closed source software.

              And that postulation is extra laughable because non-GPL coreutils implementations always existed. And by always, I mean they actually predate the GNU implementation itself (which was a originally a “rewrite” btw 😉).

              And yes, they don’t target GNU compatibility, but some of them are perfectly serviceable as is (e.g. the freebsd ones), and adding GNU compat to them would have been infinitely easier than starting a Rust implementation from scratch anyway.

              Another laughable aspect regarding the coreutils/uutils case in particular is that uutils didn’t even start as a corpo-driven or corpo-backed project. It was literally a Mozilla employee having fun in his free time, especially during Covid, and community contributions in the same vein. Rewrites of non-GPL projects (e.g. sudo) were ironically much better backed.

              From my experience here and elsewhere, the people who make such stipulations don’t even know which licenses the core packages in their own systems adopt. Many of them don’t even know what these licenses’ provisions precisely entail. They just perpetuate some retarded circlejerk probably started by some clueless+malicious e-celeb that goes like:

              linux distro -> C -> gpl -> not corpo -> good
              rust -> not gpl -> corpo -> bad