imagine some code where you transform one object, like an API return, with a bunch of optional fields, into another. In python, you wrap it in a try, and if any don't exist, the code either fails, or recovered or whatever, but cyclomatic complexity ignores the entire logic chain, because there's no conditional.
now in rust, where each field needs a match arm that accepts the possibility of missing data, and cyclomatic complexity tells you the code is way more complex because it has all these conditionals.
but really, its the same, and the try/except in python is burying a bunch of complexity in the failure cases that rust is dealing with at compile time.
View all comments
0
u/StephenRoylance Oct 14 '26
cyclomatic complexity is kinda garbage though.
imagine some code where you transform one object, like an API return, with a bunch of optional fields, into another. In python, you wrap it in a try, and if any don't exist, the code either fails, or recovered or whatever, but cyclomatic complexity ignores the entire logic chain, because there's no conditional.
now in rust, where each field needs a match arm that accepts the possibility of missing data, and cyclomatic complexity tells you the code is way more complex because it has all these conditionals.
but really, its the same, and the try/except in python is burying a bunch of complexity in the failure cases that rust is dealing with at compile time.