Coding In Malayalam


Read {count} times since 2020

Some days ago, I came across Malayalam numerals and found it very interesting. Unlike Hindi or Kannada numerals, the numerical grammar of Malayalam was unique. It’s a direct fork of the Tamil numeric system. So, Tamil & Malayalam has this unique numeral system. It is no longer commonly used though. Like the rest of the world, we use Hindu-Arabic numeral system now.

I had to include my phone number in a webpage recently for an event hosting and was concerned whether spammers would take hold of it with their fancy phone-number mining scripts. An idea to prevent this and still give the phone number was to write it in Malayalam numerals. The event was related to Malayalam, so some people would recognize it. Besides, if there were people who really really wanted to reach via phone, they’d go through the trouble to read the numerals eh ? 😉 :D (psst, see my contact page)

Here’s a phone number sample :

+91 7458367458

+൯൧ ൭൪൫൮൩൬൭൪൫൮

So this is a good usecase right, and it’s very unlikely that there’s a spam crawler script which can read malayalam numerals.

It’s difficult to look up each number and do a manual replace. I automated it by making a webtool to convert Hindu-Arabic numerals to Malayalam numerals.

But I wanted to make this more cool, so I decided to write the code in Malayalam using Thengascript. Thengascript is a dialect of JavaScript. Each JavaScript keyword has a Malayalam alternative in it. Once you have the dictionary, it’s fairly easy to write code.

Editor

My primary code editor is Sublime Text, but Malayalam rendering in it wasn’t good. So I had to find alternatives.

KDE’s Kate editor with Manjari (and other Unicode Malayalam) fonts worked really well.

VSCode failed to give correct rendering of some ligatures even after setting the font. This is definitely because of splitting up of characters due to syntax highlighting :

Programming in Malayalam - VSCode

So I picked Kate.

Typing

I used a mix of Varnam & Swanalekha to code in Malayalam on Linux. With the ibus integration, I can toggle between them and English very easily.

Language Style

Since Malayalam is Subject-Object-Verb as opposed to English’s Subject-Verb-Object, it feels awkward to write some statements.

Example :

var arr = [1, 2, 3]
for (var a in arr) {
  if (a == 1) {
    continue
  }
}

In Thengascript, the equivalent is :

ആവട arr = [1, 2, 3]
ഇന (ആവട a ഇല്‍ arr) {
  ആണി (a == 1) {
    ടര
  }
}

If following Malayalam grammar, the better way to write it would be :

arr = [1, 2, 3] ആവട
(arr  a) ഓരും {
  (a == 1) ആണി {
    ടര
  }
}

Programming in Malayalam - KDE Kate Editor

At last, I’ve made a simple script to encode and decode Malayalam numerals <-> Hindu-Arabic numerals. I called it Malayakkam (മലയക്കം) and it’s just under 30 lines of Thengascript.

Also check out malluscript, a scripting language in Malayalam and Manglish made with Rust.

Tamil has its own programming language called Ezhil from 2007 onwards. They specially made it for kids to understand programming better which is noble. It follows Tamil language logical constructs in the code syntax which makes it easier to understand for a Tamil native.

Show Comments