正在加载视频...
视频加载失败
Linus Torvalds explains "taste" in code by showing how to remove an entry from a singly linked list in C without adding extra complexity.
652,125 次观看 • 10 个月前 •via X (Twitter)
32 条评论

C code elegance is rare these days. Love how Linus breaks it down

The first "bad" code is clear and easy to understand. It also makes everything explicit. The second code is much harder to understand and maintain. It obscures details. It requires an expert to maintain.

the good taste coding is even better than a Mexican coca

Sometimes silence says more than code comments ever could

The "good" variant is awful in its own special way.

✔️

This guy's smelled his own farts for too long.

Fewer branches, fewer edge cases. That's real craftsmanship in C.

@elonmusk So the taste has a lot to do with subconscious knowledge

@elonmusk “Taste” in coding is esoteric BS. Two things, and only two things, are important: (1) efficiency in execution in code steps that execute frequently, and (2) clarity for maintainability. (Size hasn’t mattered for decades.)

@elonmusk There’s probably no human on the planet who has changed our everyday technology usage so much, yet conversely so unknown by most of the population

@elonmusk Elon, any chance we could convince Linus Torvalds to do a massive livestream of him going through the Linux Kernel telling his stories and the mess he prevents?

True

A perfect example of elegance in programming doing more with less while keeping clarity. True taste is often about simplicity, efficiency, and readability all at once.

His code is slower. More indirection, the difference for long lists will be significant. His code would only be better for really short lists of two or three items.

@elonmusk Teach you’re children 🙅🏾♀️

Linus Torvalds on "good taste" in code: It’s not about how complex you can make it, but how much complexity you can remove. Most devs use an if statement to handle the head of a linked list. Linus uses a pointer-to-pointer (**) to treat every entry exactly the same. No special cases. No branches. Just pure, indirect logic. That is the difference between a coder and an architect. 💻✨ #CProgramming #LinusTorvalds #CleanCode

Both are ok but could still be improved, code should be clear and easy to proof 🤷🏼♀️

This is about minimizing state and invariants: pointer-to-pointer deletion collapses traversal + mutation into one operation, reducing branching, temporary variables, and cognitive load. Fewer moving parts —>fewer bug surfaces —>better cache of correctness in the reader’s head.

@elonmusk Three memory references in his tasteful loop vs 1 .. not sure trading off a single “if” outside the loop is worth that cost?. As much as I admire him I think performance is more important. Anyway ive certainly done both over the years.

He didn't add extra complexity, or even remove it. His point is to redefine the problem such that complexity isn't something to be removed or avoided.

But, these are both awful from different standpoints. Neither is better than the other

I don't need good taste I just need good vibes 😏

taste sharpens code… 💻

Still thinking about Linus Torvalds’ linked list example. By focusing on the address of the pointer to the next item, rather than the item itself, the "head" of the list becomes just another pointer. This is why C remains the king of systems programming. It rewards those who understand memory at a fundamental level. If you can eliminate an if statement with a **, you’ve found the "Taste." 🖧🚀

@elonmusk good

The woke cargo culters present in most management positions would have already configured the linter to ban the 2nd style...

@elonmusk That’s cool

The woke cargo culters present in most management positions likely shit on the Linux kernel because it uses goto and many functions are more than 100 lines of code 😂

@elonmusk I have never been able to taste code. I also wonder when then was dropped.

Classic. Such a baller

@elonmusk 🧐

