Skip to content

Comment on John Carmack discusses the art and science of software engineeringparent

Comments

I hope he means

> if (obj != null && obj.isValid()) { }

Which is semantically correct due to the fail-fast evaluate of AND, it does require a double check since it's strange from a logic point of view. This is one the reasons that brace languages are hard to optimize since you can't commute things that ought to commute.

That statement can't be commuted because it expresses a concept that can't be commuted.

If the two checks were independent (pure functions), it's not difficult for a compiler to determine that given enough program visibility.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.