top | item 46452146

Ask HN: How did you learn to code?

37 points| chistev | 2 months ago | reply

85 comments

order
[+] yonki|2 months ago|reply
When I was a kid, I was really into fantasy books and online text-based RPGs. I met some friends through one of those games, and they needed some changes made to their website and forum. Somehow, I ended up working on it. Then I asked my parents to get me a PHP5 book for Christmas. I think I was around 13-14 then. This was one of few programming books I've read thoroughly, although I don't remember anything from it now.

After that I started creating websites, learning HTML and JavaScript. At some point I've found Clojure and functional programming and, immediately, decided it's better than anything else, so I started to learn it. Mostly, I learned by trying to make something, looking through the internet to find help, and joining some online communities. My parents didn't care much if I was focused on school or not, as long as I was doing something, so I had a lot of time to learn by myself.

In high school programming was one of the leading subjects in my class. There I realized I'm already quite proficient at it. I was not the best in math or physics, but was easily the best in programming.

And so it goes on for about 20 years now. I still mostly learn by doing. I read some programming books, but rarely as thoroughly as my first PHP book.

[+] pentaphobe|2 months ago|reply
Was offline and had no tech people or resources around, but got access to an unused 286 which booted into a mysterious "C:\" prompt

Slowly worked out how navigate the system, then tried running the various built in things I found

One of these was QBASIC. Started reading through and messing with the example games which were part of the built-in QBASIC in MS-DOS

Reverse engineering how they worked gave a lot of the core concepts (variables, loops, procedures)

After writing a few (very) naff text adventures I stumbled across the intriguingly named "DEBUG" tool

Used debug to step through some of the other built in MSDOS utilities and try to work out what the mysterious symbols were doing (how I learnt assembler and machine code)

Later when I finally found BBSs I started debugging/disassembling some of the BBS mini-demos which were ubiquitous those days, which introduced me to manipulating graphical memory etc.. The smaller size of these, and fact that they were generally coded in assembler was much more useful than reading through compiled code

I do not recommend writing assembler in DEBUG, but wouldn't trade in the learning I got from exploring a total black box with no references or learning resources (beyond time and curiosity)

Felt like doing alchemy

[+] Breza|2 months ago|reply
Happy to see a shoutout to QBASIC in this thread. That was my first programming language, taught in 10th grade intro to programming. I loved it! I then took C++ at the local community college then AP Comp Sci in 12th grade.
[+] another_twist|2 months ago|reply
Started by reading lots of articles on Topcoder (they have a dynamic programming tutorial which imo is the best material on DP). Then did exercises from CLRS before writing a single line of code. I considered it leg work and not of very high value (remains true though, the best paying jobs in tech are research and in finance its quant trading). Then I dived head first into C++ and Java, slogged through the pain and I got absolutely hooked. I learnt almost all of the computer science I know through books, good old fashioned working through exercises, doing lectures on MIT Ocw. Never paid a single cent for any professional courses or bootcamps or any of that jazz. I did write some Python in high school but most of the work I did while at uni studying something else entirely. My initial objective was not to build anything at all but to just get better at competitive coding. But then I built something reasonably complicated and I have been an engineer ever since. I have worked in ML, distributed systems, low level systems programming in the past 10years. To answer the question I learnt coding by self study.
[+] minder-4001|2 months ago|reply
Tracking Russian satellites at school, one of the younger teachers had an account on the local university computer. He did data reduction and orbit calculations in Fortran and showed me the code, letting me try simple stuff. I found the spherical trig nasty, but the Fortan easy to understand.

Shortly after at Uni I wrote a dating system for the Rag Committee (UK thing to raise money for local charities) whilst learning other languages. Had fun with it and annoyed a few people.

Got a job with ICL and they taught me more languages and let me write some useful software as well as some outside-work fun stuff.

These days I use Python, bash and SQL, with occasional Perl. Some of the languages I used to know have completely disappeared like S3, Snowball, Pop3, 1900 assembler and so on.

[+] ipnon|2 months ago|reply
I don't feel like I ever learned how to code. The first program I wrote was in Flash, it moved a little triangle spaceship around a small frame and shot lasers. I had no idea what was going on. Later in college I wrote a lot of Python, like Django and simple algorithms. Still had no idea what was going on. After college I wrote lots of JavaScript targeting Web APIs and DOMs and strange frameworks. Still confused. We were serving on the order of 100,000,000 people a day, kind of just made it up as I went along. Now I write Elixir, and still only have a fuzzy idea of what I'm doing, but eventually it starts to work with the features and reliability I want.

I suppose all of this is to say I still feel like I'm learning! If I ever feel like I have finished the learning process it will probably be on my death bed!

