Learn 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.
Ask HN: Rust or C or C++ in 2023?
51–56 of 56 posts
Re: Ask HN: Rust or C or C++ in 2023?
#52Earlier 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.
> It's unlikely the average C programmer has never written a program with undefined behavior 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.
No, the average C programmer probably can spot some UBs, but I think there are many more undefined behaviors than most C programmers realize. John Regehr wrote a series of blog posts about some of the trickier UBs, starting here: https://blog.regehr.org/archives/213
Re: Ask HN: Rust or C or C++ in 2023?
#53Earlier 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.
Right. But you can fumble through writing a lot of (maybe subtly wrong) C code. I certainly did for many years. You can't fumble through writing Rust. Its an order of magnitude more difficult to learn because the compiler won't compile "bad" code. Unlike C all the pain happens up front. Rust hurts when you're learning it. C hurts when you're trying to debug your program. If you've never written low level code before,…
With all that said, there are lots of things that Rust could do to make itself easier to learn. I believe it will get there, in time.
Re: Ask HN: Rust or C or C++ in 2023?
#54Earlier quoted context omitted.
So my 5k lines of C code project from back in college is all... undefined?
Almost certainly. Of course the only way you'll find out is when you upgrade GCC and it suddenly leaks the contents of your memory to the whole world.
Re: Ask HN: Rust or C or C++ in 2023?
#55The key to any of embedded, system, or low-level programming is as much about learning how the computer actually works to a reasonable degree. You are not programming to an abstract computation model. You are moving bits and bytes around and generating assembly code and talking to the machine at quite a low-level . So while Rust and C++ are higher-level languages with all kinds of nice features to be safer, concise,…
C++ is the de facto “most performant” language for a reason.
Re: Ask HN: Rust or C or C++ in 2023?
#56Earlier quoted context omitted.
> It's unlikely the average C programmer has never written a program with undefined behavior 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.
> the average C programmer can't spot UBs before they cause a problem No, the average C programmer probably can spot some UBs, but I think there are many more undefined behaviors than most C programmers realize. John Regehr wrote a series of blog posts about some of the trickier UBs, starting here: https://blog.regehr.org/archives/213
I dunno how I made that mistake even after copy/pasting, but I did, so I apologize for that.