How was the concept of variables introduced in Fortran?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How was the concept of variables introduced in Fortran?

thedumbone
I think it was Fortran which introduced variables in real programming language. When creating the assembler for this chapter, I used python which already had variables. I used a dictionary/hash table to keep track of their location in the assembly code. I understand that all these can be done in assembly but Fortran doesn't have dictionary. Basically, I want to know how variables were implemented in the initial days. How were they implemented for the first time and how their implementation progressed over time. Once it is out of the way, I think it is just the matter of building one thing on top of the other as sir describes in subsequent chapters.
Reply | Threaded
Open this post in threaded view
|

Re: How was the concept of variables introduced in Fortran?

WBahn
Administrator
The concept of variables is pretty central to programming in general and certainly existed in programs that predate any high-level language or even assembly language. Even purely mechanical contraptions had the notion of variables. Short Code, arguably the first high-level language, has them.

As for the evolution of the implementation of variables (and just about everything else) in a programming language, that is done very incrementally.

Imagine that the world doesn't have computers but you have just implemented the Hack in hardware. To program it, you have a set of sixteen switches that you set to either zero or one to represent one instruction. You have another set of sixteen switches that you use to set a ROM address. After setting all the switches, you press a button and that programs that instruction into that ROM address. I designed an IC that had a few registers used to control some things and this is exactly how I programmed it initially.

So this, right here, gives us a path to write an assembly language program and program it into the computer -- it's just that WE have to be the assembler and convert the program into machine code.

But, for small programs, that's not a huge task. So we write the smallest program that we can that can read characters from a storage device (such as a paper tape) and perform just enough manipulation to convert them to machine code and write them out to storage (such as another paper tape). It can't do the full-up assembly language, just a subset of it. It's not going to support symbolic labels or variable names, for instance. But that's okay -- we can keep track of the numbers and put them into the code before we run the program to read and assemble the code. All we have to do is make our first hand-assembled program be able to assemble an assembly program that will be able to handle a slightly large subset of the language. Repeat this process a few times (not as many as you might think) and you will have a program that can assemble itself (i.e., feed the source code for the assembler into the program that is running a previously assembled version of that code, and it will produce a new program that is an exact copy of the program that is running).