Why did we bother with line numbers at all?

oɔɯǝɹ picture oɔɯǝɹ · Feb 12, 2009 · Viewed 10.1k times · Source

When you write something in BASIC, you are required to use line numbers. Like:

10 PRINT "HOME"
20 PRINT "SWEET"
30 GOTO 10

But I wonder: who came up with the idea to use line numbers at all? It is such a nuisance, and left quite an "echo" in the developing (pun intended) world!

Answer

ypnos picture ypnos · Feb 12, 2009

The idea back then was that you could easily add code everywhere in your program by using the appropriate line number. That's why everybody uses line numbers 10, 20, 30.. so there is room left:

10 PRINT "HOME"
20 PRINT "SWEET"
30 GOTO 10
25 PRINT "HOME"

On the first interfaces BASIC was available for, there was no shiny editor, not even something like vi or emacs (or DOS edit, heh). You could only print out your program on the console and then you would add new lines or replace them, by giving the appropriate line number first. You could not navigate through the "file" (the program was kept in memory, although you could save a copy on disk) with the cursor like you are used to nowadays.

Therefore the line numbers weren't only needed as labels for the infamous GOTO, but indeed needed to tell the interpreter at what position in the program flow you are editing.