By using pen and paper. I use to write all programs on paper, debug it by hand on paper. Then whenever I was confident that the programs I wrote will run without errors, I use to go to a person's house who had a computer, pay him for 1hr access and run my programs. My parents could not afford to pay everyday, so every 1 or 2 week, I use to collect all my written programs and go type them as quickly as possible and try to compile and run them.
Had a 2nd hand Commodore 64 as a kid and copied small BASIC programs from a worn copy of the Programmer's Reference Guide, filling in pieces from a few partially torn pages. But I wouldn't say that taught me programming. Didn't have a PC until I was 16. No internet until 17. Last couple years of highschool, I made a few trivial web pages with PHP, and I wouldn't say I knew anything about coding then either. Nor would I say I really learned programming while completing my CS degree. I felt like I had learned to program while being unemployed for a few years after graduating, and I didn't feel like I was any good I until after my first few jobs. Now, having held a senior engineer title for some time, looking to move on to a principal role, I realize I never really knew anything.
My family did have a PC when I was a kid in the 90s, but I didn't program on it at all (and IIRC wasn't even aware of what programming was). Mostly fooled around in MS-Paint and played games. I did a tiny amount of programming in later high-school classes and then a lot in university.