Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did we bother with line numbers at all? [closed]

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!

like image 789
oɔɯǝɹ Avatar asked Feb 12 '09 14:02

oɔɯǝɹ


People also ask

Why did basic use line numbers?

The purpose of line numbers was for branching and for reference by formatting statements. Both JOSS and BASIC made line numbers a required element of syntax.

Why are some line numbers missing in Word?

To use line numbers in Word, you must be in Print Layout view. Go to the View tab and click Print Layout in the Views section of the ribbon. Next, insert the numbers by heading to the Layout tab. Click the Line Numbers button in the Page Setup section of the ribbon.


2 Answers

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.

like image 164
ypnos Avatar answered Sep 29 '22 13:09

ypnos


It has a loong-loong history.

Line numbering actually comes from Dartmouth BASIC, which was the original version of the BASIC programming language and was the integral part of a so called Dartmouth Time Sharing System. That DTSS had a rudimentary IDE, which was nothing more than an interactive command line.

So every line typed inside this "IDE", and beginning with a line number, was added to the program, replacing any previously stored line with the same number; anything else was assumed to be a DTSS command and immediately executed.

like image 21
Anton Gogolev Avatar answered Sep 29 '22 11:09

Anton Gogolev