Music & Programming
Part from the book of V.Ochkov «128 advices for Beginners in Programming»

(anther books and articles of V.Ochkov)

Likely it is not possible to make someone work on computers such as IBM-360 etc., Ural or Mir (Russian old computer) only reading this line. But it is necessary to speak about lamp, relay or pneumatic computers. The modern personal computers work almost silently besides all other differs from above named ones. Only easy hum (buzz, drone; humming, buzzing, droning) of the fan and of the clock of the hard disk swinging the information from a magnetic disk in the RAM, pleases to the programmer or afflicts it, informing, that all is good or something is not.

The noise of old machines was sated. The programmers were given to known by the character of buzzing the computer what stage there is a computing process. Or if they  "have come in the enclosed cycle! ", It is too silent, is not it? The square root calculates! " – they say either for fun, or seriously, playing naive, ingenuous program for visitors of computer center. But one could be defined if the machine is serviceable or not only hearing a condition of working the machine. And it was possible to define rather precisely.

It is known, that the art of programming does not consist in skill to write the programs, but to find mistakes in them. Some programmers have special working on such specific mistake, as Eternal cycle of the programs. Working in environment BASIC (fantastic BASIC) for debugging the programmer cannot base only on "sense of smell", but also... BASIC is the program. One snorting of an array is debugged on hearing. For this purpose into the program the team TRACE SOUND ON enters the musical operators PLAY sounding beginnings and ends of structural blocks. Height of sounds marks a kind of a managing design ("c-up to" – functional block, "d-re" – cycle "while", "e-mi" – alternative, "g-fa" – cycle with parameter, "h-sol" – cycle "up to", "a-la" – choice and "b-si" – cycle with an output from middle), and their duration – depth of an enclosure. The musical coloring of the Fig. 1 allows easily to remove the Eternal cycle, for example, instead of a mark "<" or " <= " and in an initial sorted file there are two identical numbers. In this case program will sound as the worn out plate. To interrupt its performance it is possible as only chord Ctrl-Break, as also easy impact not on the display, but on the system block of the COMPUTER. The operator SPEAK is similar to the operator PRINT. It serves for a conclusion of the information, but not on the display or on the printer, but on sound speaker of the machine. Thus the elements of a file are uttered. The operator SPEAK has changing parameters that allow the machine to be a polyglot and to utter variable words in different languages, different vote (man's female, children's) and with different intonation force.

The European scale "do – major" (C#, C-dur: tone, tone, halftone, halftone, tone, tone, tone, halftone) about family of basic sounds (do, re, mi, fa, sol, la and si) and with help of five auxiliary (do-dies, mi-bemol, fa-dies, la-bemol and si-bemol) is conformable to other creation of Europe. The language Pascal has seven basic (structuralize) and five auxiliary (destructuralize) methods of change the algorithm. Therefore Pascal-program can be sounded so:

This Seven "structuralize" of sounds will sound the program diftong (two sound), marking beginnings and ends of the appropriate blocks. And bemol-dies will be single, marking in the program destructuralize a key word goto and following built-in functions:

And now let's slightly dream and we shall imagine, that the operators of language not only colored (Quick Pascal, Turbo Pascal 7.0, Visual Basic et cetera) but also are sounded. If now program to start in a mode of step-by-step performance, the trace of the program will cause whole color-sound the symphony under the name " Audiovisual debugging ". The sound will be especially useful at research recursion of algorithms. The colour of trace will rush on the operators made between the announcement of procedure – function and its call. But only the varying duration diphthong will testify that any cycling is not present, and there is a travel on structure of the program – on its second dimension.

Seven-musical musical adjust it is possible to attribute (relate) not only to language Pascal, but also to the second popular programming language – to language C. And the BASIC bases on other musical basis, since includes not seven, but five structural managing designs:

It is possible to explain this law from the "musical" point of view. The business that five notes, instead of seven is a basis east sound string, instead of European: in East at lessons solfeggio sing "aa-ee-ii-oo-uu", instead of "up to – re-mi-fa-sol-la-si" as in West. Languages Pascal and C were created by the programmers for the own use. Language a BASIC reflected as a tool means for "of east natives" – not professional programmers using the computer for the decision of the applied tasks. BASIC is not only abbreviation of the English phrase " Beginner's All-purpose Symbolic Instructions Code ". The word BASIC has and direct translation – basic programming language. In colonial of century missioners used Basic English), consisting from approximately 300 words, for dialogue with the natives.

' Sorting of array with music

PLAY "o3ms"

DATA 5, 3, -6, -69, -89, -5

READ n: DIM a(n): FOR i = 1 TO n: READ a(i): NEXT i: flag = 1: PLAY "c1"

PLAY "d1"

WHILE flag = 1

      PLAY "c2": flag = 0: PLAY "c2"

      PLAY "g3"

      FOR i = 2 TO n

          PLAY "e4"

          IF a(i) < a(i – 1) THEN

             PLAY "c5"

             SWAP a(i), a(i – 1)

             flag = 1

             PLAY "c5"

          END IF

          PLAY "e4"

      NEXT i

      PLAY "g3"

WEND

PLAY "d1"

PLAY "c1"

FOR i = 1 TO n: PRINT a(i): NEXT i

PLAY "c1c0"

'Fig. 1. Program with «music statements»

'Fig. 2. «Music» created of program on Fig. 1