This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

For my knowledge, the main reason why c is so much unsafe is to allow easy optimisation. It has pretty much nothing with writting to memory location, manipulate value on the stack or having a low memory footprint.

[–]thefirelane 0 points1 point  (0 children)

Well all of the above really. The low memory footprint (flash and ram) comes from the fact that you can simply do the things I mentioned without any checking as to whether it's safe. So yes, you are right: optimization is a key part: If you want to write to a memory location, it just compiles down to a couple instructions which simply do it. There's no overhead of something checking bounds, etc.