Live data from Hacker News

Good code is like a love letter to the next developer who will maintain it

addyosmani.com

161–170 of 274 posts

Re: Good code is like a love letter to the next developer who will maintain it

#161

After almost 20 years of writing the best code I can muster as much as I can, I’ve come to understand that most people won’t ever really appreciate it for the effort you put in. Many won’t even notice; they’re too preoccupied with their own lives to open their eyes to what is there. Nor do they give a damn about mastery. But, that doesn’t mean it’s a waste. I don’t think I’d do much differently in retrospect, except…

Let's share our gratitude indeed; it's like a warming fire.

I have had extraordinary coworkers who wrote incredibly solid code that was a joy to work with at every turn. When some of those coworkers have moved on, I've bought them thank you presents and taken them out for a meal to say thank you for making a difference. It's a token gesture in the face of how much I've learned from them and their wonderful work.

My message is to all of us who work away in the trenches of our day-to-day, where we stare through straws and move grains of sand; please let us shout and celebrate the granules of gold that our peers produce!

Re: Good code is like a love letter to the next developer who will maintain it

#162
post #102

Earlier quoted context omitted.

By linking to those examples you confirmed the point you were trying to refute. From my personal perspective this is mediocre code at best. It’s written in an unsafe language. Littered with macros, which in C are not hygienic and are land mines in waiting. Constants defined with lowercase and not actually marked as const. Double underscores everywhere, which are the bad alternative to namespaces seen in weak language…

The issue so very many people fall into is assuming some foreign-looking codebase is awful. What people typically mean to say is something along the lines of "I haven't a clue what this does, haven't enough experience with the language to understand it, or how people use it". Go look at code written in "safe" languages like Rust and tell me you understand what it's doing any better than well written C code. You have…

For reference, I have many years of experience with C, C++, Rust, and even Haskell.

That kernel C code still looks awful to me.

I've seen beautiful code in every language including C.

Re: Good code is like a love letter to the next developer who will maintain it

#163
post #102

Earlier quoted context omitted.

By linking to those examples you confirmed the point you were trying to refute. From my personal perspective this is mediocre code at best. It’s written in an unsafe language. Littered with macros, which in C are not hygienic and are land mines in waiting. Constants defined with lowercase and not actually marked as const. Double underscores everywhere, which are the bad alternative to namespaces seen in weak language…

The issue so very many people fall into is assuming some foreign-looking codebase is awful. What people typically mean to say is something along the lines of "I haven't a clue what this does, haven't enough experience with the language to understand it, or how people use it". Go look at code written in "safe" languages like Rust and tell me you understand what it's doing any better than well written C code. You have…

You’ve circled back to the same point the person you’re replying to was supporting:

“ the problem is one of cultural context which is often not shared between generations of coders. “

There is no such thing as absolutely good code. It’s context dependent and context tends to be ephemeral. The Linux kernel is in some ways an exception, but also appreciated by a pretty small group. The rant against the kernel code is meant to be illustrative - if you don’t know the conventions, abbreviations, if you’re not operating in the context of an early 21st century OS, where memory is handled manually, none of this looks particularly great.

Code is cultural and cultures are niche and ever changing. Particularly these days. The same technology that enabled the fast rise of, say, Ruby, or Go, or Rust makes your code and my code depreciate quite quickly.

Re: Good code is like a love letter to the next developer who will maintain it

#164
post #50

Meh. I've seen teams and projects bogged down by "good clean code" rules and nit picking code reviewers. These folks, typically "staff" engineers, over-police the repos and care more about clean code than delivery and execution. I'm waiting for the day where AI/co-pilots can enforce team and industry best-practices, style, maintainability, testability, etc before the code is even committed. Call it "uber-linting" and…

I'm working with someone who asks me to remove documentation that summarizes what a function does.

(The whole codebase is stripped bare of documentation.)

Copilot can write implementations based on comments. Soon I think it could flag potential errors if code doesn't do what the comment claims it does. Then we can do that in code checks.

Re: Good code is like a love letter to the next developer who will maintain it

#165

Earlier quoted context omitted.

I think I just fell in love with you. Finally a sane person Honestly, I never understood why so many developers abbreviate function names or variables. Is it so much pain to type abc for auto completion? Why not simply name fd file_descriptor? Short names are a mental barrier and a level of abstraction that can easily be avoided.

Information density matters.

[deleted]

Re: Good code is like a love letter to the next developer who will maintain it

#167

As someone who has gone back and read my old code as well as a lot of others old code, there is no such thing as good code. IMHO, the problem is one of cultural context which is often not shared between generations of coders. Languages and best practices can change so violently that best-practices one decade are often anti-patterns in the next. As a codebase outlives its best-practices, do you stick with them and ext…

But thats exactly good code. Code that is clear (well-formatted/readable), works and can be easily proven that is really working.

Re: Good code is like a love letter to the next developer who will maintain it

#168

Earlier quoted context omitted.

By linking to those examples you confirmed the point you were trying to refute. From my personal perspective this is mediocre code at best. It’s written in an unsafe language. Littered with macros, which in C are not hygienic and are land mines in waiting. Constants defined with lowercase and not actually marked as const. Double underscores everywhere, which are the bad alternative to namespaces seen in weak language…

While I don't think this code is the best, these complaints are like disliking Shakespeare because his writing is archaic. Yeah, no shit. Good writing is relative to the norms and expectations of the audience, which are other kernel developers in this case. It’s written in an unsafe language. So is every other mainstream kernel. Double underscores everywhere, which are the bad alternative to namespaces seen in weak l…

> disliking Shakespeare because his writing is archaic

But... his writing is archaic. Not just quaintly archaic, like a novel from the 1800s, but literally requiring translation archaic.

Worse still, the vast, vast majority of people "teaching" Shakespeare pronounce it wrong, which means most of the humour is lost: https://www.youtube.com/watch?v=YiblRSqhL04

The jokes don't work any more!

The rhymes sound wrong!

The whole thing is a farce. Theatre. We all pretend it is great English, whe in fact it isn't even English any more.

It's taught because our teachers were taught it. Those teachers... and on.

It's like the idiots still formatting cloud SSD virtual disks as-if they are physical RAID controllers with spinning rust.

It's like the Hungarian notation identifier style people copied from the NT kernel code, even though the NT kernel people realised it was a mistake and moved on.

The Linux kernel code would be crazy bad if it wasn't for tens of thousands of people beating on it until it has become merely mediocre.

It will never be perfect, it'll never even be "good" code. It has too much inertia, too much history for that to ever happen.

Re: Good code is like a love letter to the next developer who will maintain it

#169

Precisely why I also create READMEs in top-level directories. I'm not going to remember how to structure queries for my API a year from now. Future me will always appreciate how considerate present me was.

One can figure out 'how' and 'what' from the code, given enough time. The most valuable thing in code is the brain of the Past Person who wrote it, looming over your shoulder, telling you 'why' in very explicit terms.

That 'why' also helps to show that Past You knew wtf you were doing, and lets Present You feel confident in making changes, because you know what the intent was.

"I'll remember this!" is one of the greatest lies in CS.

Post reply on HN