Does Rust have any benefits at all over C that is written memory safe?

Does Rust have any benefits at all over C that is written memory safe?

  1. 2 weeks ago
    Froggy

    Couldn't get into Rust. People say it's a beautiful fusion of old and new. But maybe it's the new stuff that is the problem. If anything the more I use C the more I appreciate it. I'll admit that crates.io is a cool site. It would be cooler if you didn't have to make a GitHub account (gross).

  2. 2 weeks ago
    Anonymous

    Rust doesn't have memory safety and claims of memory safety in Rust are just security theater. If you are doing anything interesting or useful in Rust it just ends up in an unsafe block anyways. Rust's memory safety is the equivalent of refactoring your C code to put all potentially "unsafe" code at the bottom of the file and then sticking a comment above it that says "Unsafe code goes here". It is just a label and pretending it is anything other than a label is pure cope.

    That being said, if Rust manages to remove unsafe blocks from code entirely that would be useful, but until then it is just a downgraded C that makes huge binaries for no good reason.

    • 2 weeks ago
      Anonymous

      > 1% of your application is unsafe, so it might as well all be
      There has got to be something in the water here. Its insane the number of C programmer who have never written a C program with more than 2 files.

    • 2 weeks ago
      Anonymous

      It has most of the benefits (and many of the drawbacks) of C++, for a start. It's way more expressive. Generics alone go a long way.
      You also get unified tooling with a standard build system and so on. Neither C nor C++ has that.
      You get more aggressive restrict-style aliasing optimizations by default.
      If you don't trust Rust, check out C++ first.

      You can't have read much Rust code, if any. Unsafe blocks are used for data structure implementations and FFI and not many other things.
      Check out https://github.com/rust-lang/regex for example. Very little unsafe code in the interesting parts. Or check out https://github.com/rustls/rustls, no unsafe code at all.

      • 2 weeks ago
        Anonymous

        >Unsafe blocks are used for data structure implementations and FFI and not many other things.
        I was reading about someone who was trying to implement a garbage-collected scripting language in Rust (that is, the scripting language was GCed, and the implementation of all that was in Rust). Apparently it was really awful to do it, and rather slow too. There was a detailed reason why and it was subtle; something to do with being unable to use a concurrent mark/sweep algorithm even with unsafe code, and very difficult to make a system of memory arenas work either (because unsafe mode doesn't in any way disable the aggressiveness of the borrow checker, leading to some awful bugs). The headline was that you're far better off using Zig for that sort of task.
        Be aware that I cannot confirm these statements. It was just an amusing thing I read. (I mostly prefer plain old C or a much higher level language.)

        • 2 weeks ago
          Anonymous

          I saw that same post. They might have just as many problems writing it in Zig if they aren't paranoid about optimization. Half the reason the borrow checker is so anal about your code is to keep LLVM from fucking everything up.
          If you hand-optimize all your code, obviously you don't need a high level language for that.

          • 2 weeks ago
            Anonymous

            post sauce.

            • 2 weeks ago
              Anonymous

              https://zackoverflow.dev/writing/unsafe-rust-vs-zig/
              Also, the HN thread https://news.ycombinator.com/item?id=35058176

              • 2 weeks ago
                Anonymous

                >zackoverflow.dev
                was he participating on some cringe domain name contest?

              • 2 weeks ago
                Anonymous

                >>Also, the HN thread https://news.ycombinator.com/item?id=35058176

                > Rust is the inverse of Perl: It makes the easy stuff hard.
                >
                > Writing basic data structures isn't a niche, esoteric edge case. There may be a crate that "solves" what you're trying to do. But does it rely on the stdlib (i.e., is it unusable for systems programming)? Is it implemented making gratuitous copies of data everywhere? Does it have a hideous interface which will then pollute all of your interfaces? Does it rely on 'unstable' features?
                >
                > Then, there's the 'community.' It seems to consist solely of extremely online people who get a dopamine hit from both telling people they're doing things wrong and creating the most complex solutions possible. They do this under a thin veneer of forced niceness, but it's not nice at all.

                that's a very nice summary.

              • 2 weeks ago
                Anonymous

                sounds like haskell on the community part

              • 2 weeks ago
                Anonymous

                i get same vibe from the "modern c++" community as well.

                well i'm not using a proprietary compiler or anything that microsoft touches, so if the gnu trannies don't want to implement features then c++ is dead for me

                it's libre software, send a patch if you care.

  3. 2 weeks ago
    Anonymous

    >C that is written memory safe?
    that doesn't exist

  4. 2 weeks ago
    Anonymous

    proper sum types and pattern matching

    • 2 weeks ago
      Anonymous

      no nulls
      no exceptions
      just these 2 make it better than 99% of languages. to add one more, exhaustive match statements

      multiple return values
      lambdas
      generics

      C code is completely memory safe if it contains no bugs, does not use array indexing or pointers, does not use signed integers, does not read from uninitialized variables, and does not perform IO

      > 1% of your application is unsafe, so it might as well all be
      There has got to be something in the water here. Its insane the number of C programmer who have never written a C program with more than 2 files.

      It has most of the benefits (and many of the drawbacks) of C++, for a start. It's way more expressive. Generics alone go a long way.
      You also get unified tooling with a standard build system and so on. Neither C nor C++ has that.
      You get more aggressive restrict-style aliasing optimizations by default.
      If you don't trust Rust, check out C++ first.

      You can't have read much Rust code, if any. Unsafe blocks are used for data structure implementations and FFI and not many other things.
      Check out https://github.com/rust-lang/regex for example. Very little unsafe code in the interesting parts. Or check out https://github.com/rustls/rustls, no unsafe code at all.

      [...]

  5. 2 weeks ago
    Anonymous

    C cannot be written memory safe.

  6. 2 weeks ago
    Anonymous

    >side boob
    not memory safe

  7. 2 weeks ago
    Anonymous

    no nulls
    no exceptions
    just these 2 make it better than 99% of languages. to add one more, exhaustive match statements

  8. 2 weeks ago
    Anonymous

    multiple return values
    lambdas
    generics

    • 2 weeks ago
      Anonymous

      >multiple return values
      you can return struct
      >lambdas
      pointless in non oop language
      >generics
      c11 has all the generics you would possibly need without it getting a bloated pile of garbo

      • 2 weeks ago
        Anonymous

        return values
        >you can return struct
        This is such a bad solution that everybody chooses to use pointer arguments instead.

        >pointless in non oop language
        No.

        • 2 weeks ago
          Anonymous

          >This is such a bad solution that everybody chooses to use pointer arguments instead.
          noone uses it because it is less optimal from hardware standpoint as any language that allows it.

          • 2 weeks ago
            Anonymous

            Where did you get that idea? You're not going to get better assembly out of this by using out parameters. Return values can use registers if they're small enough, pointers have to touch memory.
            And of course if it gets inlined it's all moot, and a lot of functions will be, particularly the ones where the calling convention makes up a big part of the overall performance.
            The number one reason people choose one or the other is convenience. C doesn't make compound return values convenient at all, so people don't use them.

            • 2 weeks ago
              Anonymous

              >Return values can use registers if they're small enough, pointers have to touch memory.
              Sort of. If code that uses pointers gets inlined, it can converted from using pointers into not doing so. LLVM's pretty good at that sort of trick, and I'm pretty sure that both Clang and Rustc will make some use of it.

      • 2 weeks ago
        Anonymous

        >pointless in non oop language
        do cniles really?

        • 2 weeks ago
          Anonymous

          >do cniles really?
          Some fools are just full of shit. I'd love lambdas in C, and I understand that doing it well is trickier than it looks at first glance.

          • 2 weeks ago
            Anonymous

            >I'd love lambdas in C, and I understand that doing it well is trickier than it looks at first glance.
            if you want non-capturing lambda, then just write a static function.

            if you want capturing lambda, then just NO. because capturing lambda will need either hidden pointers inserted by the compiler (which will ruin the function signature - thus making it incompatible to use as a function pointer such as qsort argument) or will require executable stack: https://nullprogram.com/blog/2019/11/15/

            adding defer/lambda's to C can easily turn out to be the biggest mistake since VLAs.

  9. 2 weeks ago
    Anonymous

    >C that is written memory safe?

    • 2 weeks ago
      Anonymous

      C code is completely memory safe if it contains no bugs, does not use array indexing or pointers, does not use signed integers, does not read from uninitialized variables, and does not perform IO

  10. 2 weeks ago
    Anonymous

    I hope Rust takes over the world already and becomes as commonplace as a refrigerator so I don't have to hear about it anymore.

  11. 2 weeks ago
    Anonymous

    >rust creates a 12mb file for a fucking hello world
    into le trash it goes

    • 2 weeks ago
      Anonymous

      Good, it filters the poor.

  12. 2 weeks ago
    Anonymous

    reimu sideboob rape

  13. 2 weeks ago
    Anonymous

    cargo is much more helpful than g++, clang, or gcc

    • 2 weeks ago
      Anonymous

      this is the only advantage rust has, C++ tooling is dreadful.
      >cmake
      >premake
      >conan
      >vcpkg
      Like seriously

      • 2 weeks ago
        Froggy

        >cmake
        >premake
        >conan
        >vcpkg
        We don't need all that mess, just put all the GCC flags you need in a script.

  14. 2 weeks ago
    Anonymous

    >package manager is more helpful than compiler
    this is your average rust tranny

  15. 2 weeks ago
    Anonymous

    rust lacks too many features and doesn't give the kind of freedom that i expect in a systems language. it's just a toy project for trannies and cucks

  16. 2 weeks ago
    Anonymous

    I just use C++23 with modules and concepts.

    • 2 weeks ago
      Anonymous

      >C++23 with modules
      >modules
      no you don't, not for any non-trivial project

      • 2 weeks ago
        Anonymous

        yes I do, modules has been here since C++20. The only thing to come is std as modules

        • 2 weeks ago
          Anonymous

          there are no modules without compiler and build system support, and compiler support is non-existent unless you are on msvc (which is still shit)

          • 2 weeks ago
            Anonymous

            STL is single handily carrying C++, gnu devs got nothing on him. Microsoft is actually the leading compiler for C++ now kek.

            std as modules is soon in msvc as well.

            • 2 weeks ago
              Anonymous

              all reasons why c++ is a dying language, the writing is on the wall

              • 2 weeks ago
                Anonymous

                it’s more that gnu trannys have been lazy since C++98 was a thing for such a long time before the C++11 and new C++ release schedule ragnarok

              • 2 weeks ago
                Anonymous

                well i'm not using a proprietary compiler or anything that microsoft touches, so if the gnu trannies don't want to implement features then c++ is dead for me

              • 2 weeks ago
                Anonymous

                they want to implement it, but they have no funds so they are taking a long time. Such is life in communist lands

              • 2 weeks ago
                Anonymous

                >I refuse to use better software because it doesn't have a guhnoo loicense
                freetard moment

  17. 2 weeks ago
    Anonymous
    • 2 weeks ago
      Anonymous

      >its hard to know what a C function does
      write a comment at the top explaining what it does
      >C doesnt have all my data structures
      its not supposed to
      >its hard to write safe C code
      check argc, think about null terminators, and use strncpy

      • 2 weeks ago
        Anonymous

        >strncpy
        Doesn't write a null terminator if it truncates
        Interesting read: man 7 string_copying

        • 2 weeks ago
          Anonymous

          >interesting read:
          >man 7 string_copying
          no it's not interesting at all. it's written by an amature who took over the linux-manpage project after Michael Kerrisk stepped down.

          this is the type of shit that retard is writing: https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=7d5c5fd9846d4a1f2ce0fd5503e56caa2087eafc

          if (src[strlen(src)] != '') raise(SIGSEGV);

          >Don't crash on invalid input.
          no fucking shit, that check was going to get optimized out by gcc/clang anyways cause it's UB.

          just keep track of your string lenght and use memcpy. making copying a couple bytes of memory seem more complicated that it is, is part of the problem.

  18. 2 weeks ago
    Anonymous

    soft skin, feminine penis, programming socks, femboy milk etc.

  19. 2 weeks ago
    Anonymous

    Containment language for the trannies.

Your email address will not be published. Required fields are marked *