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

Prohibiting exceptions is necessary in the embedded space for, err, space and allocation reasons.

Just crash the system and reboot the MCU can make sense depending on the application. And where it can't, you need to take the same kind of care for handling every single problem at the call site, or correctly propagating it to a layer that can handle it.

Exceptions aren't special here, they are simply a way to do error handling and recovery.

It's the kind of rule that doesn't make sense for applications, but when you've got tightly constrained memory limits, it makes sense.




Exceptions don't generate more space outside of code where you use try/catch, which is generally viewed as an anti-pattern.


I have personally removed exceptions (to be fair, it was only few) from an embedded application and introduced the -fno-exceptions flag. The binary size was reduced by ~20%, which can be important if you are doing SW updates to space and have a link budget... Also, the reduced code size is more cache friendly on a system with rather limited cache memories.


Well the problem was most likely with the code then, not the language feature -- because the changes are quite localized to throw sites and catch sites, not throughout the code.




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

Search: