Comment by pdimitar

16 days ago

Sum types, of course.

How do you expect to use sum types in assembly? Remember where C came from and why it was designed the way it was.

  • A naive sum type is just a tag plus a payload. There is no problem here. If you have enums you could have had sum types.

    The historical argument and appeal to assembly is illogical here. The only real argument is that niche value optimization is too complex or too clever for the time so even if sum types were in C, nullable pointers would still exist either way.

  • I remember why C stayed what it is at least: elitism and gatekeeping. And YAGNI, repeated millions of times, of which only the first few were correct.

    You're telling me OCaml / Rust / Haskell compile to fairy pixie dust? Obviously their compilers figured it out and it works.

    • > I remember why C stayed what it is at least: elitism and gatekeeping.

      If that was the goal, it failed horribly - the gatekeeping didn't work because the popularity exploded.

      > You're telling me OCaml / Rust / Haskell compile to fairy pixie dust? Obviously their compilers figured it out and it works.

      I said nothing of the sort.

      9 replies →

How are you going to build sum types in a way where you can interact with assembly or machine code? The CPU doesn't know about that stuff

  • OCaml / Rust / Haskell.

    Apparently they found a way to have the CPU know... about "this stuff".

  • Sum types map down to reading a tag and doing a comparison against fixed values.

    I don't know what to tell you, but you're clearly not cut out to be a software developer in either machine code, assembly or C or any other language if you don't understand something this basic.

    • Please check your tone down, I'm arguing politely with you but apparently you're so wrapped up in this that you're resorting to ad hominems.

      Sum types aren't the be all end all to all issues, for example you can not representer pointer values efficiently with sum types. Even rust does not wrap up pointers with sum types. Now try to go back 37 years to C89 and ask yourself if they were going to require compilers to have stringent checks like the rust compiler does.

      4 replies →

    • That's unnecessarily rude, and untrue in any case. Everyone has to learn stuff sometime, and most people won't naturally run into the implementation details of how higher level languages get translated into machine code.

      1 reply →