正在加载视频...

视频加载失败

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 条评论

Five 🐂🀄️ 的头像
Five 🐂🀄️9 个月前

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

rhelwig 的头像
rhelwig9 个月前

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.

Doge Tipping 的头像
Doge Tipping9 个月前

the good taste coding is even better than a Mexican coca

Alaoui Capital 的头像
Alaoui Capital9 个月前

Sometimes silence says more than code comments ever could

Petr Kraus 的头像
Petr Kraus9 个月前

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

David Deutsch 的头像
David Deutsch9 个月前

✔️

Jared Rogers 的头像
Jared Rogers9 个月前

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

Johnathon "Jack" Corcoran 👑 🇮🇪 的头像
Johnathon "Jack" Corcoran 👑 🇮🇪9 个月前

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

Jan Pocai 的头像
Jan Pocai9 个月前

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

Robert St Michael 的头像
Robert St Michael9 个月前

@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.)

syntap 的头像
syntap9 个月前

@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

MaX Falstein 🏴󠁧󠁢󠁥󠁮󠁧󠁿🇬🇧🇺🇸🇰🇾🇬🇮🇭🇰 的头像
MaX Falstein 🏴󠁧󠁢󠁥󠁮󠁧󠁿🇬🇧🇺🇸🇰🇾🇬🇮🇭🇰9 个月前

@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?

ZaxtR 的头像
ZaxtR9 个月前

True

Kashif Nadeem 的头像
Kashif Nadeem9 个月前

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.

Michel Colman 的头像
Michel Colman9 个月前

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.

Jade Siley-Winditt 的头像
Jade Siley-Winditt9 个月前

@elonmusk Teach you’re children 🙅🏾‍♀️

ちゅうまん@バックオフィス転職のリアル 的头像
ちゅうまん@バックオフィス転職のリアル9 个月前

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

Ziggy 🤷🏼‍♀️ 的头像
Ziggy 🤷🏼‍♀️9 个月前

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

Gill 的头像
Gill9 个月前

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.

Peter Ashwood-Smith 的头像
Peter Ashwood-Smith9 个月前

@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.

NSFW Data Guy 的头像
NSFW Data Guy9 个月前

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.

Ian Drsaurri 的头像
Ian Drsaurri9 个月前

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

MissingAFew 的头像
MissingAFew9 个月前

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

Corners 的头像
Corners9 个月前

taste sharpens code… 💻

ちゅうまん@バックオフィス転職のリアル 的头像
ちゅうまん@バックオフィス転職のリアル9 个月前

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." 🖧🚀

오뎅sla 的头像
오뎅sla9 个月前

@elonmusk good

DumbThangz 的头像
DumbThangz9 个月前

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

Adina 的头像
Adina9 个月前

@elonmusk That’s cool

DumbThangz 的头像
DumbThangz9 个月前

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 😂

Black Adder 的头像
Black Adder9 个月前

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

Coder Genius Guru 的头像
Coder Genius Guru9 个月前

Classic. Such a baller

Chuk Caviglia🇦🇷 的头像
Chuk Caviglia🇦🇷9 个月前

@elonmusk 🧐

相关视频