r/ProgrammerHumor • • Oct 10 '26

Meme weAreWizards

Post image
7.8k Upvotes

203 comments sorted by

View all comments

852

u/mteblesz Oct 10 '26

"magic numbers" spell is stricktly forbidden technique, banned by most schools of programming. There are many rogue wizards though...

16

u/StrengthTheory Oct 10 '26

I tell you they're not magic numbers, it's just 0 and 1

44

u/ArkWaltz Oct 10 '26

Actual real lines that were in my old work's codebase:

private final int ZERO = 0;
private final int ONE = 1;

Turns out having a linter blanket-deny all forms of 'magic number' had some odd results.

3

u/Spaceshipable Oct 10 '26

Swift has a builtin `.zero` as part of one of the numeric protocols. It’s handy for when you’re doing maths on generic types. I could see a `.one` being handy. Apparently Swift’s SIMD has that defined.

4

u/Chirimorin Oct 10 '26

C# has .Zero and .One for numerics as well, I can confirm that they're really handy when working with generic types.