News for hackers. Stuff that matters.
Re:Rob Pike's 5 Rules of Programming by silisili on Wednesday March 18, 2026 @01:05PM (#47428309)
> In practice what I see fail most often is not premature optimization but premature abstraction

This matches my experience as well.

Someone here commented once that abstractions should be emergent, not speculative, and I loved that line so much I use it with my team all the time now when I see the craziness starting.

Re:Rob Pike's 5 Rules of Programming by hugey010 on Wednesday March 18, 2026 @03:46PM (#47430535)
I completely agree with you, and that is an amazing quote.
Re:Rob Pike's 5 Rules of Programming by senderista on Wednesday March 18, 2026 @04:28PM (#47431010)
“Abstractions should be written in blood”
Re:Rob Pike's 5 Rules of Programming by catlifeonmars on Thursday March 19, 2026 @02:00AM (#47435499)
Some abstractions are obvious though. There is value in reusing them across projects and not reinventing the wheel each time. I don’t think this is counter to what you propose necessarily, just adding the nuance that abstractions serve another purpose: communicating intent to the readers of the code. Sometimes a concrete type is unnecessary detail.
Re:Rob Pike's 5 Rules of Programming by silisili on Thursday March 19, 2026 @02:31AM (#47435682)
Absolutely. I don't take that quote to mean we should all start from ground zero every time...if so experience wouldn't have much value.

I more think the point is that the abstractions now obvious to you emerged at some earlier point that you now recognize, and application makes sense. Speculative implies predicting, and if you've been around long enough in the same domain, it's likely you aren't guessing.

It's probably something that applies more to younger devs than older, but not exclusively of course.

Re:Rob Pike's 5 Rules of Programming by globular-toast on Thursday March 19, 2026 @02:40AM (#47435731)
But they should emerge right when they are needed, not some time later via a painful refactor.

I think every dev lives in fear of the situation where abstraction hasn't been done when it really should have. Maybe some junior dev came in after you and shoehorned in a bunch of features to your "simple" solution. Now you have to live with that but, guess what, there's no time to refactor it, in fact the business just wants even more features.

As usual these rules work best if everyone on the team understands them in the same way. If you work with people who can only see what is right in front of them (ie. the current feature), then it'll never work. You can always fit "one more feature" into the perfect codebase without thinking about the abstractions.

Re:Rob Pike's 5 Rules of Programming by silisili on Thursday March 19, 2026 @02:48AM (#47435787)
In a perfect world, sure. In my personal experience, refactoring to introduce an abstraction is far less painful than refactoring to remove or fix one.

Usually because intent is far clearer in the former case.

Re:Rob Pike's 5 Rules of Programming by teapot7 on Thursday March 19, 2026 @03:07AM (#47435898)
Similar to when someone said that the rule of thumb should not be DRY (don't repeat yourself) but WET (write everything twice) - that is, be happy to repeat similar code once or twice, and wait for the need for abstraction to become evident.

It's advice I like, as I'm prone to falling into design paralysis while trying to think of the One True Abstract Entity.

Re:Rob Pike's 5 Rules of Programming by naikrovek on Thursday March 19, 2026 @08:26AM (#47438187)
> abstractions should be emergent, not speculative

Dang, I love that line, too. It is 100% correct, and the opposite of what OOP teaches.