Ask HN: What is your first piece of code?

4 points by kalerzee ↗ HN
My first piece of code is printing triangle on screen.

13 comments

[ 10.3 ms ] story [ 39.3 ms ] thread
Making a sprite of a balloon move across the screen of my Commodore 64 in BASIC (the code came in the manual with the machine).
A jumping man, in C+4 BASIC: clear screen, draw an ASCII stick figure, for loop to wait, clear screen, draw stick figure in different position, for loop to wait, goto 10.

I still know it by heart, though it was written more than two decades ago.

It was some form of:

  10 PRINT HELLO
  20 GOTO 10
on an Apple ][ GS when I was ~6 years old.
Something similar on a Commodore PET at school. Aged 11ish.
Same, on a TRS-80 when I was about 14.
Same, on an MSX when I was 8 :P
Ditto, except mine was in QBasic on a DOS box.
INT 20H

Got me started on programming way back in the mid 80s. Once I knew how to make a program exit, I was more confident of writing more code

On the ZX Spectrum:

10 PRINT <something>; 20 GOTO 10

I was hooked from that point on. Brings back memories.

Maybe not the first, but I remember typing the line

## REM TYPE "IS A FLASHY PERSON" IN INVERSE VIDEO

from a listing in the little manual that came with my Atari 800XL, before I new what REM meant.

A "password" program in basic that sat in a loop checking input unless you typed in a hardcoded string. Not exactly production quality.