I've been reading Coders At Work, which is a collection of interviews with fifteen noteworthy programmers. One recurring question is "What was your first interesting program you ever wrote?". It's a good questions, so I thought I'd share my answer here.
My first exposure to programming was in high school; I took a class where we learned to program in BASIC. One assignment was to create a scrolling marque, where text would move from the left side of the screen to the right, and then reappear on the left in an infinite loop of textual motion. As a follow up assignment, we had to make the text "turn" downwards, and then "turn" to the right again.
But that's not the interesting part. This being my first involvement with programming, I didn't know what functions or methods were. Hell, we hadn't even gotten to subroutines yet.
Back to the program, I realized that the code for both of those turns were very similar, and decided to generalize it out. I knew that if I invested a little more work into this code, then I'd be able to turn in any direction (8 directions to be exact), and have that text snaking around the screen like nobody's business! So I wrote this generalized block of code which would make the text "turn" depending on how a few variables were set. I put this code way down in the file, like line 2,000 or something. And whenever I needed to use this code, I'd set a few appropriate variables, and then GOTO the generalized code. At the end of that code, I'd GOTO the code where I left off. I didn't realize this at the time, but I had essentially just created a function -- a block of code that takes parameters, meant for reuse.
Ironically, when I did learn about methods in C++ the following year, I had a bit of difficulty grasping the concept.