C is memory safe if you program it well enough, so I guess C
You can still make stupid mistakes in Rust. It may make it harder to make the most common mistakes, but pretending the guardrails are prevent any type of mistake is asking for a problem to happen.
The only one pretending mistakes can’t happen is the person I replied to. Mistakes definitely can happen and no programming language is fool proof.
Continuing my car analogy, would you rather drive a car with airbags and seatbelts or one without them? Of course you can still have a fatal accident, but it’s nice to have safety features that make it as unlikely as possible.
C++ with -Wall -Werror, and no pointer diddling.
Its definitely best to try and avoid raw pointers, but even if you try really hard I found it’s not really possible to get a Rust-like experience with no UB.
Even something as simple as std::optional
- you can easily forget to check it has a value and then boom, UB.
The C++ committee still have the attitude that programmers are capable of avoiding UB if they simply document it, and therefore they can omit all sanity checks. std::optional
could easily have thrown an exception rather than UB but they think programmers are perfect and will never make that mistake. There are similar wild decisions with more recent features like coroutines.
They somehow haven’t even learnt the very old lesson “safe by default”.
If I wanted memory unsafety I think I would consider Zig instead of C++ at this point.
C++, with some Skill
/s
but seriously, I don’t know any language with a good, C/Cpp-like Syntax (so not Rust), with a good compiler (again not Rust). So I’m sticking to Cpp.
You should check out zig, its compiler can even be used for c/c++. If you have time to listen to an interview, this developer voices interview on zig explains some of the advantages of this: https://www.youtube.com/watch?v=5_oqWE9otaE&t=3970s
Thinking about zig for some stuff.
Mostly because those rusticles are pissing me off.
I don’t know what you are talking about?
Rust is such an amazing language, it’s so safe and clean and beautiful and simple and clear to read and such wow community that are making amazing crates for cargo because cargo is so cool I like it so much so easy to…
Oh, and your fav lang sux alot!1 lolololllll
That is a very specific subset
Garbage collection is still allowed, and technically JIT languages are still compiled so it really isn’t that restrictive
Python
They specified statically typed languages. Python would be dynamically typed
Python is dynamically typed by default, but lots of Python is statically typed.
No python is statically typed. You have type hints, which makes the language tolerable but like their name implies it’s a hint at the type. You can perfectly legally pass in something completely different that doesn’t conform whatsoever.
The primary thing static languages provide is static typing, that being the ability to determine before runtime that all the types are valid. A good example of this is how C++ programs will refuse to compile if you try to invoke a method that doesn’t exist on the type. That’s because it’s statically typed. At compile time you know that the code is wrong. Dynamic languages fundamentally don’t work like that. You cannot know until runtime if the method you called or the field you are trying to touch exists or not. Again type hints help a lot with this but that doesn’t change how the language actually operates.