Thursday, May 14, 2015

Programming in multiple languages.

English is a language that has been the language of progress for a long time. A lot of the best things in the world have come forth from English speakers.

For people who do not natively speak English, programming is a thing which is subject to first learning the language of the world. For a lot of people that is a big step and not always such an easy one if their native language has a different structure along with a different script.

PyTongue to the rescue!! This little piece of code makes writing programs in your native language a lot easier by providing transcription services for python. Sadly the entire ecosystem of python is not supported but on the bright side people can understand the code being written.

For example:-
# HI
छाप('नमस्ते दुनिया!')
के_लिए i में range(10):
    छाप(i)
जब सच:
    छाप('नमस्ते दुनिया!')
This is code written in Hindi and produces completely understandable results. The second last line evaluates to While True: and so produces an infinite loop (there is no running from those things even in a perfect world.)

For proof of concept I tried out Arabic and Hindi programs and they ran flawlessly on my computer. Although I have pretty much no idea what the Arabic program says, I am sure it makes sense.

Since I know Hindi, I know that the program makes sense, although is a broken manner. This should not matter as constructs in programming languages are made up of only a handful of expressions. The loops are in a specific format and so are the conditional statements.

The downside is that since the software provides only Transliteration the generated programs still have to make sense only in the English way of sentence construction. The program in Hindi makes absolutely no sense in Hindi grammar but is still more readable than a program in English.

Also the programs need to be run; which indicates an interaction with the terminal/ OS in some manner. This itself indicates a point of failure as the OS is English supporting most of the time ( I know of no systems which have commands in other languages. So `ls` still remains `ls`). Sigh, some day I am going to make a language which is language independent. May that day dawn quickly. (I know about Lisp so do not even start. :)