Why is exception handling bad?

前端 未结 15 1411
温柔的废话
温柔的废话 2020-12-04 05:46

Google\'s Go language has no exceptions as a design choice, and Linus of Linux fame has called exceptions crap. Why?

15条回答
  •  难免孤独
    2020-12-04 06:11

    From the perspective of golang, I guess not having exception handling keeps the compiling process simple and safe.

    From the perspective of Linus, I understand that kernel code is ALL about corner cases. So it makes sense to refuse exceptions.

    Exceptions make sense in code were it's okay to drop the current task on the floor, and where common case code has more importance than error handling. But they require code generation from the compiler.

    For example, they are fine in most high-level, user-facing code, such as web and desktop application code.

提交回复
热议问题