Kannadigarinda, Kannadigarigoskara 🔥

Learn programming
in Kannada.ಕನ್ನಡದಲ್ಲಿ ಕೋಡ್ ಮಾಡಿ

A beginner friendly programming language with Kannada keywords. Write them in English letters or in ಕನ್ನಡ ಲಿಪಿ, and run your code right here in the browser.

hello.kans
namaskara
  idu hesaru = "Kannada";
  helu "Namaskara, " + hesaru + "!";
matte sigona
› Namaskara, Kannada! Try it
namaskaraನಮಸ್ಕಾರheluಹೇಳುiduಇದುenadruಏನಾದ್ರುellivarguಎಲ್ಲಿವರೆಗೂprathiಪ್ರತಿkelasaಕೆಲಸkoduಕೊಡುmatte sigonaಮತ್ತೆ ಸಿಗೋಣ

English or ಕನ್ನಡ ಲಿಪಿ

Every keyword works in both scripts. Switch a whole program with one click.

Runs in your browser

Nothing to install. Your code is saved automatically and easy to share.

Errors that help

Mistakes are explained in Kannada with an English hint and the exact line.

Real programming

Variables, conditions, loops, functions, arrays and input. Concepts that carry over to any language.

Ready to write your first program?

13 examples to start from, from helu to recursion.

Open Playground
Documentation

Learn Kannada Script ಕಲಿಯಿರಿ

A dynamically typed toy language written in TypeScript. Every example below can be opened in the playground with Try it.

Getting started#

Every program starts with namaskara and ends with matte sigona. Anything outside of them is ignored, so you can write notes there. Statements end with a ;.

example.kans
Try it
This line is ignored

namaskara
  helu "Namaskara Jagattu!";
matte sigona

This too

Comments#

Use // for a single line comment and /* ... */ for comments spanning multiple lines. In the playground, Ctrl + / comments out the selected lines.

example.kans
Try it
namaskara
  // idu ondu comment
  /*
    Idu
    dodda comment
  */
  helu "Comments are ignored";
matte sigona

Variables#

Create variables with idu ("this is"). Several can be declared at once, separated by commas. A variable declared without a value is khali. Use = to change a value and +=, -=, *=, /=, %= to update it.

example.kans
Try it
namaskara
  idu a = 10;
  idu b = "two", c;
  a = a + 1;
  a *= 2;
  helu a, b, c;
matte sigona

Types#

Numbers and strings work like in other languages, strings can use "double" or 'single' quotes and escapes like \n, \t and \". sari and thappu are the booleans, khali means empty (null), and [ ] makes an array.

example.kans
Try it
namaskara
  idu sankhye = 10 + (15 * 20) / 4;
  idu dashamaamsha = 3.14;
  idu shabda = "Namaskara \"anna\"";
  idu nijavaa = sari;
  idu sullu = thappu;
  idu enuilla = khali;
  idu patti = [1, "eradu", sari];
  helu sankhye, dashamaamsha, shabda;
  helu nijavaa, sullu, enuilla, patti;
matte sigona

Printing#

helu ("say") prints values. Separate several values with commas and they are printed on one line with spaces in between.

example.kans
Try it
namaskara
  helu "Hello World";
  idu a = 10;
  {
    idu b = 20;
    helu a + b;
  }
  helu 5, 'ok', khali, sari, thappu;
matte sigona

Operators#

Arithmetic: + - * / %. Comparison: == != < <= > >=. Logical: mattu (and, &&), athava (or, ||) and alla (not, !). Adding a string to a number joins them.

example.kans
Try it
namaskara
  idu a = 7;
  helu a + 3, a - 3, a * 3, a / 2, a % 3, -a;
  helu a > 5, a == 7, a != 7;
  helu (a > 5) mattu (a < 10), sari athava thappu, alla sari;
  helu "Score: " + a;
matte sigona

Conditionals#

enadru (if) runs a block when its condition is sari. Add any number of illa andre (else if) blocks and finish with an optional enu illa andre (else). thappu, khali, 0 and "" count as false, everything else as true.

example.kans
Try it
namaskara
  idu a = 10;
  enadru (a < 20) {
    helu "a is less than 20";
  } illa andre (a < 25) {
    helu "a is less than 25";
  } enu illa andre {
    helu "a is greater than or equal to 25";
  }
matte sigona

ellivargu loops#

ellivargu ("until when", while) repeats its block as long as the condition is sari. Use saaku nilsu ("enough, stop") to leave the loop and munde nodu ("look ahead") to skip to the next round.

example.kans
Try it
namaskara
  idu a = 0;
  ellivargu (a < 10) {
    a += 1;
    enadru (a == 5) {
      helu "loop olaginda helu", a;
      munde nodu;
    }
    enadru (a == 7) {
      saaku nilsu;
    }
    helu a;
  }
  helu "done";
matte sigona

prathi loops#

prathi ("for every") is a counting loop: prathi (start; condition; step). The loop variable only exists inside the loop. Every part is optional, prathi (;;) loops until saaku nilsu.

example.kans
Try it
namaskara
  prathi (idu i = 1; i <= 5; i += 1) {
    helu i, "x 9 =", i * 9;
  }
matte sigona

Functions#

Create functions with kelasa ("work") and give back a value with kodu ("give"). A function without kodu gives khali. Functions can call themselves (recursion), be stored in variables and passed to other functions.