[+] localhostinger|2 months ago|reply
In IT school back in 2008 (with 14). I had absolutely no idea about the school or programming, I was just knowing my way around computers, so I signed up for it. We started with C and I remember the first couple of weeks and exercises just doing stuff with printf. Then reading user input with scanf. It clicked pretty early for me, and I loved it.

From there on I was always learning faster and more at home as a hobby, I was mostly ahead in school. A friend and classmate and I coded so many different projects during that time (2D terminal game, PHP forum, PHP CMS that was actually productive for a few years, thereby also learning how the internet worked).

It's just crazy how lucky I got to be interested in this thing at the right time. "Back then" I feel you got so much more time to learn something well, mostly because things weren't changing at crazy speed.

[+] romanhn|2 months ago|reply
Fifth grade, early 90s, informatics class with Russian-built 8-bit computers (Corvettes). The "programming language" only had drawing commands (LINE, CIRCLE, etc) and the first program was the homework to draw a house. We were to write the program on a piece of paper and then type it up in class the next day. Everybody came in with your basic six-line box + roof. I had two pages of code with a 3D house, door, windows, chimney, shining sun, etc. I was hooked.

After that, a Logo-like language called Roo (with a kangaroo instead of a turtle) on school 286 PCs, then BASIC (with help from magazines) on home ZX Spectrum, and finally Turbo Pascal (with help from, well, the IDE help files) in after-school club, all during middle school. Made up my mind to become a programmer very early on.

[+] jakebasile|2 months ago|reply
I think the very first code I wrote was in QBasic, but the first _real_ code I wrote was in Visual Basic 6. I drew a row of dice and then a bunch of buttons and wrote a Yahtzee game (single player). It took me weeks and it was mostly a giant nested if statement.

Good times.

[+] crimsonnoodle58|2 months ago|reply
Same order for me. Also DOS batch files if they count.
[+] flowerbreeze|2 months ago|reply
Over a (rotary) phone with a classmate of mine, who had gotten really-really into programming, explaining how to do things in Turbo-C. Turbo-C had a great help system, so I mostly followed that and my classmate's instructions to make a tiny drawing program and a small RPG that rendered characters straight from FILE* to screen a pixel at a time.

I didn't know how arrays or linking/including worked (or that they existed), so it was one long file with each creature having its own function to determine their behaviour and their own health_creature_1, health_creature_2 and so on. I really started wondering if there was a better way after a while.

[+] BenoitP|2 months ago|reply
On the brand new and shiny 486 running dos and windows 3.1 that my father bought, on the qbasic language. With only a paper book as reference. No llm, no stackoverflow, no pageranked search engine, no internet, and not even Ctrl+F. In these days when you had a bug, you could chew on it for days.
[+] qsera|2 months ago|reply
>No llm, no stackoverflow, no pageranked search engine, no internet, and not even Ctrl+F.

Wait, MS QBasic had fantastic in built help, with examples. That is the best kind of help.

[+] conductr|2 months ago|reply
Tutorial sites circa late 90s, before blog was a term. I bought a book about HTML but quickly found it was easier to search and W3schools came online around this time. Google was new and a godsend. Had a few failed attempts with Perl and C. Then stumbled on PHP 3 and the LAMP stack and was off to the races.

Started and ran a web hosting business by 2002. All from googling solutions as they arose, I knew nothing about sysadmin. Quickly got out of it by selling it in 2003.

I continued on with PHP, then rails, python, JavaScript , etc trying to build a billion dollar idea without leaving my apartment without talking to people. I didn’t but I learned a lot. My motivation was always money, I was an entrepreneurial kid way before it was cool.

I view it as a hobby now. I feel like I know enough and can build anything I imagine (video games as exceptions). I like to build things like an inventor would. I never really learned to do the marketing and sales part right. I can do this pretty well IRL but driving traffic has never been fun for me.

[+] thatoneengineer|2 months ago|reply
TI-83, a few afterthought programs in my precalc textbook, and a bunch of bored afternoons in class. This would be back in '06 or so.
[+] nen-nomad|2 months ago|reply
In fifth grade, my father got me a C64. It came with a basic programming book, in English. I read the pages using the dictionary to translate the instructions into my mother tongue.

I made an 8-bit balloon that floated on the screen. It was magical. It is still after decades.

[+] johannahaffner|2 months ago|reply
Took a few computational science courses at university and left with basic knowledge of Python and C, and an inkling that I loved coding.

I got good at it by picking GitHub repositories I liked, making sure I understand their architecture top to bottom, as well as why specific technical choices were made. In addition to contributing features, solving issues for users really helped build a strong mental model for the code bases, and that is how I learned. All of this work was done while working towards my PhD, on evenings, weekends and during holidays.

