Hacker News new | past | comments | ask | show | jobs | submit login

I wonder would a compile time switch that enbales 'safe by default' be an option. At least then it means programs could transition to becoming fully able to compile in this safe mode and only let subsets (e.g. certain files in a project or old libraries) use the unsafe by default mode. It would be less of a sharp shock and could allow people time to transition, and know where to spend efforts to become safer.



One thing we do in the Firefox codebase is build using a clang plugin that we wrote to statically enforce additional rules.

It’s not a perfect solution , and obviously not built in, but it is a big help for avoiding footguns.


You can do a lot to make modern C++ programming safer with linters, clang-tidy, sanitizers, valgrind, etc. But it's a lot of work and a lot of compute to bolt that on top of a fundamentally unsafe language. It's out of reach for a lot of organizations and requires a substantial amount of organizational coding discipline.

It's like the old saw that gets trotted out about C and C++; you can write safe code in any language if you're disciplined about it. The point of safe languages is to make it easy and accessible to write safe code; to design into the language a "pit of success" rather than requiring a big slog to make a flawed language usable.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: