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.
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.
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.
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.
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.
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.
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.
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.
On my Spectrum I came up with:
10 GOTO 20
20 GOTO 10
It would start the Spectrum's "loading screen" border which would then scroll infinitely.
At some point I also opened it up to see what it looked like on the inside, but I managed to damage the keyboard in the process. Thereafter whenever I wanted to play a game (via joystick) I would have to use a piece of wire to manually select the rows/columns of the matching keys to enter the load command.
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.
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.
> 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.
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.
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.
In the early 2000s, when video games weren't protected against DLL injection hacks, I spent a lot of time writing DLL injectors for fun and learning.
The line I used in every experiment was:
`jmp $` (or `EB FE` in machine code)
It was the shortest infinite loop in x86 assembly, equivalent to `while 1: ;`
I would create a minimal DLL with this assembly code, inject it into games like Battlefield 1942, and observe it in OllyDbg. The injected DLL would then start on a new thread and access all the game data in memory.
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.
I had an assembler class back in the mid-90s at college. I discovered the self-modifying code trick while doing an assignment. The program had the desired output, so I turned it in. The professor, who was head of the department at the time, called me into her office.
Professor: "Your code modifies itself. You can't do that here."
Me: "It runs and prints the output the assignment outlined in its instructions. There is nothing on the assignment that says I can't do what I did."
Professor: "OK, but don't do it again."
The next class she announced that any assignment could not modify its own code. Any submissions that did so would be disqualified.
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
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.
Uhm, sorry but this is nonsense. Outline exists since CSS2 in 1998 and I was using it since the early 2000s with great success so this is a rather old trick.
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!