Gentee Programming Language

Published on June 18, 2012

Gentee Programming Language

Dear community, I want to tell you about the Gentee programming language . I'm sure you have not heard anything about him, but this is not new. The first working version of the compiler was released 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 can build scripts from specific commands. That is, each command from the parameters on the form had to be converted into code in some language, which could be compiled into bytecode and create an executable file. We started with a primitive language, but in the end decided to make a language of widespread use. The basic requirements were: fast compiler, easy operation with the Windows API, small size of the virtual machine engine, concise and clear syntax, the ability to use the compiler and virtual machine from any programming language. In C, a bytecode compiler and a virtual machine were written. Gentee.dll (compiler and VM) takes only 112 KB and can be included in any project that requires a built-in programming language. A Gentee program can be executed immediately after compilation, or you can create an executable file with bytecode and a wired virtual machine.

Short language description

Gentee has a “C” -like syntax and will be understood by anyone who comes across any language from this family. The language has a strict typification and is not a NLO, although it has an inheritance of types (objects) and supports polymorphism. I will not describe the syntax and main features, I just give the contents of the Language Description section of the official documentation, and then dwell on a couple of interesting points. I think that in this case you will have a more complete picture of the features of Gentee.

The basic elements of the language

  • Identifiers
  • The numbers
  • Lines
  • Binary data
  • Macros
  • Collections

Program structure. Preprocessor

  • Comments Character Replacement
  • Define command
  • Ifdef command
  • Macro Expressions
  • Include command
  • Import command
  • Public and private commands

Types and Variables

  • Type command
  • Type inheritance
  • System Methods for Types
  • Global team
  • Local variables

Functions Operation Methods

  • Func function definition
  • Method definition
  • Overriding operator operations
  • Definition of text function
  • Property properties
  • Extern command
  • Subfunc subfunctions
  • Return variables

Language constructs

  • If-elif-else condition construct
  • Switch selection construct
  • While and do loop constructs
  • For and fornum loop constructs
  • Foreach loop construction
  • Return, break, continue statements
  • Label, goto instructions
  • Construction with

Expressions and Operators

  • Arithmetic operators
  • Logical operators
  • Assignment Operators
  • Cast
  • Fields and Pointers
  • Calling Functions and Methods
  • Conditional operator ?
  • Late binding operation
  • Operator Priority Table

Some interesting points

I liked programming in C, but I always did not like the fact that I can’t just define a string like str in local variables, work with it and not think about deleting it when I exit the function. When creating the language, I fixed this problem and you can safely write This applies not only to str, but also to any types. You can describe the delete and init methods on the type, which will be automatically called when creating and deleting variables. It is also possible to “fasten” the call by index [i] to any type, iterate through the foreach statement, use the operations =, +, -, ==,! =, *, Etc. ... The second interesting point is integration with any API. If there is a DLL with exported functions, then you can easily connect and use them in your program. For example, you can write

func myfunc
str mystr = "This is a string"
print( mystr ) // Я понимаю, что можно написать просто print( "This is a string")

import "user32.dll"
uint ExitWindowsEx( uint, uint )
uint RegisterWindowMessageA( uint ) -> RegisterWindowMessage

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

It was difficult to find a compromise between the simple and the power of the language, some functionality is probably not enough, but we are not ashamed of the result. There is, for example, a text function - this is when there is no code with lines, but any text interspersed with code (an analog of HTML with PHP code). You can link any files to the bytecode and then access them directly in memory or write them temporarily to disk (useful for used DLL files). 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 Gentee users. On the other hand, there is no mass interest in the language. The reasons are understandable - everything related to the language was created on pure enthusiasm and therefore there is not enough money 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

For those who say: “Why do we need another programming language?” Or “Why is it better than others?”, Let them tell me another language with similar features that can be used as a scripting language in the program and which has a compiler and / or virtual machine takes less than 150 KB.