Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. When did Google get so weird? (sancho.bearblog.dev)
    102comments
  2. Ember-1 (fireworks.ai)
    127comments
  3. Alan Kay's answer to "Did the ENIAC have a BIOS"? (quora.com)
    14comments
  4. Show HN: Lofi Cities – Pixel-art city nights with browser-generated lofi (loficities.com)
    30comments
  5. The state of SIMD in Rust in 2026 (shnatsel.github.io)
    7comments
  6. Lunar Terminator Paradox (secretsauce.net)
    —discuss
  7. Imp is a full port of DSPy to the BEAM (github.com/deepfates)
    4comments
  8. In an $80 motel room, a discovery to shed light on the origins of life (nytimes.com)
    67comments
  9. What I did at Recurse Center (thill.me)
    5comments
  10. Don't couple your Go code to GitHub (iain.rocks)
    33comments
  11. Oral history of John Chowning, inventor of FM synthesis [video] (youtube.com)
    4comments
  12. Writing Efficient C++ Code (2013) (asawicki.info)
    71comments
  13. Replacing the old battery on rechargeable bike lights (jvns.ca)
    59comments
  14. Show HN: TinyAIArena watch AI agents battle it out (tinyaiarena.com)
    36comments
  15. The Cartesian Hand: In-Hand Manipulation with All-Linear Fingers (generalroboticslab.com)
    6comments
  16. Fragment of oldest known peace treaty found in Turkey (livescience.com)
    6comments
  17. The Normalization of Inexplicable Failures (ihatethefuture.com)
    85comments
  18. There is more to code review than (automatable) detection (adaptivecapacitylabs.com)
    1comments
  19. Flip Fluid on Flip Dots (mitxela.com)
    22comments
  20. Kicki: A DECsystem1060 – Interim Computer Museum (icm.museum)
    2comments
  21. Fakecloud: Local AWS cloud emulator for integration tests (fakecloud.dev)
    46comments
  22. John Coltrane Centenary's – Impulse Records Release the Legendary Tiberi Tapes (jazzwise.com)
    7comments
  23. Faster prompt lookup drafting in llama.cpp (jadidbourbaki.github.io)
    8comments
  24. On caring for user data: NeoVim caused Vim undo files to be deleted (aresluna.org)
    281comments
  25. Video CDs Break Windows Explorer (clydesnotes.blogspot.com)
    25comments
  26. Improving site performance by shipping more CSS (github.blog)
    60comments
  27. Show HN: Building a Markdown editor for Mac, iOS and web (markdown.beauty)
    39comments
  28. Allegations of US interference in Quebec election (globalnews.ca)
    9comments
  29. C's Flexible Integer Sizes Were Not a Design Mistake (pikuma.com)
    95comments
  30. Wiki Deep dive into Standard diving dress (wikipedia.org)
    1comments

Ten lines of code that changed my world

111 pointsby 7h agopixelambacht.nl
34 comments
5h agoHN ↗

I have been collecting small code snippets that would make for good tattoos and I have to say, some of these ones would probably make a good addition to the collection.

I'm partially more in favor of "red" instead of "hotpink" for CSS, but that's just me.

5h agoHN ↗

You have this one right?

(){ :|:& };:

4h agoHN ↗

Don’t forget the function name at the very beginning!

:(){ :|:& };:

4h agoHN ↗

mine would be something like

    p { color: red; }

as a teenager my mind was blown as I reloaded the page and there it was; text now in red. I did that!

5h agoHN ↗

The BASIC print+goto loop might have been my first ever program too (in the 80s) but one thing for sure for me: it was definitely not “Hello, World”. I and others filled the screen with any number of silly things, random words, jokes and juvenile phrases, whatever, but for some reason, “Hello, World!” was a C thing, and I remember seeing it for the first time in a C class in high school, and then much more often in college.

