Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Something something history is a flat circle

Something something history is a flat circle

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
43 Posts 24 Posters 3 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A [email protected]

    “Before rust you could either have a fast language (C/C++) or a memory safe language (any other language. That is, languages with garbage collector).”

    Ada managed to do safe and fast over forty years ago.

    B This user is from outside of this forum
    B This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #18

    Does Ada have a capability as powerful as the borrow checker?

    B A 2 Replies Last reply
    0
    • m_f@discuss.onlineM [email protected]

      Relevant comment

      I don't use Rust much, but I agree with the thrust of the article. However, I do think that the borrowchecker is the only reason Rust actually caught on. In my opinion, it's really hard for a new language to succeed unless you can point to something and say "You literally can't do this in your language"

      Without something like that, I think it just would have been impossible for Rust to gain enough momentum, and also attract the sort of people that made its culture what it is.

      Otherwise, IMO Rust would have ended up just like D, a language that few people have ever used, but most people who have heard of it will say "apparently it's a better safer C++, but I'm not going to switch because I can technically do all that stuff in C++"

      C This user is from outside of this forum
      C This user is from outside of this forum
      [email protected]
      wrote on last edited by [email protected]
      #19

      Yep, and that's not a bad thing. Switching has a cost, and using the old standby is probably the way to go if there's a bunch of new things, none of which are definitely, inarguably better than it.

      1 Reply Last reply
      3
      • A [email protected]

        “Before rust you could either have a fast language (C/C++) or a memory safe language (any other language. That is, languages with garbage collector).”

        Ada managed to do safe and fast over forty years ago.

        B This user is from outside of this forum
        B This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #20

        Before Rust, the main argument I heard from C++ enthusiasts against Ada was that it was a nice idea but too "design-by-committee". Which, yeah, is an ironic thing for C++ fans to say, but I guess that was enough 🤷

        1 Reply Last reply
        4
        • B [email protected]

          Does Ada have a capability as powerful as the borrow checker?

          B This user is from outside of this forum
          B This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #21

          Strictly speaking, no. The borrow checker was a true innovation.

          1 Reply Last reply
          1
          • mamg22@sh.itjust.worksM [email protected]

            Has Carbon been used anywhere noticeable? Last time I heard of it was when Google announced it few years ago, haven't seen anything getting written or ported to it, though I haven't read much into it so I might have missed many news.

            V This user is from outside of this forum
            V This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #22

            It looks like a nice mix of some of the worst design choices of C++ with some of the most dubious choices of Rust.

            icastfist@programming.devI 1 Reply Last reply
            29
            • C [email protected]

              How can you not have memory-safety while also having a garbage collector?

              Garbage collection means that all objects live as long as you have a reference to it. Which means that you can only dereference a pointer to invalid memory if you willingly create an invalid pointer, or reinterpret the type of one pointer into another. Going out of bounds of an array counts as the first case.

              If a language has garbage collection but no compiler/interpreter supports it, then the language doesn't have garbage collection.

              anyoldname3@lemmy.worldA This user is from outside of this forum
              anyoldname3@lemmy.worldA This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #23

              For a start, having a garbage collector doesn't mean its use is mandatory, but even in a language where the garbage collector is mandatory, keeping an array alive as long as any references to it exist doesn't stop you doing things like getting muddled about its length and reading/writing past the end. Mandatory garbage collection only prevents temporal memory bugs like use-after-free, not spatial memory safety bugs like buffer overruns, which need to be prevented by other mechanisms like bounds checks.

              C 1 Reply Last reply
              0
              • anyoldname3@lemmy.worldA [email protected]

                For a start, having a garbage collector doesn't mean its use is mandatory, but even in a language where the garbage collector is mandatory, keeping an array alive as long as any references to it exist doesn't stop you doing things like getting muddled about its length and reading/writing past the end. Mandatory garbage collection only prevents temporal memory bugs like use-after-free, not spatial memory safety bugs like buffer overruns, which need to be prevented by other mechanisms like bounds checks.

                C This user is from outside of this forum
                C This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #24

                As I said, I don't consider going out of bounds of a buffer a memory safety issue. Forcing the programmer to handle an out-of-bounds case every time there is an array access can be incredibly tedious. So much that not even rust forces you to do so. And if that language has iterators, it's even less of an issue.

                I consider out-of-bounds array access to same as casting a pointer to another type. Just because a language lets you do it, it doesn't mean that it is not memory safe. It is a performance feature, since checking the bounds every time is always possible (and incredibly easy to implement), but also with too big of an impact when you could just check the length once per loop instead of per loop iteration.

                S anyoldname3@lemmy.worldA 2 Replies Last reply
                0
                • C [email protected]

                  I kinda disagree. The reason rust caught on is because it is much safer than C++ while having the same or even better performance. And in some contexts, being garbage collected means bad performance.

                  Before rust you could either have a fast language (C/C++) or a memory safe language (any other language. That is, languages with garbage collector). But if you required memory safety and peak performance, there wasn't any option.

                  Yes, the reason that rust is both memory safe and fast is because it has a borrow checker. But the borrow checker is the means, not the end.

                  Z This user is from outside of this forum
                  Z This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #25

                  The "better" performance is due to the built-in multi-threading support, and that functional programming makes it relatively safer to pull off. Otherwise single-threaded Rust is very hard to optimize.

                  A 1 Reply Last reply
                  1
                  • C [email protected]

                    As I said, I don't consider going out of bounds of a buffer a memory safety issue. Forcing the programmer to handle an out-of-bounds case every time there is an array access can be incredibly tedious. So much that not even rust forces you to do so. And if that language has iterators, it's even less of an issue.

                    I consider out-of-bounds array access to same as casting a pointer to another type. Just because a language lets you do it, it doesn't mean that it is not memory safe. It is a performance feature, since checking the bounds every time is always possible (and incredibly easy to implement), but also with too big of an impact when you could just check the length once per loop instead of per loop iteration.

                    S This user is from outside of this forum
                    S This user is from outside of this forum
                    [email protected]
                    wrote on last edited by [email protected]
                    #26

                    buffer overflows are critical for memory safety since they can cause silent data corruption (bad) and remote code execution (very bad). Compared to those a "clean" unhandled runtime error is far preferable in most cases.

                    1 Reply Last reply
                    2
                    • tonytins@pawb.socialT [email protected]

                      I tried programming in D a little. Wasn't bad. Just up against industry giants.

                      J This user is from outside of this forum
                      J This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #27

                      I was looking for a "C with strings" and D seems to be about it.

                      1 Reply Last reply
                      0
                      • Z [email protected]
                        This post did not contain any content.
                        F This user is from outside of this forum
                        F This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #28

                        K&R started with BCPL as their base of inspiration. They then made B, and then C. The followup should be called P.

                        Z icastfist@programming.devI 2 Replies Last reply
                        7
                        • F [email protected]

                          K&R started with BCPL as their base of inspiration. They then made B, and then C. The followup should be called P.

                          Z This user is from outside of this forum
                          Z This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #29

                          https://en.m.wikipedia.org/wiki/P_(programming_language)

                          1 Reply Last reply
                          1
                          • C [email protected]

                            As I said, I don't consider going out of bounds of a buffer a memory safety issue. Forcing the programmer to handle an out-of-bounds case every time there is an array access can be incredibly tedious. So much that not even rust forces you to do so. And if that language has iterators, it's even less of an issue.

                            I consider out-of-bounds array access to same as casting a pointer to another type. Just because a language lets you do it, it doesn't mean that it is not memory safe. It is a performance feature, since checking the bounds every time is always possible (and incredibly easy to implement), but also with too big of an impact when you could just check the length once per loop instead of per loop iteration.

                            anyoldname3@lemmy.worldA This user is from outside of this forum
                            anyoldname3@lemmy.worldA This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #30

                            If you're going to change the definition of words, it's pretty easy to show that garbage collection on its own is sufficient, but it's not possible to have a useful conversation if someone's using their own personal definition of the terms being discussed. The generally accepted definition of memory safety includes deeming out-of-bounds accesses and other spatial memory safety issues unsafe.

                            C 1 Reply Last reply
                            1
                            • B [email protected]

                              Does Ada have a capability as powerful as the borrow checker?

                              A This user is from outside of this forum
                              A This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #31

                              I’ve never used Rust but from my very cursory knowledge of what the borrow checker entails, it wouldn’t add so much to Ada.

                              Use of pointers is already strongly discouraged by the simple fact that the language is designed to rarely truly need them. Besides, the compiler itself chooses automatically whether to pass data by value or by reference depending on the required results and what is most efficient. You can also specify parameters passed to a function as read-only. Finally, another thing that Ada does to prevent yourself shooting in your foot is to enforce strong encapsulation of functions and data.

                              Overall, one way to put it in simple terms is that Ada requires the programmer to give enough information to the compiler so as to ensure that it actually outputs what you want it to, which as far as I understand, is sort of what the borrow checker is there for. The downside to the Ada approach is that it is very verbose, but with the kind of code editing capabilities we have nowadays it’s certainly not as much a hassle as it was when Ada came out.

                              Anyways, I suspect that both languages are different enough in overall paradigm that trying to solve problems in Ada the way you would in Rust would probably be quite frustrating and give rather poor result.

                              B 1 Reply Last reply
                              0
                              • anyoldname3@lemmy.worldA [email protected]

                                If you're going to change the definition of words, it's pretty easy to show that garbage collection on its own is sufficient, but it's not possible to have a useful conversation if someone's using their own personal definition of the terms being discussed. The generally accepted definition of memory safety includes deeming out-of-bounds accesses and other spatial memory safety issues unsafe.

                                C This user is from outside of this forum
                                C This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #32

                                With your definition this conversation doesn't make sense though. Since rust's direct array access doesn't perform bounds checks when building in release mode. And it doesn't require using unsafe.

                                anyoldname3@lemmy.worldA 1 Reply Last reply
                                0
                                • C [email protected]

                                  With your definition this conversation doesn't make sense though. Since rust's direct array access doesn't perform bounds checks when building in release mode. And it doesn't require using unsafe.

                                  anyoldname3@lemmy.worldA This user is from outside of this forum
                                  anyoldname3@lemmy.worldA This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #33

                                  That's not what Rust's documentation says. It does a compile-time bounds check if it can prove what the index might be during compilation, and a runtime bounds check if it can't. In release mode, it tries harder to prove the maximum index is below the minimum length, but it still falls back to a runtime bounds check if it can't unless you use get_unchecked, which is unsafe.

                                  1 Reply Last reply
                                  0
                                  • C [email protected]

                                    How can you not have memory-safety while also having a garbage collector?

                                    Garbage collection means that all objects live as long as you have a reference to it. Which means that you can only dereference a pointer to invalid memory if you willingly create an invalid pointer, or reinterpret the type of one pointer into another. Going out of bounds of an array counts as the first case.

                                    If a language has garbage collection but no compiler/interpreter supports it, then the language doesn't have garbage collection.

                                    E This user is from outside of this forum
                                    E This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by [email protected]
                                    #34

                                    I've gotten segfaults in python with only the standard library

                                    1 Reply Last reply
                                    0
                                    • F [email protected]

                                      K&R started with BCPL as their base of inspiration. They then made B, and then C. The followup should be called P.

                                      icastfist@programming.devI This user is from outside of this forum
                                      icastfist@programming.devI This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #35

                                      Some people really suck at coming up with names for their programming languages. There are so many single letter languages (B, C, D, E, F, J, K, V...) that it really makes one wonder what the fuck is wrong with them

                                      F 1 Reply Last reply
                                      2
                                      • V [email protected]

                                        It looks like a nice mix of some of the worst design choices of C++ with some of the most dubious choices of Rust.

                                        icastfist@programming.devI This user is from outside of this forum
                                        icastfist@programming.devI This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #36

                                        Oh, so it's a contender against Brainfuck

                                        1 Reply Last reply
                                        5
                                        • Z [email protected]
                                          This post did not contain any content.
                                          icastfist@programming.devI This user is from outside of this forum
                                          icastfist@programming.devI This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #37

                                          Zig or V could've been shown instead of Carbon (the lone C)

                                          1 Reply Last reply
                                          1
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups