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.
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
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";
import "Srl/Console";
Srl.Console.print("Hello World!\n");
import "Srl/Console"; Srl.Console.print("Hello World!\n");
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");
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.
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, ...);
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 = 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:
import "Srl/Console"; use Srl.Console; print("Alusus language supports coding in English & Arabic 100%%");
Alusus language supports writing in English & Arabic by 100%
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
import "Srl/Console"; use Srl;def c: char = 'a'; Console.print("%c", c)
import "Srl/Console.alusus"; use Srl.Console; def x:int; print("x Address is: %p\n", x~ptr);
x Address is: 0x55a3b28493f0
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.