Tom Ritchford
1 min readDec 2, 2020

--

You seem long on the wild claims, short on the actual proof.

I have read many millions of lines of code, including code by some of the greatest programmers of our time.

Early returns are very common.

They mean less cognitive burden on the reader - "let's get this simple case out of the way and forgotten".

Your style means that a small addition to the error handling towards the start of a function results in a change to all lines remaining in the function.

One of the key steps in productionizing code is finding all the possible sources of error and handling them. With an early return style of code, each error test just adds a tiny block and affects nothing after it.

I note you don't show any code - my theory is that your code would make my eyes bleed.

Why don't you take a look at my code, at https://github.com/rec, where I use both exceptions and early returns, and see if you can point out areas which would be improved by your ideas?

Here are a few:

https://github.com/rec/safer

https://github.com/rec/editor

https://github.com/rec/tdir

https://github.com/rec/runs

--

--

No responses yet