by joaquincabezas · 2y ago · 0 comments
Go with:
C++, because I used to code in C (for embedded, 8-bit microcontrollers) when I was younger and also for its possible advantage for learning some CUDA (this last thing is mostly for fun)
or
Rust, because I have some trauma for kernel panics with bad memory management back in the days with C, and because I want to build some tooling in a nice, efficient way
Also, you'd probably have found these quickly, but cppreference.com is the nicest C++ reference (!cppref on DuckDuckGo) and doc.rust-lang.org (!rust on DuckDuckGo) has the Rust standard library documentation.
In C it often (too often actually but that's a different rant) feels as though what you wrote just translates directly into what the machine does, no surprises, so then it seems intuitively to make sense that this delivers good performance. And it's not anywhere close to obvious in idiomatic C++ or Rust, where yeah, "more Java" in some sense.
One option is to trust it, it's the fastest option as it's no work but you may find you can't bring yourself to do that.
Another option is to satisfy yourself by measuring, time it, or measure how big it is, now and again when you find something that seems like it ought to be dramatically worse - is it really worse? Huh.
The final option, which is very time intensive, is to learn the depths of how this actually works. That probably means learning assembly language, and a bunch of things about how CPUs work, how memory works, etc. If you never did this for C, I'd suggest not starting now as it's a huge time sink and is often going to shake what you thought you knew. But it's an option if you aren't satisfied by the other options.
Note that most people who use Compiler Explorer don't actually know assembly that well, but you don't need to know it to see what is happening at a basic level, which usually suffices.
However, it is not necessary to care so much about performance in most cases. The language is generally fast compared to other languages, even if you don't try to make it fast -- the compilers and the language spec usually have that outcome. But when you really want to squeeze out the most efficient code, Compiler Explorer is the way most people do it.
If you already know C and Python, it would be a better and faster choice. I’m more a C++ expert, but I’ve written a few small command line tools in Rust and it looked a bit like the Python equivalents.
I dont want to comment about rust, but personally I just don't like ideological people. Also some people seem to not understand, that the set of all valid computer programs is greater than the set of all programs that can be proved correct. It is a fact and can be proven.
Imo C# is a well designed language and would be the best start to learn more about a modern statically typed language. Swift is also interesting, but its mostly apple and has similiar ideologic problems like rust (e.g. pointers are evil).
What exactly are you afraid of?