Comment Re:I don't currently use Rust (Score 5, Insightful) 161
Just to point it out, in case people drink the kool-aid.
Just be cause "Rust does this thing better" does not mean you should always use Rust instead of C. You should always be using C when performance matters. Not Rust, not C++. If anything, C developers should be always using
Realistically, string handling sucks in C because of the baggage of ANSI C, as wchar_t makes things horrible to debug.
The thing that would make C/C++ code safer from the start to implicitly check the length of variables, instead of having to pass the length.
All post-unicode languages such as Rust, Javascript and Python (not PHP or Perl) handle their strings internally as unicode, thus you don't actually need to know the length of the string to pass to it. In C is a UTF-8 string have a BOM? Does it use Windows, Mac or Unix line endings? you have up to three additional non-printable characters when dealing with unicode. Then there is Windows which is an additional special hell because it's wchar_t is UTF-16 in visual C but UTF-32 in GCC. Yet the vast majority of software out there only wants to deal with UTF-8.
If C and C++ natively did UTF-8, a good chunk of mistakes would not happen. Pointer nonsense not withstanding, most of the mistakes in C could probably be tracked by an AI linter and OSS projects could just fix things instead of publishing code that would fall under treating all warnings as errors. It's the pointer stuff that trips up people who don't understand the underlying assembly language code it would make. So people not familiar with C or ASM will constantly use variables that use the local registers rather than the ram address, and then wonder why the compiler complains about stack space.
Fun fact "the switch" statement is a heavy use of the stack space, because the compiler is unwrapping this to a series of "jump if equal" which is equal to "if" statements. This is the purpose of making functions as small and single-purpose as possible and antithesis of C++ classes. This is why you don't use C++ in performance code.
Rust seems to aim to be "better C" but doesn't necessarily do so since it technically runs on the C runtime. I think Rust might be fine to use in things outside of kernel space, but it seems like it might be expensive to use in the kernel/driver space.
Meanwhile, Nvidia, AMD, Razer, and Logitech are out there making "Driver" bundles that are full on chromium embedded frameworks , going in much the wrong direction. These companies have stopped caring.