Personally I think this approach has really worked for me! I do think that it does depend on picking great projects to contribute to, in which the quality of the code is extremely high. That is the best way to pick up good habits.

[+] efitz|2 months ago|reply
One BASIC class on a mainframe at the local community college in 7th grade. Then 5 years of teaching myself BASIC and 6502 assembly and Logo and Forth on the Apple //e that I begged my parents for. And one year of Pascal in high school.
[+] arionmiles|2 months ago|reply
By solving problems in my life.

When I was in high school, I needed to automate downloading torrents (I was downloading tons). So I plugged together a bunch of tools including:

1. QBittorrent to run a FileBot script once the file was finished downloading.

2. FileBot script was a Groovy script that renamed and rearranged the contents into proper folders and

3. A small Python script that called the Telegram API to send me a notification that the download was complete.

Then I got into college and learnt they had a web portal which showed metrics like attendance (which turned out to be important) and test scores. So I wrote a Telegram Bot that would scrape these figures and save it into a database and run some calculations such as

1. Tell me how many lectures I needed to sit through to get to a required threshold.

2. If I decided to bunk college on certain days, how much attendance I'd end up losing.

Then I opened up this bot to allow my friends to register. Near the end of the first semester, the test scores were only available on the website but there was no direct link to that page from the public portal. I had found it out playing around on it and noticed they had directory listing enabled on some endpoints which led me to those "unlinked" but functional pages.

I wrote a neat feature which would allow querying this page and send a screenshot of it via my bot. I was running this entire thing on a Raspberry Pi 3B at my home and one morning I woke up to see logs from students I didn't know trying to use the bot (and ended up crashing it haha). Word had gotten around that test scores are accessible only through my bot.

It was one of the best projects I ever worked on. At its peak, I had 300 DAUs and I would hear from my friends in other departments that their entire batch is using Telegram solely for my program. I was also able to monetize it towards the end which felt nice.

These projects served as a learning tool for a lot of stuff for me. I learnt how to manage VMs, containerization, async I/O, DB and ORM integration, how to write good docs.

I still miss it.

[+] chistev|2 months ago|reply
You would have made a bit of money from that bot if you had known! Haha
[+] stevekemp|2 months ago|reply
When I was 11 years old my parents bought a 48k ZX Spectrum for the family. These were huge in the UK, and to a lesser extent they were popular in Spain too.

The tape-recorder which was used to load programs from cassette-tape did not work, so my sisters ignored the machine and I started reading the manual, which had instructions and an introduction to BASIC.

Got hooked on BASIC, then z80 assembly, later graduated to working in intel assembly and similar low-level stuff.

These days I'm sysadmin/devops/cloud/whatever pointless title and while I program for fun, and to do terraform, etc, I'm not a coder per se.

[+] cookiengineer|2 months ago|reply
On the 6502, which a relative gifted me when I was around 9. The cool part was that they also gifted me a huge stack of boxes with C64 magazines in them that contained new games and programs the publishers found cool and wrote about. Then you could type in the code of those games and play or modify them, as a lot of them were commented codes.

The amazing part was the reader comment section in the end, where people were writing letters to the magazine publishers with their modifications to programs from one of the magazines before, so patches were literally transmitted via paper.

To me as a child, I never understood that this was programming. This was just how I could play games on the device.

Amazing memories with the C64, and I was so lucky to get one as a child because it was more common in the human generations before me. Getting a used 386 turbo as the second device was literally child's play when I was learning to write assembly for it when I discovered an assembler program on its hard drive.

[+] zvrba|2 months ago|reply
Similar story here. C64 was amazing, even to load a game, you had to learn some commands. (Unless the game was in a cartridge.)

Then I got a PC, and learned structured programming with Borland Pascal and later Turbo C. These were great IDEs for the time.

[+] sodafountan|2 months ago|reply
I was probably about 12-13 when I started learning how to code. I liked video games, and I wanted to have a creative outlet. I started building games with C# and the XNA framework. Eventually, I turned it into a career. (Doing webdev, I've never done professional game development)

That was probably about 20 years ago, I'm 32 years old now.

[+] jaboostin|2 months ago|reply
ZZT! It had its own in-game editor and scripting language ZZT-OOP, which blew my mind as a kid. That was the gateway drug to Flash and ActionScript, HTML, IRC bots, Minecraft mods, and more. Self teaching by building something fun and exciting always worked the best for me. Back when coding was for fun and not money :-)
[+] BrenBarn|2 months ago|reply
ZZT was pretty awesome. I wish I still had the games I wrote for it.