example.kans
Try it
namaskara
  kelasa jodisu(a, b) {
    kodu a + b;
  }

  kelasa factorial(n) {
    enadru (n <= 1) {
      kodu 1;
    }
    kodu n * factorial(n - 1);
  }

  helu jodisu(2, 3);
  helu factorial(5);
matte sigona

Arrays#

Arrays hold a list of values: [1, 2, 3]. Read and change elements with list[index], indexes start at 0. Strings can be indexed too. Use uddha, serisu and tegi to get the length, add and remove elements.

example.kans
Try it
namaskara
  idu hannu = ["mavu", "bale"];
  serisu(hannu, "halasu");
  hannu[0] = "seebe";

  prathi (idu i = 0; i < uddha(hannu); i += 1) {
    helu i, hannu[i];
  }
  helu hannu, "Kannada"[0];
matte sigona

Built-in functions#

Kannada Script comes with a few helpful functions. Each one also has a Kannada script name, e.g. ಉದ್ದ for uddha. See the table in Keywords.

example.kans
Try it
namaskara
  helu uddha("namaskara"), uddha([1, 2]);
  helu sankhye("41") + 1, pada(41) + 1;
  helu poorna(7 / 2);

  idu stack = [];
  serisu(stack, 1);
  serisu(stack, 2);
  helu tegi(stack), stack;
matte sigona

Input#

kelu ("ask") reads a line of input and gives it as a string, use sankhye to turn it into a number. In the playground, answers come from the Input tab (one per line), otherwise the browser asks you.

example.kans
Try it
namaskara
  idu hesaru = kelu("Ninna hesaru? ");
  idu a = sankhye(kelu("Ondu sankhye: "));
  helu "Namaskara " + hesaru + "!", a, "x 2 =", a * 2;
matte sigona

Write in ಕನ್ನಡ ಲಿಪಿ#

Every keyword can also be written in Kannada script, and variable names can use Kannada letters and digits (೦–೯). Mix both as you like. The ಕನ್ನಡ ಲಿಪಿ button in the playground converts a program between the two.

example.kans
Try it
ನಮಸ್ಕಾರ
  ಇದು ಹೆಸರು = "ಕನ್ನಡ";
  ಏನಾದ್ರು (ಉದ್ದ(ಹೆಸರು) > ೨) {
    ಹೇಳು "ನಮಸ್ಕಾರ " + ಹೆಸರು;
  } ಏನೂ ಇಲ್ಲ ಅಂದ್ರೆ {
    ಹೇಳು ಖಾಲಿ;
  }
ಮತ್ತೆ ಸಿಗೋಣ

Errors#

When something goes wrong, Kannada Script tells you what happened, in Kannada with an English hint. Syntax errors show the line and column, in the playground that line is highlighted and you can jump to it. Infinite loops and runaway recursion are stopped automatically.

example.kans
Try it
namaskara
  idu a = 10
  helu a;
matte sigona
Cheat sheet

Keywords ಪದಗಳು

Both spellings work everywhere. Use whichever you find easier.

namaskara
ನಮಸ್ಕಾರ
hello — the program starts here · program start
matte sigona
ಮತ್ತೆ ಸಿಗೋಣ
see you again — the program ends here · program end
helu
ಹೇಳು
say · console.log
idu
ಇದು
this is · let
enadru
ಏನಾದ್ರು
if ever · if
illa andre
ಇಲ್ಲ ಅಂದ್ರೆ
if not · else if
enu illa andre
ಏನು ಇಲ್ಲ ಅಂದ್ರೆ
if nothing else · else
ellivargu
ಎಲ್ಲಿವರೆಗೂ
until when · while
prathi
ಪ್ರತಿ
for every · for
saaku nilsu
ಸಾಕು ನಿಲ್ಸು
enough, stop · break
munde nodu
ಮುಂದೆ ನೋಡು
look ahead · continue
kelasa
ಕೆಲಸ
work · function
kodu
ಕೊಡು
give · return
sari
ಸರಿ
right · true
thappu
ತಪ್ಪು
wrong · false
khali
ಖಾಲಿ
empty · null
mattu
ಮತ್ತು
and · &&
athava
ಅಥವಾ
or · ||
alla
ಅಲ್ಲ
not · !

Built-in functions

uddha(x)ಉದ್ದ

Length of a string or array

serisu(list, x)ಸೇರಿಸು

Adds x to the end of the array, gives the new length

tegi(list)ತೆಗಿ

Removes the last element and gives it back

sankhye(x)ಸಂಖ್ಯೆ

Converts to a number: sankhye("42") is 42

pada(x)ಪದ

Converts any value to a string

poorna(x)ಪೂರ್ಣ

Rounds down to a whole number: poorna(7 / 2) is 3

kelu(prompt)ಕೇಳು

Reads a line of input as a string

Command line

Run on your computer ನಿಮ್ಮ ಕಂಪ್ಯೂಟರ್‌ನಲ್ಲಿ

Install Kannada Script from npm, save your programs as .kans files and run them from the terminal.

  1. 1Install
    $ npm i -g kannada-script

    Needs Node.js 14 or newer

  2. 2Write hello.kans
    namaskara
      helu "Namaskara Jagattu!";
    matte sigona

    Any text editor works

  3. 3Run it
    $ kannadascript hello.kans

    kelu() reads from your keyboard

Want to improve Kannada Script itself? See the development guide to build it from source.