How I learned to program in two months in my mind

Valeri Rakitine
6 min readSep 4, 2022

When I, about 50 years ago, as a schoolboy, watched the movie “Chess Story” (now it is on Youtube) ::

https://en.wikipedia.org/wiki/The_Royal_Game

how could I have thought that something similar would happen to me in my first year of the institute .. No, I did not sit in prison as the hero of a film, but by my own inattention and misunderstanding how the BASIC programming language works, in which I had to write a course project, I drove myself crazy as the hero of a film that was playing chess in my mind uncontrollably with myself, and I could not stop writing in my mind a program for a course project.

Is this funny? Believe me, it’s not funny.

Only alcohol helped temporarily shut off and sleep. I solved this problem and calmed down, but as an addict, until the next task. Over time, I learned to deal with this by pushing the process of writing a program into the background. It’s like walking, when the cerebellum is responsible for motor skills, while you chat with your companion or compose poems on the go.

And so, more to the point. The circumstances and the scene, so to speak. Moscow, 1975, Moscow Engineering Physics Institute, first year, they began to teach us the first BASIC programming language in our life, or rather one of its variants, implemented at our department on an M-6000 machine with only 16 Kb of RAM and all this in a time-sharing mode ( times sharing) about 8 teletypes were connected. Teletypes were in a separate room, which they would now call a display class.

The teacher gave us lectures about the programming language and taught, on simple tasks, the basics of how to write algorithms and everything connected with it. Oh god, no internet or textbooks. The Americans invented the BASIC language 10 years before and created a similar “display class” on more powerful machines with hundreds of teletypes remotely connected. Of course, I did not know anything about this and did not suspect that programming was taught at that time in no more than ten universities of the USSR, and perhaps there were none like our class at all.

While preparing the article, it was very difficult to find on the Internet a working version of the BASIC language, as close as possible to the ancient one in which I wrote a term paper and almost went crazy. Here http://www.vintage-basic.net/ I found both a description of the language and sources and how to install everything on Windows 10. Thanks to the people who made this tutorial, they saved me and my time. This is how to find wine older than 50 years and sip it. Be sure to contact them and thank them.

I was impressed that the whole description of the language fit on two or three pages, but believe me, this is enough to let the roof go:

http://www.vintage-basic.net/downloads/Vintage_BASIC_Users_Guide.html

Do not believe what works? He was surprised, tensed, invented a task, wrote a code.

This is how the implementation of the array sorting algorithm in descending order by the “bubble method” looks in BASIC language

10 DIM A(20)
20 LET A(1) = 99
30 LET A(2) = 77
40 LET A(3) = 55
50 LET A(4) = 44
60 LET A(5) = 33
70 LET A(6) = 22
80 PRINT “Start”
100 LET M = 6
110 FOR I = 1 TO M
120 PRINT A(I);
130 NEXT I
135 LET C% = 0
137 LET T = 0
140 FOR I = 1 TO M-1
150 IF A(I) < A(I+1) THEN 200
160 LET T = A(I)
170 LET A(I) = A(I+1)
180 LET A(I+1) = T
190 LET C% = 1
200 NEXT I
205 PRINT
210 PRINT “ — “
220 FOR I = 1 TO M
230 PRINT A(I);
240 NEXT I
250 IF C% = 1 THEN 135
260 PRINT
270 PRINT “End”
900 END

It works! But I last wrote on this fossilized version of the BASIC language more than forty years ago.

So you think: where can it be stuck and what was wrong should be understood from the lectures of the teacher? so that, then, for two months to focus on the coursework, in which it was only necessary to write a program to sort the array of numbers in ascending order of multiplicity.

At the entrance:

89, 5, 23, 5, 14, 8, 5, 23,

output

89, 14, 8, 23, 23, 5, 5, 5

You never guess, and I myself would never have thought of it. Jammed and this is a gift of fate. For all the difficulties that do not kill us strengthen us.

What went wrong? Let’s look at a simple example:

10 PRINT “Start”
20 GOTO 100
25 REM
30 PRINT “Two — 2”
40 GOTO 200
50 REM
60 REM
70 REM
100 PRINT “One — 1”
110 GOTO 30
200 PRINT “End”

A simple program and the output we have:

Start

One — 1

Two — 2

End

Let’s see how control is transferred in the program

I thought that it was impossible to transfer control in a program like that. You see, the red circle is a mistake. Control transmission lines intersect.

Of course, this is not a mistake, but I got over and it became a mistake.

My coursework code, with such a restriction, became a hundred times more complicated, if not more.

Try to write a program for my coursework without such red circles, and then you will understand how lucky I am in life. I have the opportunity to rewrite the code a hundred times. Instead of one coursework, I did a hundred coursework, bringing my brain to a state of uncontrolled generation. I learned to draw algorithms and write code in my mind. At first, like everyone else, he wrote code on paper, drew control transmission lines. As soon as he rested that it was impossible to continue without crossing, he stepped back and slowly moved to the goal. A month later, I already saw a few steps forward, and paper with a pen was not always at hand. I remember when, after passing the coursework, it dawned on me that there were no such restrictions. I even felt sad because in a few minutes I figured out several versions of my coursework code in my mind and told myself — it’s not interesting !

Just like in a joke — A vet comes to the doctor. The doctor asks — What are you complaining about? And the vet is responsible. How not interesting !. This I myself can treat.

That’s, like, that’s all. Go ahead.

There is one indulgence — the program can be started from any line.

Just put 10 GOTO 300 first, the line number with which you want to start the program.

I am sure that you will still have questions. I will answer them with pleasure.

Finally, I would like to thank my grandson Eric for his help in translating the article into English. I think he has no idea that I wrote this for him and for all the guys who are just starting to learn to program.

--

--