

Ask HN: How do you start programming? - whackedspinach

I'm a high school senior who wants to get into programming.  Unfortunately, my school offers no computer related classes at all. So, I want to teach myself. Usually whenever someone asks how to start programming, they are looking for a language to start with. I've realized that is a trivial question, and it just spawns those pesky flame wars. What I am looking fo are examples and ideas to gain experience. I've played around at Project Euler a bit, but I doubt that most programmers worry about the number of prime numbers under 1 million in their everyday jobs. How did you get started in programming and what did you use to gain experience?
======
manvsmachine
Video games. Seriously. Here's why:

1) _Hardware knowledge._ I didn't start programming until I started college,
but I quickly realized that, growing up as a pretty avid gamer, I still had
one advantage that a lot of the CS majors didn't have: I knew more _about
computers_ than they did. Games are some of the most demanding applications
being created today, and, as a result, I had spent a lot of time reading
hardware reviews and benchmarks. This resulted in my having a somewhat innate
understanding of how data is passed around inside a computer and how this
affects performance. It takes time to understand on a deep level how your code
is interacting with the hardware, but when you see the frame rate tank because
you used an inefficient algorithm somewhere, it sticks with you instantly.[1]

2) _Instant gratification_. Much like web programming, game programming allows
you to see the result of your work, immediately and incrementally. And it
looks good, because you get to use professionally developed resources (models,
textures, etc). A side benefit is having _good looking_ programs to put in
your portfolio.

3) _Wide variety of problem domains._ Once you get familiar with programming
in general, you can then work on pretty much anything you want: 3D graphics,
physics simulation, AI, networking, UI / UX , HCI, etc.

4) _It's fun._

