

Ask HN: When was your "ah-ha" moment when learning how to program? - ch00ey

Non-technical business guy here, I'm currently learning PHP, I've watched screencasts (Lynda)and I'm now going through PHP 101: for absolute beginners (http://devzone.zend.com/node/view/id/627. I'm starting to understand what's going on but, still have a loooooong way to go. Regardless of that, my question to everyone at HN is:<p>How long did it take you to reach your "ah-ha" moment when you first learned how to program? And how/what did you get to that point?<p>P.S. Would love to hear some exercises you did to apply what you were learning.
======
madhouse
I've had a couple of "ah-ha" moments during my career so far. The first was
when I noticed that "hey! I can WRITE programs myself!". That was one of the
happiest weeks of my life: my father showed me how to write a very simple C+4
BASIC program, a dancing stick figure on the top-left corner of the screen. I
spent the rest of the week drawing different things and 'animating' them. That
was somewhere around 1987 or so.

For the next few years, I played around with C+4 basic, didn't do anything
serious. But in 1991, we got our first PC, and I tried to port the stuff I
wrote on the C+4 to gwbasic, and later QBasic, but didn't succeed. So I
dropped basic, and tried Turbo Pascal. That was my second ah-ha moment, when I
discovered its help.

By 1998, I was reasonably fluent in Pascal and 386 assembly, but then my
harddrive crashed, and I lost everything I wrote and collected since '91.
That's when I installed Linux, and started to poke around with Perl (we had
internet at school, and it was full of perl scripts. I choose perl because
that's what I found the most resources for), and I discovered regular
expressions: third ah-ha moment.

The fourth ah-ha moment was when I started to play with esoteric languages,
which in turn resulted in learning a couple of other, real and interesting
languages aswell. And then I realised that hey, I can program! And I don't
care what the language is, once I knew a few, I could very easily learn
another!

That moment was when it dawned on me, that programming is something much
deeper, and something much more than simply writing code in one's language of
choice.

And then I found the "Learn You a Haskell for Great Good" book, and when I
finished it, I was enlightened.

~~~
xcallemjudasx
Learn You a Haskell is excellent. It probably taught me in an hour or two what
my professor couldn't do the entire term. (He's a great professor, just not
when it comes to teaching Haskell)

It's all available online currently here:
<http://learnyouahaskell.com/chapters>

------
rajeshamara
I started programming in 1991. Initially I didn't understand any thing. Then
after couple of months every thing made sense. The only thing in programming
is practice. If you don't get 100th time you should try 101st. If you don't
get it in 1000 times try 1001 time. The only way you can get any thing in
programming is practice practice and practice. This is not rocket science
eventually you are going to get it. The only thing you require is patience.
Always start simple. Then slowly try to learn harder things. These days you
have lot of resources available online which makes it very easy for one to
learn programming

------
stevep98
When I was 12 I took the Commodore VIC-20 Programmer's reference guide to
spain on vacation (!) for 2 weeks. I figured out how to program assembly and
hand-assembled a short program to rapidly toggle the screen color from black-
to-white.

Hmm if I try real hard I can probably recreate it here: 169 0 141 15 144 169 1
141 15 144 76 0 32

Anyway, when I got home, I tried it out. It changes the screen color, but then
crashed because of a mistake in the loop instruction.

That was definitely an AHA moment - realizing how CPU's work.

------
solarmist
I had two. The first was when I was in 7th grade math and was exposed to
programming for the first time. We used basic and just did some ascii art
stuff. A christmas tree. But I added a clear screen and a goto and that made
the tree flash and kinda twinkle. Every one asked me how I did it and I showed
them (it didn't work on most of their computers, I guess the refresh rate was
juuuust right on my screen). That's what made me interested in computers.

My other was after my first year of college at University of Minnesota
(99-00). I had AP comp sci AB so I didn't need to take the first year intro CS
classes, but I hung out at the ACM a lot and someone told me about quick-sort
or I learned it in class and it was the most complex intricate piece of code
I'd ever seen. I was mesmerized by it, but everyone else just bitched about
how "crazy" it was. That's when I knew I was in the right major.

I guess a third one would be when every one I knew that was into computers
changed their major because it was too hard and I was the only one left. That
was a bit of an ah-ha moment I guess.

~~~
ysangkok
Goto considered inspiring :D

------
fogus
After a month of plodding around with C, one night I sat bolt upright in bed
and just suddenly understood pointers. I had written my fair share of BASIC
and Pascal before, but I think something in my mind turned over that night. I
can't explain it any other way.

~~~
saulrh
I know exactly how you feel; that's how I've learned most of the really cool
stuff so far. I just load the formalities into headspace, go do something
else, and have a random epiphany anywhere between two minutes and two days
later.

------
impendia
I taught myself GWBasic on an old computer, and wrote awful spaghetti code. I
actually wrote a game where every map square had twelve lines of code "Print
'....XX...X....X'" that would together print what that piece of the world map
looked like. The allowed line numbers went up to 65,535, and as I was planning
the game I planned out how I would use all of them.

