Monday, August 20, 2007

Programming in and for Devanagari

Programming for Devenagari has been largely supported by mordern languages like Java.
However, I have never tried before to program in devanagari. Using the Google's Indic transliteration tool (http://www.google.com/transliterate/indic) and a modified BeanShell editor for MeTA Studio I had some fun (http://tovganesh.googlepages.com/ganak.bsh):


गणक(अ, ब) { print(अ + " और " + ब + " की गणना " + (अ + ब) + " है!"); }


now the function can be called as:

bsh% गणक(5, 6);

the result being:

5 और 6 की गणना 11 है

which was cool. I tried the same trick in JavaFX Pad with the following code (http://tovganesh.googlepages.com/om.fx):


import javafx.ui.*;

var नमो = "ॐ नमो भगवते वासुदेवाय";

Frame {
title: "Hello World JavaFX"
width: 200
height: 50
content: Label {
text: नमो
font: new Font("sans", "PLAIN", 22)
}
visible: true
}



and WOW it worked :)


now finally I used a unicode capable editor to key in the following Java snippet:

public class हेलो {
public static void main(String [] args) {
System.out.println("भो विशव \n");
}
}

and compiled and ran it as shown in the screen shot:


and as u see, this too worked . Only the output is a bit problematic because of some font problem with my Indic font installation on FC6. However, the same is not the case when the code is written in the modified BeanShell editor in MeTA Studio.

In any case I enjoyed this experiment and hope that one day I can write a whole useful software in Sanskrit :)

No comments: