Csq Documentation

Getting Started

Csq is a high-level, easy-to-use, and transpiled programming language with a syntax very similar to Python and the speed near C++. It was designed by Aniket Kumar in 2022.

There are total two functional versions of Csq but in this case we are going to use version (4.2).


$ git clone https://github.com/CsqLang/Csq4
$ cd Csq4/
$ bash build.sh
            

Now you are good to go!

Hello World Program

Let's create our first program in Csq:


print 'Hello, World!'
            

Let's run it:


$ ./csq cpp hello 'current-directory'
            

Output:


Hello, World!
            

Data Types

Csq4.2 is a dynamically typed programming language so here no type is required to decl a variable

Creating a Variable and doing assignment:


a := 405
a = 595
print a
            

Output:


595
            

Control Structures

Csq supports all types of control structures present in Python. Be aware of the indentation since Csq doesn't consider tabs as indents.

If statement

The if statement will execute a block of statements only when the condition is true.


a := 334
b := 334
if a == b:
    print 'equal'
            

Output:


equal
            

Else statement

The else statement will execute a block of statements only when the if condition is false.


a := 334
b := 3334
if a == b:
    print 'equal'
else:
    print 'not equal'
            

Output:


not equal
            

Elif statement

The elif statement will execute a block of statements only when the above if or another elif condition is false.


a := 334
b := 3334
if a == b:
    print 'equal'
elif a < b:
    print 'done'
            

Output:


done
            

Loops

To repeat a piece of code, we use loops. In Csq, there are two types of loops: while and for.

While loop

It's a type of loop that executes the block of code until the condition is false.


i := 0
while i < 5:
    print i
    i = i + 1
            

Output:


0
1
2
3
4