All are good choices in the right context. None is unambiguously superior for all systems programming use cases.
Ask HN: Rust or C or C++ in 2023?
31–40 of 56 posts
Re: Ask HN: Rust or C or C++ in 2023?
#32Learn enough C to encounter the pain points C++ & Rust are trying to solve. C is simple, but not easy. Then learn enough Rust to be productive. Then learn enough C++ to interact with the enormous amounts of existing C++ code. Once you know a bit of all 3, decide where to focus based on the work you're trying to do. Rust is the easiest, but least widely supported. C is necessary either way, unless you're working for M…
> C is simple, but not easy. I think I know what you're trying to say, but unfortunately C is anything but simple. The semantics are riddled with surprises of all kinds. It's unlikely the average C programmer has never written a program with undefined behavior, for example.
I'd add that the average C programmer can't spot UBs before they cause a problem, they are not your average bug. Unless you're very well read or are just told about them, that is.
Re: Ask HN: Rust or C or C++ in 2023?
#33Re: Ask HN: Rust or C or C++ in 2023?
#34C is the best choice to learn systems programming. C is the simplest of C, C++, or Rust and most other languages have C interop or foreign function interface. First learn C and then you can learn Rust or C++ if needed. The concepts you learn in C programming will help you to better understand the more advanced concepts used in Rust or C++. Recommended first book: https://en.wikipedia.org/wiki/The_C_Programming_Langua…
Biases because that's how I learned, but yeah... I agree. Learning C will help you be a better programmer in any C-like language. C forces you to think like a programmer. Once you grasp that, you can learn most other languages with relative ease. Maybe not counting Lisps.
Re: Ask HN: Rust or C or C++ in 2023?
#35C is the best choice to learn systems programming. C is the simplest of C, C++, or Rust and most other languages have C interop or foreign function interface. First learn C and then you can learn Rust or C++ if needed. The concepts you learn in C programming will help you to better understand the more advanced concepts used in Rust or C++. Recommended first book: https://en.wikipedia.org/wiki/The_C_Programming_Langua…
+1 and I say this as a rust fan. The rust programmers that learned C first always have very elegant solutions and have the least issues in their unsafe blocks. C to learn how memory works and how to manage resources, then Rust to understand how to use a higher level systems language for more productivity in places where it helps. I work as a C++ dev and there are jobs in it, but unless you are trying to work a C++ jo…
C knowledge also helps to understand what rust's borrow checker is actually doing. And it will teach you what Box / Rc / etc are for. Its surprisingly easy to write rust code that Box everywhere, and runs very slowly in practice. (I've seen rust programs run slower than their javascript equivalents). Learning C first will give you the right knowledge base to appreciate rust and use it well.
Re: Ask HN: Rust or C or C++ in 2023?
#36Earlier quoted context omitted.
> C is simple, but not easy. I think I know what you're trying to say, but unfortunately C is anything but simple. The semantics are riddled with surprises of all kinds. It's unlikely the average C programmer has never written a program with undefined behavior, for example.
I'd go so far as to say it's unlikely the average C programmer has ever written a program with defined behaviour.
Re: Ask HN: Rust or C or C++ in 2023?
#37C is the best choice to learn systems programming. C is the simplest of C, C++, or Rust and most other languages have C interop or foreign function interface. First learn C and then you can learn Rust or C++ if needed. The concepts you learn in C programming will help you to better understand the more advanced concepts used in Rust or C++. Recommended first book: https://en.wikipedia.org/wiki/The_C_Programming_Langua…
Agree that C is easier to explore the concepts in, but knowing enough C to know why e.g. [0] gets the behavior it does is IMO not useful if the goal is to learn the _concepts_ before switching to a language that doesn't do this kind of thing. So, IMO worth jumping to Rust as soon as you feel confident with the stack vs the heap, use-after-frees, etc. [0]: https://godbolt.org/z/x7bf4edo9
I mean, why would I expect the parenthesised subtraction to do anything I can rely on? Or did you mean (&ys[2] - &ys[0]) ?
Re: Ask HN: Rust or C or C++ in 2023?
#38C is the best choice to learn systems programming. C is the simplest of C, C++, or Rust and most other languages have C interop or foreign function interface. First learn C and then you can learn Rust or C++ if needed. The concepts you learn in C programming will help you to better understand the more advanced concepts used in Rust or C++. Recommended first book: https://en.wikipedia.org/wiki/The_C_Programming_Langua…
However, it is not a productive systems programming language these days compared to C++, Rust, or Zig.
Re: Ask HN: Rust or C or C++ in 2023?
#39Otherwise go back in time and use Cyclone.
Or use Ada or Rust.
Re: Ask HN: Rust or C or C++ in 2023?
#40C is such a glorious language to competently develop software in, UB be damned.