Settings

Theme

The Impossible Optimization, and the Metaprogramming to Achieve It

verdagon.dev

9 points by verdagon 3 months ago · 1 comment

Reader

vrnvu 3 months ago

> Any time you are making decisions based on information that you know at compile time, you could apply this technique

I’d go further. Most business requirements are known at compile time.

Take the simplest example, dispatching a function based on a condition. If A then do_X, if B then do_Y.

People often reach for elaborate design patterns, dependency injection, or polymorphism here. But why? If the decision logic is static, don’t turn it into a runtime problem.

Inline the code. Move the ifs up. Write clear, specific functions that match your domain knowledge instead of abstracting too early…

Don’t make compile time problems runtime ones.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection