Skip to content
English

Installing and your first program

This page takes you from nothing to a running program. It needs about five minutes.

Install Algorizm

Algorizm is a single program. Get it from the downloads page and follow the short steps there for Windows, Linux or macOS. When it is installed, this command prints the version:

algorizm --versiya

If the system answers that it cannot find algorizm, either the folder is not in PATH yet, or you need to type the full path of the program, for example C:\algorizm\algorizm.exe.

The first program

Create a file named salom.alg in any text editor (Notepad, VS Code, or any other) and type one line into it:

chiqar("Salom, dunyo!")
Output
Salom, dunyo!

Save the file as UTF-8 text, which is what editors do by default. Then open a terminal in the folder of the file and run it:

algorizm salom.alg

chiqar is the built-in function that prints its arguments on the screen. Text is written in quotation marks.

A slightly longer program

ism = "Ali"
yosh = 17

chiqar(f"Salom, {ism}!")
agar yosh >= 18:
    chiqar("Siz kattasiz")
aks holda:
    chiqar(f"18 yoshga {18 - yosh} yil qoldi")
Output
Salom, Ali!
18 yoshga 1 yil qoldi

Three things in this program are worth noticing:

  • A variable is created by giving it a value with =. There are no declarations and no types to write.
  • f"..." is text with values inside: whatever stands in { } is worked out and put into the text.
  • The lines that belong to agar and aks holda are indented by four spaces. Indentation is how Algorizm knows where a block begins and ends, so it is not optional.

The interactive mode

Running algorizm without a file name starts the interactive mode. Type a line, press Enter, and the answer appears at once. This is the quickest way to try something out.

>>> 2 + 3 * 4
14
>>> ism = "Ali"
>>> ism.katta()
"ALI"
>>> funksiya ikki(n):
...     qaytar n * 2
...
>>> ikki(21)
42
>>> chiqish

A block, such as a function, is finished with an empty line. Type chiqish to leave, and yordam to see what is built in.

The apostrophe

Uzbek words such as to'xta, yolg'on, bo'sh and qo'sh contain an apostrophe. Algorizm accepts every common way of typing it and treats them all as the same letter: the straight apostrophe ', the backtick, and the curly forms ʻ and ’. Your own names may contain apostrophes too, for example yo'l = 1.

Comments

Everything from # to the end of a line is a comment. Algorizm ignores it; it is a note for the person who reads the program.

When something goes wrong

If a program contains a mistake, Algorizm stops and says, in Uzbek, which line is wrong and why. Here a function name is misspelled:

narxlar = [12000, 25000, 8000]
chiqar(uzunlk(narxlar))
Output
Xato (2-qator): 'uzunlk' aniqlanmagan. Balki 'uzunlik' demoqchimisiz?

The message names line 2 and suggests the right word. Errors are described in detail on the page Errors.

What next

Continue with Values and variables, the first page of the tutorial.