Live data from Hacker News

Ask HN: What is the most enlightening concept that changed how you program?

news.ycombinator.com

21–30 of 33 posts

Re: Ask HN: What is the most enlightening concept that changed how you program?

#21
Foregoing perfectionism, elitism, and fashion in favor of code that Just Works. Functional is nice, concurrent is a nice, sometimes necessary transformation, "compression-oriented" sounds cringe and complicated-pilled (but I'm sure it's nice). But I'm not here for nice things, I'm here for profitable things, and profitable things need to Just Work. They don't need to be functional, or algorithmically perfect, or nerdically sound.

Procedural is fine and simple and it works. You can refactor later if you have the time and money.

Related listening/watching: Jonathan Blow.

Re: Ask HN: What is the most enlightening concept that changed how you program?

#22
Dependency injection & Inversion of control.

Technically 2 concepts but they’re highly related.

Basically, allow the consumer of a component to pass in something, rather than the component needing to contain that logic.

It’s great for front end systems, but also apples to backend and general systems programming… an invaluable concept

Re: Ask HN: What is the most enlightening concept that changed how you program?

#23
post #9

YAGNI and WET - You Ain't Gonna Need It and Write Everything Twice - Copied code leads to simple bugs; premature abstraction leads to heartbreak.

> premature abstraction leads to heartbreak Could you please elaborate on that? I'm not sure to understand.

In my experience abstracting before you know all the use cases is generally the problem.

Write the simplest abstraction first, then as the system develops combine similar use cases into useful abstractions for clarity

Re: Ask HN: What is the most enlightening concept that changed how you program?

#24

YAGNI and WET - You Ain't Gonna Need It and Write Everything Twice - Copied code leads to simple bugs; premature abstraction leads to heartbreak.

> premature abstraction leads to heartbreak.

Anything that is “premature” is per definition incorrect. So there is no information in that sentence.

Having said that, a lack of architectural abstractions leads to badly designed code with a WTF count reaching the heavens. Have you ever seen UI code directly relying on a specific flavour of SQL implementation and database? That’s an example of how a lack of architectural abstractions leads to spaghetti code. Or how about the domain logic directly relying on a specific UI framework? Another example where an early architectural abstractions would have saved years of maintenance work. Again something I see all the time in the wild.

Re: Ask HN: What is the most enlightening concept that changed how you program?

#25

Foregoing perfectionism, elitism, and fashion in favor of code that Just Works. Functional is nice, concurrent is a nice, sometimes necessary transformation, "compression-oriented" sounds cringe and complicated-pilled (but I'm sure it's nice). But I'm not here for nice things, I'm here for profitable things, and profitable things need to Just Work. They don't need to be functional, or algorithmically perfect, or nerd…

Let me play devils advocate here for a second.

I have seen a lot of videos of Jonathan Blow. IIRC he created his own programming language to code in. That could be interpreted as pretty "nerdically sound" and "perfectionist" by many.

My point is, I agree with what you said in spirit, but the way you phrased it could be used to justify spaguetti code, too much technical debt and, ironically, fashion-based decisions (we need to just make it work, lets choose x).

Re: Ask HN: What is the most enlightening concept that changed how you program?

#26

YAGNI and WET - You Ain't Gonna Need It and Write Everything Twice - Copied code leads to simple bugs; premature abstraction leads to heartbreak.

> premature abstraction leads to heartbreak. Anything that is “premature” is per definition incorrect. So there is no information in that sentence. Having said that, a lack of architectural abstractions leads to badly designed code with a WTF count reaching the heavens. Have you ever seen UI code directly relying on a specific flavour of SQL implementation and database? That’s an example of how a lack of architectura…

Not op, but let me rephrase it:

leaky abstractions create more trouble than is worth it. If your abstraction does not fit the problem neatly do not abstract it.

Re: Ask HN: What is the most enlightening concept that changed how you program?

#29

Avoid deep nesting by testing error case first and exiting/returning immediately. Instead of : If foo then bar Else baz Endif Now I write: If foo then bar return Endif baz Exit early makes the code easier to read and understand

IMO the example you provided is an anti-pattern. There are better ways to avoid deeply nested code, but it depends on the programming language.

I try to make each method/function to have a single entry and a single exit.

Cond, case, pattern maching in function heads, decision tables, and syntactic sugar in some PLs, allow you to flatten the nested code / branchinbg / conditionals.

Re: Ask HN: What is the most enlightening concept that changed how you program?

#30

Earlier quoted context omitted.

> premature abstraction leads to heartbreak. Anything that is “premature” is per definition incorrect. So there is no information in that sentence. Having said that, a lack of architectural abstractions leads to badly designed code with a WTF count reaching the heavens. Have you ever seen UI code directly relying on a specific flavour of SQL implementation and database? That’s an example of how a lack of architectura…

Not op, but let me rephrase it: leaky abstractions create more trouble than is worth it. If your abstraction does not fit the problem neatly do not abstract it.

Leaky abstractions are bad abstractions. So what you are basically saying is “don’t implement bad abstractions”. Ehhhh right. I think we can all agree to not implement bad things. There is no insight or enlightenment there IMHO.
Post reply on HN