Ask HN: How did you learn to code?

13 points | by chistev 3 hours ago ago

55 comments

  • placebo 4 minutes ago

    Basic on a RadioShack TRS-80. Guess I'm one of the older dinosaurs here.

  • localhostinger 35 minutes ago

    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.

  • yonki 2 hours ago

    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.

  • burnt-resistor 3 minutes ago

    By sitting in front of Turbo Pascal 6.0 and with trial-and-error, pre internet. (I was 12~13.)

  • flowerbreeze an hour ago

    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.

  • another_twist 2 hours ago

    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.

  • jutter an hour ago

    Playing in Excel one day, I added a button, then double clicked the button, and the world of Visual Basic appeared. It was like peeking behind the curtain. "Is this how they do it!?"

    I wrote some surprisingly complex interfaces for online services in Excel, without having much of a clue what I was doing. I didn't understand variables so memory was handled by reading and writing to the spreadsheet - arbitrary cells would hold values, rows were my arrays. In hindsight this very visual way of representing memory was probably helpful to my learning.

  • romanhn 2 hours ago

    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.

  • arionmiles 2 hours ago

    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 an hour ago

      You would have made a bit of money from that bot if you had known! Haha

  • jakebasile 2 hours ago

    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 hours ago

      Same order for me. Also DOS batch files if they count.

      • BrenBarn an hour ago

        Me too. QBasic and DOS batch files were the gateway drug.

  • mndgs an hour ago

    Played video games on ZX Spectrum and some Soviet computer at home. Wanted to learn to code games as a teen, took a course in Basic, very shallow. Then in high school some exposure to Turbo Pascal (90s), learned a bit, but wasn't great.

    Then really learned Python in 2010s trying to solve a real-life problem - had to scrape an ecom website, used Scrapy. Now it's Go, quite complex projects, about to launch our SaaS startup.. took a while..

  • thatoneengineer 2 hours ago

    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 an hour ago

    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 hours ago

    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.

  • cookiengineer 2 hours ago

    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 hours ago

      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.

  • jaboostin 2 hours ago

    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 an hour ago

      ZZT was pretty awesome. I wish I still had the games I wrote for it.

  • efitz 2 hours ago

    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.

  • ChristopherDrum an hour ago

    Applescript; first trying to automate mundane work tasks, then later to build simple GUI apps. That led into more robust Applescript Studio work, which led into learning Objective-C through Big Nerd Ranch and the book/class by Aaron Hillegass. That was all pre-iPhone. When the iPhone released, suddenly my Objective-C hobby skills were in hot demand. And that's how I became the mediocre developer iOS engineer I am today.

  • BenoitP 2 hours ago

    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 hours ago

      >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.

  • chistev 25 minutes ago

    Interesting that nobody yet has mentioned Bucky Roberts from The New Boston.

  • stevekemp 2 hours ago

    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.

  • medwards666 an hour ago

    Copying listings from computer magazines into a ZX81 ... could never get the damn tape drive to save anything that would then reload (either a cheap tape deck, or cheap tapes)... so had no choice but to hand-code.

    Also, didn't have the cash to go buy games from the local computer store so this was the next best thing...

  • onion2k 2 hours ago

    My father was a software engineer (working on satellite control systems ... very cool stuff) and he bought a ZX Spectrum in the mid 80s when I was about 8. That gave me access to Basic and I picked up the fundamentals from there. I didn't love it until university and using the Internet for the first time though. There's something about writing code that people can access from anywhere in the world that I find really exciting.

    Considering I've spent 40 years coding things I really should be better at it.

  • hivacruz 2 hours ago

    I “learned” to code in Visual Basic 6 to create programs mainly for AOL chat rooms (games, etc.) when I was a kid. I was more of a script kiddie than anything else, but I got hooked pretty quickly. Good times!

  • w4rh4wk5 2 hours ago

    My first coding experience was through the StarCraft 1 map editor. It offered a text-snippet-based scripting system to build rudimentary logic. It was relatively easy to pick up thanks to its documentation and localization.

    After that, I played around with HTML/CSS which led me to building things in PHP as this was the go to language for implementing logic on the web.

  • gentooflux 2 hours ago

    Practical Common Lisp by Peter Seibel, and then The C Book by Mike Banahan, Declan Brady and Mark Doran. No clue why those books in that order, but they both proved to be decent choices.

    Then I had a couple of jobs where I was given access to data and opportunities to go beyond my expected duties by doing things with that data, i.e. automation and reporting.

  • geuis an hour ago

    BASIC on an Apple II back in elementary school. That was at least my first exposure.

    A few years later, it wasn't exactly programming but I was able to learn a bit about assembly on Macs in the 90s with ResEdit.

  • bobowzki 2 hours ago

    My father had a an old HP Vectra 286. Somehow I found the 5.25 floppies with QBasic 4.5 and the manuals and just started experimenting with it. I must have been around 11-12 years old. When I was 14 and doing work experience in system administrator I got a Free sad CD. That started my Unix journey.

  • owisd 2 hours ago

    qbasic mainly using previous generation books eg https://usborne.com/gb/books/computer-and-coding-books

    Personally find p5js/The Coding Train is the closest thing around to a modern equivalent.

  • kopollo 2 hours ago

    There used to be a website called Planet SourceCode where everyone uploaded their own code. I would download the zip files from there and build clone programs by watching how everyone else did it. Mostly programs for Windows XP, Visual Basic and Delphi clones.

    • kopollo 2 hours ago

      I started my web development with PHP back when there was a free 110MB hosting planner. Running websites there was a lot of fun. These days I still host websites using PHP, but the APIs are usually handled by Rust Node.js in the background. Of course, this depends on the user base. Smaller projects still use pure PHP PostgreSQL.

  • hxugufjfjf 2 hours ago

    Never really learned it. Still struggling.

    • chistev 2 hours ago

      I bet you're better at it than you were before.

  • electroglyph 2 hours ago

    i started with x86 intel asm. i just derped around with ollydbg a lot while i referenced the intel instruction set pdf that i had.

    after i was able to do basic patches i learned C# (then 1.0) so that i could load and patch processes in Windows. my patches were relocatable and assembled in the hackiest way, heh. why didn't i do C or C++ like a sane person? dunno, but that's how i started =)

  • thomasfromcdnjs 2 hours ago

    neopets was definitely a factor, who else? And "hacking" school computers, windows use to let you make folder backgrounds with html, could do some funny stuff.

    • BrenBarn an hour ago

      I used to go into Staples or Circuit City and go to the demo computers. I'd hit the reset button, boot into DOS, open up QBasic, and write a classic program along the lines of 10 PRINT "BRENBARN RULEZ!" 20 GOTO 10. Add a little spacing offset so it would create a wave-like pattern of text. Set it running and skedaddle.

  • roamerz 2 hours ago

    Using an 8051 on a breadboard writing ASM in a text editor and debugged with a tektronix storage oscilloscope. It was super fun.

  • Buttons840 2 hours ago

    By endlessly asking #python on freenode how to do basic things like utilize a dictionary.

  • bibimsz 2 hours ago

    experimenting at home with qbasic + college

    • bibimsz 2 hours ago

      anyone else bootleg quickbasic 4.5 so you could compile to executable?

  • hbogert an hour ago

    Brother's minor included making webpages. Pure html. That led to listings in a computer magazine for making a guestbook in php more comprehensible. That was in 2001. That was enough to get me hooked. Continued with the java bible and by then there was no doubt, going to do CS in uni. I hated it with a passion. And only 10+ years after graduating I understand the value of it

  • stackghost an hour ago

    Writing emulators for Ultima Online servers. Sphere Script, then POLscript which was a weird Delphi thing, then C#.

    Plus C++ in first year "programming for engineers" and assembly in 4th year robotics

  • sodafountan 2 hours ago

    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.

  • delusional 2 hours ago

    I wanted to cheat in video games. To cheat in video games. For the first couple of years I was content using the offsets published by others, but eventually I wanted to reverse the games myself. That's where people told me that the best way go get good at reverse engineering was to get good at programming.

    That set the train moving.

    • electroglyph 2 hours ago

      yep! reversing Ultima Online clients started it all for me

  • BrenBarn an hour ago

    I played computer games as a kid and got interested in computers. I looked at books from the library on how to make games. This was in the 90s and many of the library books were from the 70s or early 80s. Many of them focused on computers like the TRS-80 that I had never heard of. Eventually at the library I found the David Ahl books ("BASIC Computer Games" and "More BASIC Computer Games"), and discovered that I had QBasic available in DOS. I started typing in the listings and playing the games. Pursuing this interest led me to get a fat book called "Using BASIC" that focused on QBasic.

    I started learning to modify the games I was inputting, and then to write my own simple games. Somewhere in there I also was learning to write DOS batch files to do simple tasks. I wrote a DOS menu system that let you choose which program you wanted to run, to make it easy for me or my siblings to run any of various games, plus "serious" programs like WordPerfect. My dad got me a subscription to Dr. Dobb's Journal and a magazine called DOS World. They had program listings in assembly that I also typed in and tried to modify, just doing super simple stuff like playing the Twilight Zone theme song on the PC Speaker. A bit later I got into text adventures and wrote a few of those using special-purpose languages. I also wrote some games in ZZT. (And oh yeah, another comment on here reminded me I wrote some silly "games" in the variant of basic on my TI calculator, stuff like a Mad Libs generator.)

    At some point in high school I started using Python. I think it was Python 2.1. By that point the internet had gotten to the point where I could learn a lot by searching for stuff, and so then I kind of shifted into using web tutorials and newsgroups and forums and stuff, which continued until today. Along the way I played around with a few other languages, like Haskell, and got reasonably conversant with JavaScript, but Python remains "the" language for me.

    So I was self-taught, at first relying on books and later on whatever I could scrounge from the internet. I've never taken an actual class in programming or computer science.

    Games were a major factor in my early programming development, the other main line being small DOS utilities. The David Ahl books were foundational for me, and I really hope people starting out today can find something like that, something that makes them go "Wow, look at all the things that I can actually do just by taking this code that I don't understand and learning how to mess with it." The "Using BASIC" book was similarly key in that it got me to understand how a programming language had a syntax, data types, and so on. Even when I moved away from BASIC, I pretty easily understood how when I was reading a tutorial on Haskell or Python, it was in some sense telling me the same stuff that that book was telling me, although the languages were quite different.

    Since then I've taught programming a few times and I'm very informed by that early experience, basically the idea that learning to program involves just jumping in and wrestling with stuff, exploring and experimenting.

  • ipnon 2 hours ago

    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!