3 ms·
The semantics of C and how to write code that is well defined is much more complex than assembly.
by kbenson 5y ago
The semantics of C and how to write code that is well defined is much more complex than assembly.
- formerly_proven 5y agoC is easy to read and follow though. Rust has far more syntax and as a language is way beyond the complexity of C.
- nicoburns 5y agoOnly if you know C but not Rust. I personally find Rust fairly easy to follow and C a complete nightmare (the details in C are ok, but it's really hard to see the forest for the trees).
- edgyquant 5y agoI know C and can get by in Rust and I disagree that rust is easier to follow. C is a simple language, the complexity comes from large systems, while Rust is just not.
- nicoburns 5y agoWell I know Rust and I can get by in C. Perhaps that makes a difference. > C is a simple language, the complexity comes from large systems, while Rust is just not. I mean I agree that C is simple if you're making a 50 line program that writes to stdout or something. But more often than not with C or Rust you are working with a large complex system. And I'd argue that when working with such a large system, Rust programs are less complex than C programs.
- formerly_proven 5y agoThere is a huge difference between reading and writing C. C is very easy to read, but it's quite difficult to write (secure, portable, performant) C. Code is typically read a lot more than it is written. I haven't written a single line of code in torvalds/linux.git but read probably tens of thousands of lines of Linux kernel code over the years. I'd wager that for every kernel developer there are at least 10 people reading the code to figure out how something works, or how it broke. C makes many questions when reading trivial to answer, questions like "how do I get here?", "where does it go?", "what is this type?" and "what does this code do?" are generally very easy to answer without expert-level C knowledge. From what I've seen, that's not true for rust.
- edgyquant 5y agoI disagree. You can learn the semantics of C in a day, assembly requires a ton more memorization and a ton more code to write. C is more abstract that assembly but it is less complicated, on its face, than assembly or rust.
- kbenson 5y agoIf you're familiar enough with programming to learn C in a day, you can learn assembly in a couple hours. It's really not that complicated. You can copy to/from memory addresses to local temp variable containers that are various sizes of bits (registers), you can do various math operations on those bits in those registers, you can compare those registers and test that comparison, and you can jump from the current point in the code to any other point by label or address (go-to). Sometimes operations will result in other registers you can check to see if something happened (overflow). The OS will provide some interrupts to do some base things as interrupts such as IO. If you didn't know how to code in assembly already, you now know enough to do everything C can do with a simple reference sheet. All the extra boilerplate (such as program segments and where to store costants such as what the 'strings' program sees in a binary) you can read two to three pages to explain what you need for whatever OS you're on. Assembly isn't hard, it's just tedious.