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. LLVM

LLVM

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
52 Posts 19 Posters 0 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.
  • D [email protected]

    New kid on the block, roc, has it right by splitting application code from "platform"/framework code, precompiling and optimising the platform, then using their fast surgical linker to sew the app code to the platform code.

    Platforms are things like cli program, web server that kind of thing. Platforms provide an interface of domain specific IO primitives and handle all IO and memory management, and they also specify what functions app code must supply to complete the program.

    It's pretty cool, and they're getting efficiency in the area of systems programming languages like C and Rust, but with none of the footguns of manual memory management, no garbage collection pauses, but yet also no evil stepparent style borrow checker to be beaten by. They pay a lot of attention to preventing cache misses and branch prediction failures, which is his they get away with reference counting and still being fast.

    A note of caution: I might sound like I know about it, but I know almost nothing.

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

    [email protected]

    1 Reply Last reply
    1
    • D [email protected]

      Reference counting.

      They pay a lot of attention to preventing cache misses and branch prediction failures, which is how they get away with reference counting and still being fast.

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

      Oh, you just mean it's a kind of garbage collection that's lighter on pauses. Sorry, I've had the "my pre-Rust pet language already does what Rust does" conversation on here too many times.

      B D firelizzard@programming.devF 3 Replies Last reply
      6
      • C [email protected]

        Oh, you just mean it's a kind of garbage collection that's lighter on pauses. Sorry, I've had the "my pre-Rust pet language already does what Rust does" conversation on here too many times.

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

        To be fair, the drop/dealloc "pause" is very different from what people usually mean when they say "garbage collection pause", i.e. stop-the-world (...or at least a slice of the world).

        C 1 Reply Last reply
        3
        • lena@gregtech.euL [email protected]
          This post did not contain any content.
          L This user is from outside of this forum
          L This user is from outside of this forum
          [email protected]
          wrote last edited by [email protected]
          #12

          GCC is adding cool new languages too!

          They just recently added COBOL and Modula-2. Algol 68 is coming in GCC 16.

          P D 2 Replies Last reply
          30
          • E [email protected]

            That's like... It's purpose. Compilers always have a frontend and a backend. Even when the compiler is entirely made from scratch (like Java or go), it is split between front and backend, that's just how they are made.

            So it makes sense to invest in just a few highly advanced backends (llvm, gcc, msvc) and then just build frontends for those. Most projects choose llvm because, unlike the others, it was purpose built to be a common ground, but it's not a rule. For example, there is an in-developement rust frontend for GCC.

            K This user is from outside of this forum
            K This user is from outside of this forum
            [email protected]
            wrote last edited by
            #13

            that’s just how they are made.

            Can confirm, even the little training compiler we made at Uni for a subset of Java (Javali) had a backend and frontend.

            I can't imagine trying to spit out machine code while parsing the input without an intermediary AST stage. It was complicated enough with the proper split.

            buboscandiacus@mander.xyzB L 2 Replies Last reply
            6
            • K [email protected]

              that’s just how they are made.

              Can confirm, even the little training compiler we made at Uni for a subset of Java (Javali) had a backend and frontend.

              I can't imagine trying to spit out machine code while parsing the input without an intermediary AST stage. It was complicated enough with the proper split.

              buboscandiacus@mander.xyzB This user is from outside of this forum
              buboscandiacus@mander.xyzB This user is from outside of this forum
              [email protected]
              wrote last edited by
              #14

              I can imagine;

              1 Reply Last reply
              5
              • C [email protected]

                Oh, you just mean it's a kind of garbage collection that's lighter on pauses. Sorry, I've had the "my pre-Rust pet language already does what Rust does" conversation on here too many times.

                D This user is from outside of this forum
                D This user is from outside of this forum
                [email protected]
                wrote last edited by [email protected]
                #15

                It's a post rust language.

                By your definition any automatic memory management is garbage collection, including rust!

                Did you think rust doesn't free up memory for you? That would be the biggest memory leak in history! No! Rust does reference counting, it just makes sure that that number is always one! What did you think the borrow checker was for?

                In roc, because the platform is in charge of memory management, it can optimise, so that a web server can allocate an arena for each client, a game loop can calculate what it needs in advance etc etc.

                But like I say, they do a lot of work on avoiding cache misses and branch mispredictions, which are their own source of "stop the world while I page in from main memory" or "stop the pipeline while I build a new one". If it was doing traditional garbage collection, that would be an utterly pointless microoptimisation.

                Rust isn't a religion. Don't treat it like one.

                When it was very new a bunch of C programmers shit on its ideas and said C was the only real systems programming language, but rust, which was pretty much Linear ML dressed up in C style syntax came from hyper weird functional programming language to trusted systems programming language. Why? Because it does memory management sooooo much better than C and is just about as fast. Guess what roc is doing? Memory management soooooo much better than C, and sooooo much less niggly and hard to get right than the borrow checker and is just about as fast.

                Plenty of beginners program in rust by just throwing clone at every error the borrow checker sends them, or even unsafe! Bye bye advantages of rust, because it was hard to please. Roc calculates from your code whether it needs to clone (eg once for a reference to an unmodified value, each time for an initial value for the points in a new data structure), and like rust, frees memory when it's not being used.

                Rust does manual cloning. Roc does calculated cloning. Rust wins over C for memory safety by calculating when to free rather than using manual free, totally eliminating a whole class of bugs. Roc could win over rust by calculating when to clone, eliminating a whole class of unnecessary allocation and deallocation. Don't be so sure that no one could do better than rust. And the devXP in rust is really poor.

                C C 2 Replies Last reply
                1
                • lena@gregtech.euL [email protected]
                  This post did not contain any content.
                  tatterdemalion@programming.devT This user is from outside of this forum
                  tatterdemalion@programming.devT This user is from outside of this forum
                  [email protected]
                  wrote last edited by
                  #16

                  Isn't Zig working on their own backend?

                  Also, pretty excited about the cranelift project.

                  vpol@feddit.ukV 1 Reply Last reply
                  7
                  • L [email protected]

                    GCC is adding cool new languages too!

                    They just recently added COBOL and Modula-2. Algol 68 is coming in GCC 16.

                    P This user is from outside of this forum
                    P This user is from outside of this forum
                    [email protected]
                    wrote last edited by
                    #17

                    cool new languages

                    COBOL

                    skullgrid@lemmy.worldS L 2 Replies Last reply
                    40
                    • D [email protected]

                      Reference counting.

                      They pay a lot of attention to preventing cache misses and branch prediction failures, which is how they get away with reference counting and still being fast.

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

                      I wish more languages used ref counting. Yes, it has problems with memory cycles, but it's also predictable and fast. Works really well with immutable data.

                      D 1 Reply Last reply
                      1
                      • F [email protected]

                        I wish more languages used ref counting. Yes, it has problems with memory cycles, but it's also predictable and fast. Works really well with immutable data.

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

                        Roc uses immutable data by default. It performs opportunistic in-place mutation when the reference count will stay 1 (eg this code would satisfy the borrow checker without cloning or copying if it were rust - static code analysis).

                        F 1 Reply Last reply
                        1
                        • D [email protected]

                          It's a post rust language.

                          By your definition any automatic memory management is garbage collection, including rust!

                          Did you think rust doesn't free up memory for you? That would be the biggest memory leak in history! No! Rust does reference counting, it just makes sure that that number is always one! What did you think the borrow checker was for?

                          In roc, because the platform is in charge of memory management, it can optimise, so that a web server can allocate an arena for each client, a game loop can calculate what it needs in advance etc etc.

                          But like I say, they do a lot of work on avoiding cache misses and branch mispredictions, which are their own source of "stop the world while I page in from main memory" or "stop the pipeline while I build a new one". If it was doing traditional garbage collection, that would be an utterly pointless microoptimisation.

                          Rust isn't a religion. Don't treat it like one.

                          When it was very new a bunch of C programmers shit on its ideas and said C was the only real systems programming language, but rust, which was pretty much Linear ML dressed up in C style syntax came from hyper weird functional programming language to trusted systems programming language. Why? Because it does memory management sooooo much better than C and is just about as fast. Guess what roc is doing? Memory management soooooo much better than C, and sooooo much less niggly and hard to get right than the borrow checker and is just about as fast.

                          Plenty of beginners program in rust by just throwing clone at every error the borrow checker sends them, or even unsafe! Bye bye advantages of rust, because it was hard to please. Roc calculates from your code whether it needs to clone (eg once for a reference to an unmodified value, each time for an initial value for the points in a new data structure), and like rust, frees memory when it's not being used.

                          Rust does manual cloning. Roc does calculated cloning. Rust wins over C for memory safety by calculating when to free rather than using manual free, totally eliminating a whole class of bugs. Roc could win over rust by calculating when to clone, eliminating a whole class of unnecessary allocation and deallocation. Don't be so sure that no one could do better than rust. And the devXP in rust is really poor.

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

                          There is no reference counting if the count is always one.

                          The defining feature of reference counting is that its a runtime check. Which in turn results in a runtime performance.

                          If there is no in memory counter at runtime, nobody calls that reference counting.

                          D 2 Replies Last reply
                          2
                          • tatterdemalion@programming.devT [email protected]

                            Isn't Zig working on their own backend?

                            Also, pretty excited about the cranelift project.

                            vpol@feddit.ukV This user is from outside of this forum
                            vpol@feddit.ukV This user is from outside of this forum
                            [email protected]
                            wrote last edited by
                            #21

                            Yes, and it’s now default for x86_64

                            B 1 Reply Last reply
                            4
                            • P [email protected]

                              cool new languages

                              COBOL

                              skullgrid@lemmy.worldS This user is from outside of this forum
                              skullgrid@lemmy.worldS This user is from outside of this forum
                              [email protected]
                              wrote last edited by
                              #22

                              It's new to gcc!

                              1 Reply Last reply
                              3
                              • C [email protected]

                                There is no reference counting if the count is always one.

                                The defining feature of reference counting is that its a runtime check. Which in turn results in a runtime performance.

                                If there is no in memory counter at runtime, nobody calls that reference counting.

                                D This user is from outside of this forum
                                D This user is from outside of this forum
                                [email protected]
                                wrote last edited by
                                #23

                                It's not as simple as that.

                                Roc does static reference counting too, otherwise it wouldn't be able to do opportunistic in place mutation. It can do static reference counting up to a known compile time bound, whereas rust can only count to one. Both of them can do runtime reference counting, but it's implicit in roc and explicit with Rc and Arc in rust.

                                For example, consider the pseudocode
                                {
                                h = "Hello, "
                                hw = h + "world."
                                hm = h + "Mum!"
                                }

                                In real life, this could be something less swervable.

                                Roc counts, at compile time, 1,2,3,0, drop. No problem.

                                Depending on how you declare these variables (with what additional keywords, symbols, string types and concepts), rust counts, at compile time, 1,release,1,2! No no no stop broken! Bad programmer! This was in this case an unnecessary premature optimisation. That's what I mean by rust counts references, but only counts up to 1.

                                The borrow checker is a static reference counter with an arbitrary number of immutable references that you must declare explicitly and a maximum of one mutable reference that you declare explicitly with mut or let under different circumstances. Arc and Rc are runtime reference counters that you declare explicitly. This is essentially all tracked in the type system.

                                Roc does the static reference counting and if the total doesn't rise above rust's maximum of 1, uses in place mutation (as opposed to the default immutability). If it is bounded it can use static (compile time) reference counting so that when, for example, all four local references fall out of scope, the memory is dropped. If the number is unbounded (eg parameter passing recursion that can't be tail-cpseudocode ilarly removed), runtime reference counting is used. This is all essentially tracked in the runtime system, but calls to clone are automated in roc. A beginner absolutely can write a memory hog in roc, but the same beginner is likely to overuse clone in rust and write a similar memory hog.

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

                                  There is no reference counting if the count is always one.

                                  The defining feature of reference counting is that its a runtime check. Which in turn results in a runtime performance.

                                  If there is no in memory counter at runtime, nobody calls that reference counting.

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

                                  runtime check. Which in turn results in a runtime performance.

                                  If you're calling drop on a mutable string that's been extended repeatedly, you're recursively dropping all kinds of mess all over the heap. Checking for zero beforehand has an insignificant impact. Those cache misses you had because rust pays less attention to "where" than it does to "whether", they cost you a lot more than the reference count check. In the real world, in practice, under profiling of real code, the cache misses and the branch misses are more expensive than the reference counting.

                                  You sound a little bit like a C programmer who claims his code is fast because his arrays don't do bounds checking. That's not why C is fast. Similarly rust isn't fast because it never does runtime reference counting. It does sometimes, but that code isn't pathologically slow.

                                  Also, rust isn't just fast because of the borrow checker, primarily it's memory safe because of the borrow checker.

                                  If it's any consolation, afaik, most of the roc platforms are written in rust. Also afaik only application specific code is written in roc. There are no memory management primitives in roc code unless a platform author exposes them in their api/interface, and I don't think anyone is working on implementing C on top of roc.

                                  C 1 Reply Last reply
                                  0
                                  • D [email protected]

                                    runtime check. Which in turn results in a runtime performance.

                                    If you're calling drop on a mutable string that's been extended repeatedly, you're recursively dropping all kinds of mess all over the heap. Checking for zero beforehand has an insignificant impact. Those cache misses you had because rust pays less attention to "where" than it does to "whether", they cost you a lot more than the reference count check. In the real world, in practice, under profiling of real code, the cache misses and the branch misses are more expensive than the reference counting.

                                    You sound a little bit like a C programmer who claims his code is fast because his arrays don't do bounds checking. That's not why C is fast. Similarly rust isn't fast because it never does runtime reference counting. It does sometimes, but that code isn't pathologically slow.

                                    Also, rust isn't just fast because of the borrow checker, primarily it's memory safe because of the borrow checker.

                                    If it's any consolation, afaik, most of the roc platforms are written in rust. Also afaik only application specific code is written in roc. There are no memory management primitives in roc code unless a platform author exposes them in their api/interface, and I don't think anyone is working on implementing C on top of roc.

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

                                    I don't know what you read on my reply. But your reply makes no sense.

                                    Let me rephrase it if you prefer:

                                    Claiming that Rusty's borrow checker is reference counting is hugely misleading. Since the borrow checker was made specifically to prevent the runtime cost of garbage collection and reference counting while still being safe.

                                    To anyone unaware, it may read as "rust uses reference counting to avoid reference counting, but they just call it borrow checking". Which is objectively false, since rust's solution doesn't require counting references at runtime.

                                    I don't know what mutable string or any of the other rant has to do with reference counting. Looks like you're just looking to catch a "rust evangelist" in some kind of trap. Without even reading what I said.

                                    D 1 Reply Last reply
                                    0
                                    • vpol@feddit.ukV [email protected]

                                      Yes, and it’s now default for x86_64

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

                                      I'll make my own LLVM, with blackjack and hookers.

                                      1 Reply Last reply
                                      3
                                      • D [email protected]

                                        It's not as simple as that.

                                        Roc does static reference counting too, otherwise it wouldn't be able to do opportunistic in place mutation. It can do static reference counting up to a known compile time bound, whereas rust can only count to one. Both of them can do runtime reference counting, but it's implicit in roc and explicit with Rc and Arc in rust.

                                        For example, consider the pseudocode
                                        {
                                        h = "Hello, "
                                        hw = h + "world."
                                        hm = h + "Mum!"
                                        }

                                        In real life, this could be something less swervable.

                                        Roc counts, at compile time, 1,2,3,0, drop. No problem.

                                        Depending on how you declare these variables (with what additional keywords, symbols, string types and concepts), rust counts, at compile time, 1,release,1,2! No no no stop broken! Bad programmer! This was in this case an unnecessary premature optimisation. That's what I mean by rust counts references, but only counts up to 1.

                                        The borrow checker is a static reference counter with an arbitrary number of immutable references that you must declare explicitly and a maximum of one mutable reference that you declare explicitly with mut or let under different circumstances. Arc and Rc are runtime reference counters that you declare explicitly. This is essentially all tracked in the type system.

                                        Roc does the static reference counting and if the total doesn't rise above rust's maximum of 1, uses in place mutation (as opposed to the default immutability). If it is bounded it can use static (compile time) reference counting so that when, for example, all four local references fall out of scope, the memory is dropped. If the number is unbounded (eg parameter passing recursion that can't be tail-cpseudocode ilarly removed), runtime reference counting is used. This is all essentially tracked in the runtime system, but calls to clone are automated in roc. A beginner absolutely can write a memory hog in roc, but the same beginner is likely to overuse clone in rust and write a similar memory hog.

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

                                        I don't know whatever that language is doing is called, but it's not reference counting. It's doing some kind of static code analysis, and then it falls back to reference counting.

                                        If you call that reference counting, what stops you from calling garbage collectors reference counting too? They certainly count references! Is the stack a reference count too? It keeps track of all the data in a stack frame, some of it might be references!

                                        D 1 Reply Last reply
                                        0
                                        • D [email protected]

                                          Roc uses immutable data by default. It performs opportunistic in-place mutation when the reference count will stay 1 (eg this code would satisfy the borrow checker without cloning or copying if it were rust - static code analysis).

                                          F This user is from outside of this forum
                                          F This user is from outside of this forum
                                          [email protected]
                                          wrote last edited by [email protected]
                                          #28

                                          Thanks, this looks really interesting. I've thought for a while that Rust's borrow checker wouldn't be such a pain in the ass if the APIs were developed with immutable data in mind. It's not something you can easily slap on, because the whole ecosystem fights against it. Looks like Roc is taking that idea and running with it.

                                          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