Why is exception handling bad?

前端 未结 15 1410
温柔的废话
温柔的废话 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:22

    Typical arguments are that there's no way to tell what exceptions will come out of a particular piece of code (depending on language) and that they are too much like gotos, making it difficult to mentally trace execution.

    http://www.joelonsoftware.com/items/2003/10/13.html

    There is definitely no consensus on this issue. I would say that from the point of view of a hard-core C programmer like Linus, exceptions are definitely a bad idea. A typical Java programmer is in a vastly different situation, though.

提交回复
热议问题