Application of national languages ​​in SPL programming

    Surely every programmer takes for granted that the main program code is written in English. One can argue about whether this should be necessary or is it just an anachronism, but it happens differently.

    Indeed, as a rule, programming is carried out in English. And there are several reasons for this.

    The first is the standard. And it exists not only in programming. Since school, we are accustomed to write:

    y = sin(x)

    but not at all:

    в = син(г)

    Therefore, of course, any library function should have its own basic designation, and it will most likely be in English.

    The second is internationality. It is unlikely that anyone is specifically developing a programming language for use exclusively in one country in the world and in only one language - Russian, Chinese, Hindi ... That would be extremely impractical. The language should be as accessible as possible to everyone, unless, of course, this is a special mnemonic code for a limited range of tasks. Well, if it is international, then this is English, as the simplest and most widespread international language.

    The third is, of course, the story of the creation of the language. Despite a large number of programmers both in Russia and from Russia, programming technologies are developed, as a rule, by large international corporations. And the language there is chosen, of course, English.

    In fairness, it should be noted that there are development of programming languages, the basis of which are national languages ​​other than English. That is, you can meet such code samples:

    (Тип1 Эл, Тип2 Зн, (Фн1) Фн):
    _Примесь лТ___;
    *лА=лТ___.Тип1;
    лА=Эл;
    лТ___._ЗнПримесь=Зн;
    лТ___._ФнПримесь=Фн;
    =лТ___;

    The question of the convenience of such coding is left open.
     
    In short, it is completely understandable and not surprising that, with the exception of comments, the program code will be in English.

    And now about how it could be different. As a language developer, I’ll say right away that the ability to use the writing of variable names, user functions, library functions in an arbitrary language should be laid down in the language’s capabilities, in its syntax initially, at the time this language was created. That is, so that the simultaneous possibility of such a record:

    y = sin(x)

    and such a record:

    в = син(г)

    would be equally acceptable for both the computer and the programmer.

    And there is good news: firstly, Unicode was invented a long time ago, and secondly, they continue to invent new programming languages, for example, the SPL language.

    In SPL there are no restrictions on what language the names of variables, functions, and other objects are called. Examples of valid names:

    N
    x1
    123k
    текст
    颜色

    Okay, good. Let's say there are no problems with variable names and they can be called as you like. But what about the constructions of the language itself? Loops, transitions, keywords that are in any programming language - how to deal with them?

    Elementary. There are no keywords in SPL. This language is so simple that he simply does not need them. Loops and transitions? Here is the loop and transition:

    >
    'тело цикла
    <
    1 -> 'а это переход на метку с именем "1"
    

    Symbols instead of keywords? Yes, why not! After all, you have hardly forgotten that "->" is a transition to the label. That is, there is nothing complicated here.

    Well, what about library functions?

    Everything is simple here. Of course, the basic version of library functions has an English-language spelling. The sine function there is familiar to everyone sin (). But in SPL, functions are the same objects. And they can be assigned to other objects. That is, you can write:

    син = #.sin

    which means that now the object "syn" is equal to the library function "sin ()", and if you want, now easily write:

    в = син(г)

    In SPL, inserting program files into other files is very simple - just one "$" character:

    $file.txt

    and the file "file.txt" will be inserted into this place of the program. And in this file there can be, for example, a list of your own overrides of library functions.

    In conclusion, I will give an example of the same recursive function of calculating the factorial of a number written in different ways. Please note that all of these options can easily be in the same program code. So to write the program code in English, Russian or any other language is exclusively the choice of the user, and not the requirement of the language if this program is written in SPL.

    fact(n)=
      ? n!>1
        <=1
      .
      <= n * fact(n-1)
    .
    #.output(fact(5))
    

    печать=#.output
    фактор(н)=
      ? н!>1
        <=1
      .
      <= н * фактор(н-1)
    .
    печать(фактор(5))

    $中文
    阶乘(号)=
      ? 号!>1
        <=1
      .
      <= 号 * 阶乘(号-1)
    .
    印(阶乘(5))

    where is the contents of the 中文 file:

    印=#.output

    Thanks for attention!

    Also popular now: