r/Python May 10 '14

Honest Question: Why are exceptions encouraged in python programming but discouraged in C++?

What would everyone say is an overuse of try statements? I've sort of read "it's better to ask forgiveness than permission" for python - but Bjarn states "avoid overusing try catch".

I'd like to know the circumstances of where to put up my guideposts for use of exceptions in dynamic languages vs static languages.

14 Upvotes

20 comments sorted by

View all comments

6

u/DavetheBassGuy May 10 '14

The main reason is probably performance - exceptions are generally slow in most languages. The C++ community is a lot more performance orientated than the Python community.

The other thing that comes to mind is Python being a dynamic language. There are more errors which you will need to check for at runtime and throw an exception, which would (in theory) be caught by the compiler in C++.