What Is Alusus Programming Language?


Alusus programming language is a general purpose programming language that can be dynamically extended by end users. At its core it's a low level language similar to C, giving users procedural programming, static typing, pointers, manual memory management, and other low level features found in C/C++. In addition to these low level features, Alusus provides few extensibility features that allow users to extend the language vertically to provide high level features as well as extending it horizontally to support new fields. By default it is JIT compiled, but users can also choose to pre-compile their executables.

Setup And Running Instructions


Before starting you should have installed Alusus on your device. If not, you can visit the Download page and follow the required instructions
In case of any problems, you can seek help from the Community

The First Program


You will learn how to write the first and the simplest code you could implement using Alusus, which is printing "Hello World!". So first you should include the required libraries to implement this program, and as the case in any language there is a standard build module that execute the procedural operations inside the program. In Alusus this module is "libalusus_spp.so", so we should start the program by including it in the following way:

import "libalusus_spp.so";

Now we need to a function that do print operation, this is done using `print` function which is in `Console` module, which in `Srl` library. So we should include it at first:
import "Srl/Console";

When including a file, the compiler includes the files and libraries that this file includes, so if we include "Srl/Console" then we don't have to include "libalusus_spp.so" manually since it is included in `Console` library. Now we could use `print` as follows:
Srl.Console.print("Hello World!\n");

We add between parentheses a variable that represents the string we want to print, or the string directly between two double quotations as we just did. Regarding \n operator, it is an optional symbol as in all programming languages, it start a new line after the print operation. So we could write the whole code as follows:
import "Srl/Console";
Srl.Console.print("Hello World!\n");

Output:
Hello World!

Note: to make calling `print` function easier, we could use `use` command to allow us to directly access the elements of a module, for example `Srl`, without the need to write the name of the module.

import "Srl/Console";
use Srl.Console;
print("Hello World!\n");

Output and Input


All input and output operations in Alusus is done using `Console` module, so don't forget to include it (as we did in the previous example) before thinking of executing input or output operations. Also, each data type has its own input and output method.

Printing


In Alusus we use `print` function to execute output operations. It is the standard function used for printing strings. This function gives us the ability to control the way strings are printed, or what is known as strings format, and the ability to print variables values inside the string we want to print. It has the following form:

print(format, ...);

`format` argument represents the string, and the three dots `...` allow us to add unspecified number of arguments. This type of functions is known as "Variadic function", and to print the values of the variables (integer, real, or char variables) we add to the format a specific expression depending on the type of the variables.
Let's assume that you have a variables `x` that contains a numerical values resulted from some arithmetic operations, and you want to know the value of this variable, if you write the name of the variable (which is `x`) between double quotes, then the character `x` will be printed, not the value of the variable `x`, for that reason we use this function and add to the format a specific format to make this work. The next example shows us how to use this function to print an integer variable.
import "Srl/Console.alusus";
use Srl.Console;
def x: int=3; // The definition of an integer variable (we will discuss all types in the next lesson).
print("Result = %d", x);

Result:
Result = 3

We write the sentence we want to print inside double quote, and we reserve a place inside the string (like a Placeholder that we provide its value later) to print the value of the variable inside it by writing `%` followed by `d`, `%` symbol is a special symbol for `print` function (it is replaced by the variable value), that we specify its type by the letter `d` then we passed the variable `x` as a second argument.
There is a specific set of letters that we could use with `%` symbol to control the way of printing variables' values, each one represent a specific type of data, the letters that we could use and the type they represent is shown in the following list:


Symbol %:
This symbol is used to print the percentage symbol as it, since this symbol is special for this function, we could not print it unless we write it twice. Example:

import "Srl/Console";
use Srl.Console;
print("Alusus language supports coding in English & Arabic 100%%");

Result:
Alusus language supports writing in English & Arabic by 100%

Symbols d, i:
`d` or `i` letters are used to print the integers which represented by `int` class. Both of them print the integers in `print` function. Example:

import "Srl/Console";
use Srl.Console;
def integerNum: int;
integerNum=778
print("%d",integerNum); // Print it while keeping the print pointer at the same line
//print(integerNum); // the same as the previous print statement
//print("%d\n",integerNum); // the same as first statement but it move the print pointer to a new line

Symbol c:
Used to print data with type `char`, which is a single character, or a special symbol from the ASCII characters set.

import "Srl/Console";
use Srl;def c: char = 'a';
Console.print("%c", c)

Symbol f:
It is used to print the floating point numbers, this type of data is known as `float` (we will talk about it in variables lesson).


Symbol s:
It is used to print a text that may contains more than one character, which means printing strings (we will talk about them in variables lesson).


Symbol p:
It is used to print the address of the pointer in hexadecimal. As shown in the next example:

import "Srl/Console.alusus";
use Srl.Console;
def x:int;
print("x Address is: %p\n", x~ptr);

Result:
x Address is: 0x55a3b28493f0

Symbol e or E:
It is used to print the numbers with `float` type in the `Scientific Notation` which is formed by writing the number raised to the power equal to number of decimal digits, which is the way used to represent floating point numbers the known by IEEE-32 and IEEE-64.


Symbol g or G:
It is used to print the decimal numbers with `float` type, which is printed in the regular way `fixed-point` if the number could be written in that form. If the number is bigger than we could show, it is printed in the `scientific-notation`, and the difference between `g` and `G` is the way the exponential letter is printed in the scientific way, 'g' will print 'e' and 'G' will print 'E'.


Symbol a or A:
It is used to print the decimal numbers with type `float` in hexadecimal, and the difference between the small and capital letter is the case it prints the letter x which precedes the number.


Input


To enter an integer we use `getInt` function, as shown in the next example:

import "Srl/Console";
use Srl.Console;
def integerNum: int;
integerNum=getInt (); // enter the number
print("%d",integerNum);

To enter an floating point number we use `getFloat` function, as shown in the next example:

import "Srl/Console";
use Srl.Console;
def floatNum: float[64];
floatNum = getFloat (); // enter the number
print("%f",floatNum);

To enter a char we use `getChar` function, as shown in the next example:

import "Srl/Console";
use Srl.Console;
def c: char = getChar();
print("%c", c);

To enter a string we use `getString` function, but we will not talk about it in this lesson since we are going to do that in the lesson for `String` class.