Ten Lines of Code That Changed My World

(pixelambacht.nl)

48 points | by dimonomid 3 hours ago

6 comments

  • dahart 1 hour ago
    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!

    • andsoitis 2 minutes ago
      Concur. Us hackers who got started with BASIC had a more fun and creative ethos.
    • mcherm 15 minutes ago
      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.
    • dgacmu 17 minutes ago
      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.

  • andsoitis 5 minutes ago
    Here are 4 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"))

  • throw34889 7 minutes ago
    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.

  • probably_wrong 1 hour ago
    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.

    • apsurd 22 minutes ago
      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!
    • thenthenthen 1 hour ago
      You have this one right?

      (){ :|:& };:

      • mattrighetti 51 minutes ago
        Don’t forget the function name at the very beginning!

        :(){ :|:& };:

  • analog8374 10 minutes ago
    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.
  • irregularbowels 1 hour ago
    [dead]