Then I learned Pascal, in high school, and learned basic things like
procedures and local variables. With that, I learned that you should _never
have to do anything more than once_. Everything I subsequently learned was
basically technique for following this rule.

------
fmstephe
I don't know if it's the Aha moment you are after. But in my programming 101
class the lecturer outlined the maximum-contiguous subsequence problem (which
sounds very boring). Solved it once and then solved it two more times each
time making it more efficient. That was my 'aha' moment that I decided I
wanted to be a programmer.

I suspect that this is the most important learning moment - what is it in
programming that excites you? (probably won't be this article :)

<http://en.wikipedia.org/wiki/Maximum_subarray_problem>

~~~
ch00ey
>what is it in programming that excites you?

Not quite sure actually. I've always been fascinated with computers and the
web from a young age. And I've gotten to a point where I have (at least what
I'd like to think of as) great ideas and not being able to program is what's
been "holding me back" from executing them. So, I bit the bullet and decided
to start learning how to program.

------
tritogeneia
I learned sporadically: I fooled around in Scheme and Java when I was a kid,
and used MATLAB as a student doing research, and learned the modicum of Unix
that everybody in a math department knows, but it didn't really stick. Until
recently, when I realized that everything I care about scientifically needs a
good programmer to implement it. So I started a learning project and quickly
discovered that programming is not hard. I wish someone had told me this a
long time ago. Programming is just, in essence, writing extremely clearly.

------
LarryA
When I was learning to program in high school, I was thinking on how to do
something ...to make the computer do subroutines, and and my brother told me
about GOSUB (that hadn't been taught yet in the class), something clicked at
that point.

After that moment I started looking for ways to do what 'I' wanted the
computer to do instead of just what I was told the computer could do... and
was then happily exploring stuff beyond what the teachers knew (which was not
too much either, back then).

------
mapster
Started with VIC20 Basic programming. 4 hrs typing from a book, then 2 hrs de-
bugging, then no storage so played the sprite game until I was ready to kiss
it goodbye and power off.

De-bugging makes you think like a programmer. I can now look at code of a
language I do not know and find where the error is by 'gestalt'

Props to taking a VIC20 manual on vacation to Spain. Serious nerd street cred
:)

------
nobodyspecial
I had the Vic-20 manual - it included everything, schematics, assembly
language, etc. But for some reason I just couldn't cross the conceptual
barrier of op-codes to assembly instructions. I didn't understand. A small
assembly program in some computer magazine showed the assembly code, then the
list of POKES to load the assembly program (it was a keyboard organ): BOOM!
that was all it took...

------
mikey_p
Data structures. I could understand control flow, looping, etc, but until I
took the time to understand data structures, I was always copying example code
and trying to guess at what would work.

You can self teach yourself alot by learning as you go, but until I took the
time to specifically study data structures I hadn't made it over the hump, my
'ah-ha' moment so to speak.

~~~
ch00ey
hmmm... ok. I've been hearing a lot on how learning Data Structures (from
creeping other Ask HN questions) helps.

Can you recommend a good source on learning data structures?

------
Yhippa
This might sound silly but I get that "a-ha" moment quite a bit. It happens to
me when I do something that the big boys do like persist data to a database
using an ORM tool or implementing something as simple as an MVC app. I would
keep testing different things and emulating things you've seen in real life so
you too can continue getting that "a-ha" moment.

------
jeffool
My teacher used color combinations in Visual Studio that made things
unmistakable. After my first dream of sering code in those colors, it was just
different. It was far less daunting, and I was much more quick to get in and
start tinkering with things rather than "copy him and the book." That's when I
started understanding.

------
pstaub
It's such a gradual process that I never experienced any sort of epiphany or
"ah-ha" moment. The best way to learn it is to use it in real world scenarios;
just 3 months at a job where I had to program/figure things out taught me more
than a year of practice tutorials.

------
petervandijck
When I saved some data to a database and then printed it back on an html page.
Suddenly I could make real interactive websites, not just static web pages.

------
antirez
X=X+1

~~~
theblueadept111
X = X + 1 was my earliest 'aha' moment. At first it stumped me... there is
absolutely no value X such that X = X + 1, so how on earth can this be a valid
line of computer code? It really pissed me off.

~~~
ysangkok
And it should. The "=" is misused like this. ":=" should've become the norm...

Mathematics and programming are similar in so many regards. No reason to
confuse people like this.

------
babel17
I read this magazine called DOS, and after I bought (or, better, after my mom
bought it for me) a used 8088-PC in, like, 1990, I spent about 6 months trying
to get the programs in this magazine to run. I did this by typing them up into
a textfile, and it just didn't work. Then, one day, it worked! It was a .BAT
file. This was probably my biggest AHA moment in programming.