I have memories of ‘poke’ as well. On the Atari 800 you could poke memory to change the keystroke repeat rate and delay before repeat started, so obviously we would turn down the delay to zero and turn up the repeat to max (it was maybe 60 characters per second), so anyone trying to type couldn’t hit the keys quickly enough to avoid repeating. You’d have to power-cycle the machine to fix it, so it was hilarious to 11 year old me.

Similar to his description of ‘poke’, but different mechanism - using debug.com on an IBM PC jr to edit the Ultimate III save files, and give myself maximum money and lives.

Good times!

4h agoHN ↗

Most definitely the juvenile phrases.

I think my second BASIC program was the "guess a number" one -- that seemed really popular in intro basic programming things in the 80s also since it showed keyboard input and conditionals and was, uh, fun-adjacent.

4h agoHN ↗

The reason that "Hello, World" is a C thing is that C is the source of the tradition around that phrase. In Kernighan and Richie's "The C Programming Language" printing "Hello, World" is the very first exercise.

2h agoHN ↗

Interestingly enough, in the linked text, B is referred as a "language", follow by "the generated code is quite good", presumably referring to the resulting Assembly code.

2h agoHN ↗

I disagree as that doesn’t introduce using the B environment with a Hello, world program which is the whole point. After K&R it was the canonical first program.

48m agoHN ↗

Pulling my copy of K&R from the shelf, it introduces the hello world program with

  The first program to write is the same for all languages:
    Print the words   
    hello, world

Suggesting that this was already an established tradition when the book was written in 1978

4h agoHN ↗

Concur. Us hackers who got started with BASIC had a more fun and creative ethos.

3h agoHN ↗

I have been building BASIC32, a ROM BASIC like the ones I grew up with.

The first one runs on an ESP32 that I plan to use as a watch. The software works, I just need to finish the 3D printed case.

The second runs on an RP2350 connected to my living room TV via an HDMI cord.

I have so much appreciation for these old machines I grew up with.

    BASIC32
    
    Ready.
2h agoHN ↗

In C, the classic hello world example gets to demonstrate compilation and defining functions. In BASIC, `10 print "Hello, world"` does neither, so it's not a very interesting storytelling step. Hence, the introductory materials for the two end up chunked differently.

2h agoHN ↗

I started with

  10 FOR I = 1 TO 10
  20 PRINT I, SQRT(I)
  30 NEXT I

and struggled to type this without errors into computers in department stores. I must have read this code somewhere and needed to see it working for myself.

1h agoHN ↗

I remember discovering ? as a shortcut for PRINT on the C64. That was when software development as a profession really started looking like a good choice to young me.

1h agoHN ↗

In high school, my friend and I were demonstrating to Fred the magic powers of our IMSAI 8080 with ye olde:

  10 PRINT "FRED IS A GEEK"
  20 GOTO 10

To wit my friend and I would giggle and taunt.

Undaunted, Fred took a look around, found the power button, and turned the machine off. Yes, that power button next to the "DO NOT TURN OFF" sign.

As the monitor and LEDs faded to black, the giggling stopped and my friend and I stood aghast at Fred's treachery.

Fred left, and we were tasked with restarting the machine, getting to the monitor, keying in the hex code of the cassette loader, and reloading BASIC from cassette.

Got it to work on our second try!

4h agoHN ↗

My first shipped code was an art thing. C64 Basic. Poke random characters to random locations on the screen. Random colors, screen and border too. On infinite goto loop. Radio Shack (IIRC) in the local mall used it on all their C64s.

4h agoHN ↗

For debugging CSS, I prefer something along the lines of:

    * {
      outline: 1px solid hotpink !important;
      outline-offset: -1px !important;
    }

As in most cases the above snippet doesn't reflow content.

Exercise to the reader is to turn the above into a javascript bookmarklet toggle, and to add support for shading margins and padding.

3h agoHN ↗

if you're using firefox, you can generally juts ctrl-click on the page. It'll draw outlines around every child element without reflowing.

