I don’t like that “C++ isn’t memory safe”. It is. Users of that language are usually just not experienced or educated enough and therefore more mistakes happen.
I agree though, that other languages like Rust or Java can make it easier to prevent such mistakes.
In my experience, using smart pointers alone already solves 90% of memory issues I have to deal with. C++ improved a lot in that regard over the decades.
I agree that experienced users can write code that leaks less than in C, leaving aside the bottomless pit of despair that is undefined behaviour. But the the language isn’t memory safe, it doesn’t even prevent you from returning a reference to a local or helpnwitg iterator invalidation. you don’t have to jump through any hoops to enable making that mistake.
If a language prevents you from doing stuff like that, this always comes at a cost, since it has to do the work for you, almost always. This is additional overhead you can get rid of in C++ and therefore gain a lot of performance. But that again comes with more responsibility on the developer’s side and you might need to implement appropriate checks yourself where needed.
Rust prevents the things mentioned above in the compiler; there is no runtime cost for most of Rust’s safety measures. There is definitely a build time cost though.
You can unsafe your way around anything, but that’s on the dev.
I don’t like that “C++ isn’t memory safe”. It is. Users of that language are usually just not experienced or educated enough and therefore more mistakes happen.
I agree though, that other languages like Rust or Java can make it easier to prevent such mistakes.
In my experience, using smart pointers alone already solves 90% of memory issues I have to deal with. C++ improved a lot in that regard over the decades.
The good news is that the browser comes from Serenity OS which means it probably is lightweight and well written.
I agree that experienced users can write code that leaks less than in C, leaving aside the bottomless pit of despair that is undefined behaviour. But the the language isn’t memory safe, it doesn’t even prevent you from returning a reference to a local or helpnwitg iterator invalidation. you don’t have to jump through any hoops to enable making that mistake.
If a language prevents you from doing stuff like that, this always comes at a cost, since it has to do the work for you, almost always. This is additional overhead you can get rid of in C++ and therefore gain a lot of performance. But that again comes with more responsibility on the developer’s side and you might need to implement appropriate checks yourself where needed.
Rust prevents the things mentioned above in the compiler; there is no runtime cost for most of Rust’s safety measures. There is definitely a build time cost though.
You can unsafe your way around anything, but that’s on the dev.