Ask HN: How did you learn to program?

10 points by nunsi ↗ HN
So currently i'm interested in learning how to program and what resources are the best for a beginner. Some info : 23 years old, doing tech support for hosting company mainly having customers using *nix.

How did you learn to program and what resources did you use ?

12 comments

[ 2.8 ms ] story [ 31.3 ms ] thread
I taught myself when I was about 14. I ended up programming in response to being given an old laptop that was too resource constrained for the latest Windows OS. All I wanted to do was browse the internet and listen to music locally. This lead me down. The road of discovering linux and eventually writing a CLI music player in Python. I didn't do any serious programming for years after that.

Later on I was struggling through college, switching majors every semester and was running out of time to pick a career. I had no partcuarly strong interest, but I knew I wanted a challenge, so I went into a computer related degree. I am now happily employed 5 years into a career in SWE.

To summarize I taught myself to program through whatever resources I had available to me in response to problems that programming could solve. The internet is vast, if you want to learn you will. Don't just rely on the information, reach out to the people for advice, ie find mini-mentors.

I started learning by using a wysiwyg html editor that would let me view the source code. That gave me a clue to how things worked.

After that I started editing perl cgi scripts. Then I started making my own web apps with perl.

Then I started using CSS with HTML and then Javascript to write my app code.

But... if I were to start now I would buy a Raspberry Pi computer (or two or three) and start taking advantage of all the resources available to learn using it because most of what you'll learn can be used across platforms and the resources are amazing.

https://www.raspberrypi.org

At first, by typing in BASIC code listings from magazines, when I was 12. Then, by writing several hundred small programs that were either graphics "demos" or simple games. Then simple 3D renderers, and then complex 3D renderers. In those days, there was no web, and only a few programming books at the library or bookstore. So I learned almost completely by trial and error. Later, I experienced a lot of growth in my first job, mostly from reading my boss's code. By that time, the web existed, and it was off to the races.
I learned mostly in college. I already had a decent understanding of computers at that point from playing games and messing around with them.

You don't need to go to college to learn how to program though. Programming is just feeding a computer instructions. Since you are working with customers on *nix, that is a place to start. Start small with things like looping over a directory of files and outputting the name. This could be done in Bash. You could pick nearly any programming language and it will have File/IO libraries that allow you to traverse a directory. Sure you could just use "ls -l" on a command line and you should to compare your results. Start small, learn different ways to loop over things. Read docs.

Its much easier to learn when you have some knowledge of the context you are learning in. Tech Support leads somewhat naturally into more of System Administration, which can have a fair amount of programming, mostly for automating things.

I started in the 80s. I wanted to write computer games as I didn't have many at that time. Started with BASIC and moved to Assembler.
I got started around the similar time, first with BASIC then with Z80 assembly language.

My earliest motivation wasn't to write games, it was to hack games instead, for infinite lives, etc!

Elementary school math textbooks in the 80s and 90s (do they still?) had BASIC source listings at the end of sections and chapters. I typed that out into our Tandy 1000 which had some kind of BASIC on it (at the time I just knew it was BASIC and didn't know there were different kinds so which one is lost to me).

For people today, if they're going to be more self-taught than going to school for programming, I often recommend Python. It's very straightforward, usually does what you expect, and the documentation on the main site is fantastic.

Use it to scratch your own itches and python is on nearly every OS outside Windows by default.

If you're interested in web stuffs learn Javascript. I'm not a fan of it, I have my reasons, but it is available on every computer today and has a huge ecosystem of libraries for you to use.

My first exposure to computers was in elementary school. We had a couple Apple II computers which had Logo installed on them. We had fun typing in commands to draw Spirograph looking images on the screen.

My parents got me a Commodore 64 when it first came out. I had a tape deck to save stuff onto. When you turned on the machine you were at a BASIC prompt. It came with a manual that had some simple programs in it. One of the programs drew a piano keyboard on the screen and mapped keys to keyboard keys to let you play. I remember going through the code and changing values just to see what it did. That kind of got me started on programming.

We subscribed to a few magazines (Family Computing, BYTE, etc) that would have program listings in them, which I would sit down and type in. I would then go through the same process. What happens if I change this peek or poke command? What is GOSUB doing? What are all these numbers in the DATA section?

I got to the point where I could write my own programs, including a couple simple games using sprites and joystick controls.

I enjoyed it enough that I'm still a developer now at the age of 46 and plan on doing it for as long as I can.

A lot of people are talking about having learned early in childhood. Don't let that discourage you - it's not at all too late to learn in your 20s.

My suggestion would be to examine what you know about yourself. How do you personally learn best? Is it in a formal classroom setting? Is it by watching videos? Reading books? By picking up a project you want to accomplish and then progressively figuring out what you need to know to finish it?

That can help you determine whether to self-teach, join a bootcamp or MOOC, etc, and what type of resources to look for.

Me: Started taking computer science courses but I struggled a lot. My thoughts at the end of my graduation was there's just not enough time to cram in all the information and skills they asked out of me but luckily, I graduated. If I could turn back the clock, I'd just Google for resources myself to learn programming, databases, and all and have chosen a different major to do instead.

Advice: Start with a high level programming language like Python or Ruby. Google to your heart's content.

I am learning Python by writing codes on a piece of paper, and then practicing in a text editor. Writing on a paper makes learning easier to committing concepts to brain.
Start by automating your tasks. First, you'll get more efficient and less error-prone in your work. Second, you'll reuse your code across tasks and you'll learn when it's a good time to refactor and generalize vs copy & paste. Third, you'll see how many times your programs misbehave, and you'll learn about fixing errors and writing tests.

Everything can be learned in a course or on a book, but creating something that you really need and care about is the easiest way to get exposed to the details that matter.

As for the question, I learned programming in Pascal at 12 so way over 20y ago. At the time I was playing a lot of role-play games and I wanted to automate "battles": rolling dies, looking up tables related to the damage inflicted, etc. I didn't have Internet, I learned from help and a manual.