Chomik

Chomik is an experimental and minimalistic interpreted programming language. Its interpreter - chomik has been written in C++ (version 17). It is Open Source (GPL 3.0). You may use it in your own C++ projects. If you find it useful you may even use it in a commercial product - contact me pawel.f.biernacki@gmail.com to agree on the commercial license then.

Rationale

For years, for decades we were using the programming languages based on the mathematical notation with some extras like IF..THEN construct and FOR construct, in various forms. The mathematical notation was designed by the mathematicians (no surprise!), not by us, the programmers. Languages were copying ideas one from another, introducing just new syntax as something revolutionary. In fact they are just clones. Until someone comes and writes something like Chomik on his own. This is not a clone of Fortran/C/C++/Java and similar languages. There are no data structures in Chomik. No explicit loops. No conditional instruction. In spite of that it is a powerful language.

Concepts

There are at the moment two Chomik-like programming languages. One is Chomik itself, and one is SDL_Chomik (based on the SDL2/SDL2/SDL2_ttf libraries). The main concept in both languages is a family of variables. Some families of variables are built-in, and implemented actually in C++. For example 'print ...'. Other families of variables can be provided by the user. So what is the big deal? Why is Chomik different than other languages? The idea is, that variables have unified names. Each name of a variable contains of name items which can be identifiers or literals (of any type, including code). But there are no parameters passed to code as such. For instance you can define a family of variables of type code, and give each variable within this family a different code value. BTW - you can do it with other built-in types as well. There is a clean separation between the name of a variable and its content. Second - in C++ for example there are various ways to refer to variables, depending on whether they are items within an array, standalone variables, object attributes, attributes of an object denoted by a pointer and so on. In Chomik all these logically exists, but their names are syntactically the same. A sequence of identifiers mixed with literals and placeholders.

Names of variables

In the traditional imperative languages the variables names are identifiers. In Chomik/SDL_Chomik they are sequences of identifiers mixed with literals and placeholders. The literals of any built-in type, i.e. an int, a float, a string or even a code. The placeholders look like (P:T) where P is the placeholder name, and T represents some set (type). When you define a family of variables without placeholders then it represents a single variable, no matter how complex the name is. If you use placeholders Chomik will create a cartesian product of all types of the placeholders used to build the name of the family of variables. And for each item of the cartesian product it will create a separate variable. So for example 'alpha (X:boolean) (Y:boolean)' is a family of four variables, whose names are:
  • alpha false false
  • alpha false true
  • alpha true false
  • alpha true true
This is how we create "arays", "objects" or other complex data structures in Chomik. They are all just families of variables.

Evaluation of a variable

We do not assume in Chomik that a name of a variable should mean two things, either evaluating it, or assigning it, like it is the case in Fortran/C/C++/Java/... Instead there is a special operator to evaluate a variable. For example to evaluate a variable 'alpha false false' we have to write '<alpha false false>'. This operator can be nested! This way instead of 'false' we can refer to another variable, for example we can write: '<alpha <a> <b>>', and, provided the variables 'a' and 'b' exist and have boolean values we can this way refer to any of the variables from the family 'alpha (X:boolean) (Y:boolean)', just using the 'a' and 'b' as indices. Needless to say, this eliminates the need for a conditional instruction! Instead of writing IF..THEN..ELSE we define a family of variables of type code with a placeholder (X:boolean) and make one of them (for false) to have one code value and another (for true) a different value. This way Chomik naturally enforces writing clean code!

Loops

If you want to do something like printing out all items of the cartesian product, say of two boolean sets, then you are free to type: '<print (A:boolean) (B:boolean)>' and Chomik will print out:
false false
false true
true false
true true
        
So there is no need for a loop command. You just iterate implicitly over all items within the cartesian product. All iterations in Chomik are done this way!

Enumerations

Enumerations are probably the most powerful weapon in Chomik's arsenal. Chomik allows recursive enumerations, i.e. enumerations with values depending on their very type! It also allows one type of enumerations to depend on another type, and allows the dependency to be mutual (cyclic), up to a certain depth. We can then use the enumerations as names of variables (or part of their names). Take a look at the Chomik tutorial to find out more.

Mixing Chomik and C++

You are free to enhance Chomik either embedding it in your C++ programs as a scripting language, or extending it, i.e. creating new Chomik dialects. Take a look at the source code of SDL_Chomik (in the folder src2 of the Chomik sources) to learn how this can be done. All new Chomik dialects inherit the Chomik features and are free to add new families of variables, new enumerations and so on.

Download

You may clone the chomik git repository from: https://github.com/pawelbiernacki/chomik. The chomik repository contains the source codes for:
  • chomik
  • sdl_chomik
  • http_chomik
  • fancy_http_chomik
  • libchomik library
  • libhttpchomik library

For Windows

Here are the binaries of chomik and sdl_chomik for Windows: chomik_for_windows.zip
They require the following DLLs (win32 versions):
  • libfreetype-6.dll
  • libgcc_s_sjlj-1.dll
  • libharfbuzz-0.dll
  • libjpeg.dll
  • libpng16-16.dll
  • libtiff.dll
  • libwinpthread-1.dll
  • SDL2.dll
  • SDL2_image.dll
  • SDL2_ttf.dll
  • zlib1.dll

Docs

chomik_0_1.pdf

Copyright by Pawel Biernacki, 2023 Vantaa