4h agoHN ↗

Here are 3 lines that capture something profound about Lisp: code can manufacture code that manufactures code:

———————

(defmacro twice (form)

  `(progn ,form ,form))

(twice (print "Reality"))

———————

twice doesn’t execute its argument twice. It rewrites the program itself before execution into:

(progn

    (print "Reality") 

    (print "Reality"))
3h agoHN ↗

Hmm. What a great question.

    while(1) { fork(); } 

Must have meant something to me, because it was in my Usenet sig. And then:

    exit(main(kfp->kargc, argv, environ));

from FreeBSD crt0; kind of a big moment for me to realize there was more C code underneath main().

Then:

    statements: /*E*/ | statement statements

The moment Yacc clicked for me; that line was profound but a more accurate depiction of the moment was realizing that all you were doing with the parser generator was building a tree, and that's what the side effects of each production were for: returning and plugging in tree nodes.

If there was a single line I could come up with for "double the size of the hash table when it fills up", that'd deserve a slot here.

Then, of course (we get to cheat because assembly):

    jmp .call
    .pop: pop esi
    ...
    .call: call .pop

The "delta offset" trick, which I believe came from x86 virus culture but was universal in 90s overflow exploits as a way to get position-independent references to strings and other memory things.

For sure:

    void walk(node *n) { if(!n) return; walk(n->left); visit(n); walk(n->right); }

I should figure out a way to fit a write-select(2) into a line because that's another "oh shit" moment for me.

Similarly: when Vern Paxson explained to me that he'd implemented TCP reassembly by simply opening up a file and using "seek" to place incoming segments in the right position. I could probably golf that down to a line! But it would be an annoying line.

3h agoHN ↗

Such a lovely article. Thanks for sharing.

3h agoHN ↗

This tiny batch script allowed for a poor man’s `touch` on Windows, which I used extensively from Windows NT to Windows 7. I typed `touch filename.txt` in the Total Commander mini-shell to quickly generate new, empty files.

This is funny to me, because I associate touch more with updating the timestamp of an existing file, and that script would miserably (destructively) be failing at that.

3h agoHN ↗

yeah i get the utility for the 'making new file' use case, but aliasing this as touch if you're used to touch for both uses scares me!

3h agoHN ↗

Another fun one for a bit of shenanigans:

  #define true ((rand()&15)!=15)
2h agoHN ↗

Cute.

Back in the day, I looked down my nose at other young fledgling developers that would #define true 1. I knew only clarity and woe lived down that road.

    if(5-2 == true) ;

As verbose as it was stupid.

I felt superior because I knew that #define false 0 was the only Boolean keyword hack that would work.

    if (5-2 != false) ;

Still verbose, and stupid, but at least it was correct.

These days… I don’t feel as confident about anything as I did about those #defines.

3h agoHN ↗

Loved the The speed-up loop section. Smart move!

2h agoHN ↗

The CSS debugger should have been:

outline: hotpink 1px solid;

not border! It destroys the layout. I mean, come on :)

2h agoHN ↗

Dead youngling, the border property is older than Firefox or Chrome. Outline become useful somewhere around 2021-2023.

1h agoHN ↗

Mine was

someObject.changeToClassOf(SomrOtherClass);

(or something like that--i'm was long ago).

In Smalltalk, changing an object's class preserves instance variable (attribute) values when possible, silently dropping if not, and gives it an SomeOtherClass's inheritance (and method dictionaries as a result).

It forced me to realize that an instance of a class wasn't permanently coupled to be an instance of the class that instantiated it or even its current class

1h agoHN ↗

Sorry this is ten SNIPPETS or BLOCKS of code. I'm counting more than 10 lines here.

... er, but also cool and inspirational :)

55m agoHN ↗

Always ran this to impress my friends

    10 for i = 0 to 359
    20 plot 100+100*cos(i), 100+100*sin(i)
    30 next i