Educational language in robotics
Hi all. I developed a programming language with Russian syntax, specifically for robotics based on ESP8266 boards. This language should simplify the learning process for schoolchildren and make programming accessible even to beginners, without requiring in-depth knowledge of English or complex technical skills. But first things first.
So, let's get to know each other a little. My name is Yaroslav and I have been working as a teacher for children for 3 years. I mainly teach programming and robotics. Now I’m working on my robot project for teaching, and we’ll actually talk about one of the parts of this topic today.
Why create a new language? I will say right away that the answer to this question is quite simple. My idea is to bring programming to the web. You connect to the robot via IP and get a website development environment. This way you won’t need to install anything on your device. Also, I want to add simplicity to the learning process.
How does this language work? There is nothing special here, the user wrote the code, then directly on the site, the code is processed lexer to get a list of tokens. The tokens go to the parser, which, connecting them, creates an AST (abstract syntax tree) that the interpreter will use to execute. In addition, AST is also used to build a block diagram of the code (currently disabled, as it requires improvement). It is the AST that will be sent to the robot and executed there. The diagram of this language can be seen in the figure below.
Now let's look at what already works and what can be used. The first thing you need to write a program is, of course, a code editor. It allows you to write a program, and nothing more for now. In the future, both tabulation and syntax highlighting will be added. But at the moment this is not in the alpha version. By the way, you can write what you need to add in the comments, it will be interesting to read your ideas about the ideal code editor.
Next, what you can see on the alpha version is a simple simulator. The robot in this world has only a couple of motors and a proximity sensor mounted on the front. It’s not too rich here either, but in the future it will be possible to change the configuration of components and edit the “room” (that’s what I called the environment for the robot). At the moment there are only 2 obstacles in the “room”.
Finally, let's move on to the main and most important thing, namely the language itself. This is still an alpha version and the syntax will continue to change and be improved in the future.
цел x = 10
цел y = 5
цел z = x + y * 2 // Ожидаемый результат: z = 20
вывод(z) // Должно вывести: 20
As you can see, variables are declared in the same way as in many other languages. There are line comments //. The “output” command prints data to the console. Variable names can have both Cyrillic and Latin alphabet.
если z меньше 15
вывод("z меньше или равно 15")
иначе
вывод("z больше 15")
конец условия
Conditions in a language work the same way as anywhere else. The only thing that could cause you misunderstanding or even indignation was replacing the “<" symbol with the word "less". This decision was made in order to minimize the need to switch layouts.
цел счетчик = 0
пока (счетчик меньше 3)
вывод("Счетчик: " + счетчик)
счетчик = счетчик + 1
конец цикла
At the moment there is only a “while” loop, also known as a “while” loop. And here you may notice something that will no longer be in future versions of the language. The parentheses for the repetition condition will be removed. In the web version, both finite and infinite loops work fine. They don't block the visual display, and if the robot is forced into an infinite loop, nothing bad will happen.
ЛевыйМотор(вперед)
ПравыйМотор(вперед)
РоботВперед()
Пауза(2000) // Робот двигается вперед 2 секунды
РоботСтоп()
ЛевыйМотор(назад)
ПравыйМотор(назад)
РоботНазад()
Пауза(2000) // Робот двигается назад 2 секунды
РоботСтоп()
РоботРазвернись(влево)
Пауза(1000) // Робот поворачивается влево на 1 секунду
РоботСтоп()
цел расстояние = РоботДистанция()
вывод("Расстояние до препятствия: " + расстояние)
These are commands to control the robot. There is not much yet, and there are no commands to control ESP8266 ports directly, but this allows you to create simple programs in this language.
What can I say as a result? My language is not perfect yet, but I would like to finish it. You can try it out in person at test page. I would be extremely grateful for your opinion and feedback, as it will help make my language better, more convenient and understandable. The main goal is to educate children, so I ask you to leave your opinion.