Try giving Unity a shot and see how you like it:
<http://unity3d.com/unity/download/> . It's multiplatform and has API's in C#,
JavaScript, and Python, so you have an element of choice. If you're a Windows
user, I know a few people who started out by playing around with XNA, which
uses C#. Examples of free commercial game SDK's are Epic's Unreal Development
Kit (<http://www.udk.com/>) and Valve's Source Engine SDK, which comes free
with any Source Engine-based game.

[1] When working on a graphics project, I accidentally put the function that
imports and initializes the texture resources into the draw loop, which meant
that new memory was being allocated for them 60+ times per second. Needless to
say, I became very aware of the problem when my fans started to spin up like
jet engines.

------
mansilla
Oh, nostalgia. I started coding out of curiosity back when I was in 4th grade
(back in 1983). It was a helluva lot less main stream than it is today, so
some of the things that I wanted to code back then mostly had to do with
whatever I was into at the time.

So, in your case, you sound completely not familiar with programming at all.
That's an awesome place to be, believe it or not. You sound like you're into
mathematics, so think about hacking something trivial in a field that you're
passionate about.

My first thing I programmed was a BBS (bulletin board system) on the Apple IIe
computer. Called it Warphactor. Fell in love with the fact that I could make
my computer's modem ANSWER a phone call, send and receive data. Just kept on
building from there.

I code in a bunch of different languages (for recreation and profession) not
because I'm some genius, but for two reasons. First, different types of
projects demand different languages or platforms. Second, once you've been
programming for a while, you realize that there's a LOT of crossover between
languages. So don't get too hung up on one language, because once you start
doing this stuff in the real world, you'll be pretty flexible and able to pick
up new languages without much effort.

Don't run out and buy a bunch of books. You'll find plenty of resources online
to learn concepts, and my favorite, BY EXAMPLE. Don't be afraid to ask
questions. Most importantly, if you feel like there are concepts that you just
can't wrap your head around -- POWER THROUGH until you understand them.

There's always someone out there that has explained it better than the
resource you currently have in hand.

One neat resource that, in my opinion, stands above its contemporaries, is
stackoverflow.com. Stuck? Compose a well written question, get some very well
written answers.

Good luck!

~~~
whackedspinach
Thanks. I have noticed that any time I have a question related to programming,
there is almost always an answer on stackoverflow.com.

------
sz
Story:

I started out playing around with a TI-84 in middle school. Saved myself a lot
of annoyance by making it do my homework, saved myself from insanity by
programming games in class instead of paying attention. I never got into the
ASM stuff, since I didn't have a computer then, but I was at least pushing the
limits of what was possible without it. (Wrote a 3D engine in TI-BASIC at one
point - intolerably slow but it worked :P)

Then in high school I got a summer internship at a startup with a chemical
research lab. I didn't know this going in, but my job ended up essentially
being to sit at a desk the entire day and manually type column after column of
data into Excel. That pissed me off, so I started messing around with .bat
files, trying to automate as much of it as I could (still didn't know how to
program anything but a calculator at this point). My boss—apparently an ex
kernel hacker—saw this, decided I was wasting my time, gave me a Ruby book,
and instead set me loose on a project to revamp their data infrastructure.
That was my first exposure to "real" programming, and so far I still consider
it the best time of my life.

To summarize, what got me into programming was: (1) trying to automate
mundane, repetitive tasks; and (2) just playing around to see how much you can
do with a piece of technology.

I would recommend this: look around and imagine what you would want to do if
you knew how to program, then try to do it, using books as a reference. From
there, follow your natural curiosity.

------
Macha
I started to learn how to program while I was 13. The language I started with
was Java. My first real program I tried to make was a Simcity clone in Java.

I failed, but even in failure, I learned a lot. The important thing is once
you have learned the basics of a language, try and build stuff yourself. You
won't learn much by copy/pasting or slightly modifying or retyping examples.

One thing to look out for is a project you can do to start. If you are doing a
web language, code a basic blog once you've done the basics to put together
what you've learnt.

Another common starter project nowadays is a Twitter client. This used to be a
good idea, but it's gotten a bit harder now, and I wouldn't recommend trying
to figure out OAuth for your first program.

Another important point is learning different languages. Don't go "I've
learned Ruby" then stop. Despite it being my first language, I hardly ever use
Java anymore. Different languages lend themselves to different problems, and
knowing more languages helps you look at programming problems from a wider
perspective. I strongly suggest that you try at least one static language, one
dynamically typed language, and one functional language at some point.

A final point is that it can be quite helpful to read blogs o.n programming. I
can't suggest any ATM, because the two I always read are more or less at an
end.

~~~
whackedspinach
A Twitter client is interesting. I might just try that. I haven't really
settled on any language. I have books on Python and Ruby, and I've recently
become interested in Haskell. But it seems like you can do almost anything
with any language (maybe not efficiently). I figure I'll learn the mindset of
programming, and then concentrate on different languages.

~~~
jamaicahest
Throw in C++, C# or Java and you've got all three archtypes covered. Some
people still fancy plain C, though I haven't used it for years, it will give
you some historical perspective, as it is the granddaddy of many languages
today.

------
alttab
I learned on the TI-83. You learn skill-sets in chunks. First it was menus.
Then holy-shit, variables. Things kinda just go from there.

You never as much learn programming as you "absorb" it. This includes things
like syntax, approach, mind-set, etc. This goes for every language, especially
if the idioms are different.

Come up with a cool project with small scope and a discernible "end goal," and
do whatever it takes to get there. You'll learn more along the way than you
expected to. I learned more about call-stacks, memory management, and pointers
in front of MS VC++6 compiler and runtime errors than I ever thought I would
when "making a game."

Its like learning any other language or math. Learn and understand and atom,
and use that to understand another. Its definitely cumulative and you can't
learn it "front-to-back" as much as it is in "bits and pieces."

Good luck!

(If its any help - this is the order I learned things in. Not documenting my
age or how long I spent learning it as it spans more than a decade)

HTML

TI-Basic (TI-83)

Visual Basic

C++

CSS (finally stopped using homesite)

Java

Python

C

PHP

ActionScript

Ruby

Javascript

------
samratjp
A practical/immediate suggestion: Forget about reading books and try the
following for now.

Don't worry about the language wars. First learn to have fun. Have a go at
<http://www.tryruby.org> \- it teaches you to code in Ruby in 15 minutes'ish
online. You can type stuff in and try it out immediately. If you like the test
drive, then download Ruby and have a go at it.

If you liked that, checkout Google's python class - it has great examples,
lectures, and even sample assignments.
<http://code.google.com/edu/languages/google-python-class/>

They're both competing languages (or so the flame wars make it out to be :)
and give you a nice introduction to programming super fast!

------
teddytruong7
I am a lot like the poster. In fact, HackerNews is one of my homepages and I
am reading this post as I read "Head-First Java".. Haha what a good
coincidence. I'm hoping if anyone can lend out some guidance on what blogs we
should start following and what websites that are out there to help us get
started. So far, I'm enjoying this book. But of course, I'm not going to spent
$45 on it.. The internet is free :D

Thanks for this post! Looking forward to more comments

------
igrekel
The good thing about things like project Euler is that it makes you practice
solving problems that are easily constrained. I would say most of the real
problems you'll encounter day to day are often much simpler but are far more
verbose. That makes them good exercises to learn. They are also fun.

------
pbewig
programming Praxis (<http://programmingpraxis.com>) offers a series of
exercises, similar to Project Euler, but with more emphasis on programming and
less emphasis on mathematics. There are new exercises every Tuesday and
Friday.

