Does anyone have any suggestions for such examples? Any language is fine. As long as there's some way to say "look, here is where people say this is great code".
https://www.gnu.org/software/mes/manual/html_node/LISP-as-Ma...
https://betterexplained.com/articles/understanding-quakes-fa...
Also a lot of 4k demo scene have some great looking videos rendered purely by a small amount of code.
In the year 2033 Earth was discovered by Survey Fleet MCXII of the Galactic Empire. The Emperor ordered Earth to send a representative to the court, with strict instructions to “bring something beautiful”.
Emperor: What beautiful things does Earth have?
Earth Representative: Your excellency, our mathematician Euler proved in our year 1737 that
+/(1+⍳∞)*-s ←→ ×/÷1-(⍭⍳∞)*-s
Emperor: What is the ⍭ symbol?Earth Rep.: ⍭i is the i-th prime.
Emperor: And what is ∞? Does it do anything useful?
Earth Rep.: It denotes infinity, your excellency.
Emperor: (ponders equation for a minute or two) Respect!
Emperor: Neat notation you have there. Tell me more.
Earth Rep.: Your excellency, it’s called APL. It was invented by the Canadian Kenneth E. Iverson…
The C 'Hello, world!' program documented the style of a whole programming language in 5 lines of code. Every computer engineer who sees it can now recognize C code. Even non -programmers understand vaguely what's going on.
Just about every programming language today starts with the same example. That's how wildly succesfull it became as demo.
This isn't just a small implementation of the C standard library, it's an absolute joy to read and usually every easy to understand. It takes real talent to write code which is both this legible and efficient.
Often when I'm trying to understand what glibc is doing I'll read the musl version of a function and that will give me an indication of what the glibc source is trying to communicate.
He was one of the Gang of Four who wrote Design Patterns, but he wrote this library years before the book came out. It always seemed to me that he invented all the main patterns in the Interviews library before they were subsequently (nicely!) documented in the book (which went on to become a smash hit).
I've since realised that I much prefer functional programming (Clojure!) over OO, BUT, oh my goodness, what a truly groundbreaking and beautiful bit of work it was for its time. I read every line of code in that library, and I became a much better programmer for it.
You could charge a credit card with just 7 lines of code.
But I've heard good things about the Fast Inverse Square Root Calculation algorithm in the Doom 3 source code. https://www.youtube.com/watch?v=p8u_k2LIZyo