📜 ⬆️ ⬇️

Gentee programming language

Dear community, I want to tell you about the programming language Gentee . I am sure that you have not heard anything about him, but this is not a novelty. The first working version of the compiler saw the light in 2008, and at the end of 2010 the latest version 3 was released. Gentee is an open source project and is distributed under the MIT license , that is, without any conditions and restrictions. Besides me, another person worked on the compiler, libraries, and all the documentation. In the beginning I want to write about the history of the language. Since 2000 I have been working on installers in which the user could build scripts from specific commands. That is, each command from the parameters on the form had to be converted into code in some language that could be compiled into byte code and create an executable file. We started with a primitive language, but in the end we decided to make a language of wide application. The main requirements were as follows: fast compiler, easy work with Windows API, small size of the virtual machine engine, concise and clear syntax, ability to use the compiler and virtual machine from any programming language. The C language was written bytecode compiler and virtual machine. Gentee.dll (compiler and VM) takes only 112 KB and can be included in any project that requires a built-in programming language. A program on Gentee can be executed immediately after compilation, or you can create an executable file with bytecode and a stitched virtual machine.

Brief language description


Gentee has an “C” -like syntax and will be understood by anyone who has come across any language from this family. The language has a strong typing and is not an SNAP, although it has type inheritance (objects) and supports polymorphism. I will not describe the syntax and basic features, I just give the content of the Language Description section of the official documentation, and then I’ll focus on a couple of interesting points. I think that in this case you will develop a more complete picture of the possibilities of Gentee.

Basic language elements



The structure of the program. Preprocessor


')
Types and variables



Functions operation methods



Language constructs



Expressions and Operators



Some interesting moments


I liked programming in C, but I always didn’t like the fact that I couldn’t just define a str type string in local variables, work with it and not think about deleting it when exiting a function. When creating the language, I fixed this problem and you can safely write

func myfunc
{
str mystr = "This is a string"
print( mystr ) // , print( "This is a string")
}


This applies not only to str, but also to any type. You can describe the delete and init methods of the type, which will be automatically called when creating and deleting variables. Also, any type can be “screwed” on the index [i], iteration in the foreach operator, use of operations =, +, -, ==,! =, * Etc ...

The second interesting point is integration with any API. If you have a DLL with exported functions, you can easily connect and use them in your program.
For example, you can write
import "user32.dll"
{
uint ExitWindowsEx( uint, uint )
uint RegisterWindowMessageA( uint ) -> RegisterWindowMessage
}

and then use ExitWindowsEx and RegisterWindowMessage as normal functions. This possibility does not mean that the language can not be ported to other platforms. Gentee v2 had a version for Linux, but, unfortunately, the third version of the compiler, for various reasons, still remains only for Windows.

It was difficult to find a compromise between simple and power of the language, some functionality may not be enough, but we are not ashamed of the result. There is, for example, a text function — this is when there is not code with strings, but any text with code intersperse (analogous to HTML with PHP code). You can link any files to the byte code and then access them directly in memory or write them temporarily to disk (useful for DLL files used). Of course, there is a preprocessor with macros and conditional compilation and much more.

What's next?


Any language is of no interest without the possibility of its practical application. On the one hand, Gentee is widely used in our programs, the distribution includes more than 30 libraries (files, string, tree, dbf, sqlite, xml, COM / OLE, HTTP, FTP, etc.), the compiler contains a built-in optimizer, there is even a visual studio for creating GUI programs (but without documentation), there is a debugger developed by one of the users of Gentee. On the other hand, there is no widespread interest in the language. The reasons are clear - everything related to the language was created on pure enthusiasm and therefore there are not enough funds to bring it in the desired form. I want to see versions not only for Windows. Also, it would be possible to add new features to the language itself (optional parameters, support for UTF-8 and Unicode at the language level). There are ways for development, but even now Gentee is a very convenient language for use in other applications and as an improvised tool for quickly creating small utilities.

To those who say, “Why do we need another programming language?” Or “What is better than others?”, Let them call me another language with similar capabilities, which can be used in the program as a scripting language and in which the compiler and / or virtual machine It takes less than 150 KB.

Source: https://habr.com/ru/post/145813/


All Articles