Tuesday, March 31, 2009

Comment on: BeanShell, Rhino and Java -- Performance Comparison

These are my comments on an old performance test by Pankaj Kumar on BeanShell, Jython and others (http://www.pankaj-k.net/spubs/articles/beanshell_rhino_and_java_perf_comparison/index.html).

There are some notable problems with the benchmarks reported in above Blog:
1) When a time comparison is done, you chose the best possible implementation of an algorithm in that language. Evidently this is not the case. For instance, in case of BeanShell, ArrayList is used to represent an array of Strings and not a normal array. This introduces additional overheads especially calls to get() method.
2) If you use inbuilt methods to do the sorting: i.e. array.sort() for Jython and java.util.Collection.sort(array) for BeanShell the results are totally different, and it seem to show Jython to be 13 times slower than BeanShell for array if size 1000. Which is bizarre.

In short, I find all such benchmarks as misleading, and should not be used as the mere metric for choosing a particular scripting language, or for that matter any other programming language. And Pankaj does seem to make this comment at the end of his article.

Another reason to fool around with MeTA Studio: Python support

Well yes! Many had asked for it so now here is it!

First a bit of history. When I started developing MeTA Studio, I did evaluate Jython (Python implementation for JVM) along with BeanShell and many others. But then finally decided that BeanShell would be the first class scripting interface for MeTA Studio with provision for adding any other scripting language that is targeted for JVM. There were couple for reasons for this decision:

- Jython is too heavy. At about 3 mb (with no debug info). My modified BeanShell is 800kb while if u compile it with no debug info it boils down to a mere 200kb!!
- Prototype-to-production. Python code, though easy to write, doesn't translate easily to Java code. It is very easy to prototype in BeanShell and put it into Java.
- Speed. While BeanShell can run at native speed of Java (i.e. after you compile the code for a target JVM), Jython is purely interpreted, and it was definitely orders of magnitude slower than BeanShell. When I tried Jython the first time many years ago it was about 40-50 times slower than BeanShell, enough to keep me away form making it the primary scripting interface for MeTA Studio. In recent times though Jython has improved substantially. In many cases faster, but not as flexible as BeanShell in terms of the earlier point(s).
- License. It is not LGPL/BSD... So I will only distribute it as a separate addon package (maintainers are needed here ;) !)

and why it is included now:
- IBM supports Jython in their enterprise apps like websphere, I want to impress them ;) With rumours of them taking over Sun.. (Glee .. Well now wondering on that as Oracle plans to buy them instead!)
- I want more developers and users for my platform!!
- Proof that other languages can be easily supported, with out changing anything within the core IDE!
- I want to have fun ;)

Well the complete Jython support for MeTA Studio was added with about 4 days of work, which largely involved writing appropriate wrapper functions akin to BeanShell. And thanks to ways to add external library and widgets framework in MeTA Studio, there were no changes made to the core IDE specifically incorporate Jython support.

So you wanna give a try? Here is how:
The installation instructions are same as previous, but again ..
0) Ensure u have v 2.0.01042009 or a higher version installed. Project URL: [http://code.google.com/p/metastudio/]
1) Unzip metajython.zip (download from: Jython support file on Skydrive) in meta/lib/ext
2) Shut down MeTA Studio if it is already running
3) from command line:
meta/bin >$ java -jar MeTA.jar --addlibs jython
(you can skip this step, if you have already done so with the previous builds)
4) Start MeTA Studio, open the code editor. Then open jythonWidget.bsh from meta/lib/ext/meta-jython directory
5) Click on Make Widget to get the Jython widget on the the widget panel

Now you can either use the shell (like the usual python shell) or use the editor to write code in python as you would normally do for BeanShell scripts.

I will be putting up user guides on how to use the Jython support in MeTA Studio at: http://code.google.com/p/metastudio/wiki/PythonSupportForMeTAStudio. You are also strongly encouraged to contribute to the wiki, just drop me in a mail if you want to!

Now that Jython support is out, would like to state few things about future of this Jython support of MeTA Studio:
- Firstly, BeanShell will always be the primary scripting interface in MeTA Studio. Meaning that all new releases of MeTA Studio will come installed by default with BeanShell as has always been the case.
- Jython will never be distributed along with binary distribution of MeTA Studio. This support will always be available as an external download as is provided above.
- Since this project is getting big day-by-day, it would be really nice if some one can take up the responsibility of maintaining the Jython support in near future. Though I would maintain it with a bit less priority till I can get a maintainer for this port.

Fool around ;-)

Monday, March 30, 2009

MeTA Studio bug fix release

Another online release is available (MeTA Studio version 2.0.31032009). This is primarily a bug fix release. But it also includes a test geometry minimizer based on MM/UFF being written by Josh. To use this Right Click in MoleculeViewer, Choose Tools -> Minimize. Again note that the minimizer is an experimental code, and may not give you expected results!

And yes, suggestions are also welcome for the modified project page at: http://code.google.com/p/metastudio/

Have fun!

(Quick Update: as usual, found some last minute bugs after I uploaded the online update, so now the latest version is 2.0.01042009)

Tuesday, March 24, 2009

MeTA Studio SVN repository

Starting from today, daily source updates of MeTA Studio will be available via the SVN repository: http://code.google.com/p/metastudio/source/browse/

Note that I will still release stable source tar balls as earlier (http://code.google.com/p/metastudio/downloads/list), but the current source will give a preview of things to come. I do not recommend using any of the APIs in the current source to write scripts or applications of your own! These are subject to change on day to day basis.

On a side note: I hate SVN :(


Saturday, March 21, 2009

A reboot on Photography

Well this time at a different place in the world… Oz, the “island continent”, place of kangaroos.

When I got my first digital camera, I had been regularly with my photography interest. But I soon hit into how much I can stress with my very minimal HP camera with 3x optical zoom. Most of times I am interested in either far away objects or macro shots. For either of these I have to strain a lot with my HP camera to get good shots. I also tried things like putting extra lenses for macro shoot and also a telescope for getting a closer look at the moon.

In any case, my interest in photography has not gone done, least because I can not yet afford a good quality DSLR ;-)

So, I decided to go about my photography again with my HP camera, this time a new place. All the photos here are in fact indoor photos, in that me and the camera were both inside my home or on a balcony at a friends place, but what was shot was all outside ;-)


On my backyard, the clouds begin to appear…


they are a bit shy ;-)


and then they are all over!


and the rain…


and the storm was hard for this branch…


no one out there, its raining there !



and I try to cook in the mean time… Those potatoes stacked up on their own, I didn’t do it :-)




and at the end there was this wonderful rainbow. All shots are taken with different EV exposure settings.

And then, I go to play tennis on weekend these days… but since my games is very bad, I though its better to shoot some thing that looks better than my self ;-) which now really makes for  the outdoor photography :D All these photos were taken on my mobile (Nokia e51) camera.



Then we went to a small (but quite steep) waterfall near Canberra



and some of the photos on Bateman bay





That is it for this photo story ;-)

Have fun!

Tuesday, March 17, 2009

My parents fixed the PC at home!

This was an experience!

For the last one month or so my parents have been complaining that my PC at home some times suddenly refused to start up. This was strange to me as the PC in question is a Dell machine and is about an year and a half old. Though I have opened it up and added a few memory modules and a graphics card to over the time.

Now I have absolutely no physical access to my machine @ home, but I heavily depend on it to talk to my parents. The only rational thing I could figure out most of the time was that the power plug was loose and you just need remove it from UPS and fix it back. Though I was pretty sure that it was not the real problem as I have never seen it to be loose before.

And one fine day, i.e. on a Monday (March 9, a holiday for me and had planned a cycling session to a near by lake for the day), my mom calls me and tells me that my computer is broke!! It is giving strange beeps and there is no power on keyboard! From which I could only make a vague guess that there is some memory problem or some of them have gone loose for some strange reason.

That was pretty good observation by my parents, I must admit, as they are not really used to computers as I am. Though my dad has worked on third-generation computers, but that was quite a while ago.

Ensuing this was a real ordeal from my and my parents side, beginning by telling how to open the machine. Thank god it was a Dell machine, and you can easily open the side cover without using screwdrivers! To make them open the cabinet did not take much of a time it was done with some five minutes of instructions.

The real hard part was telling them where the RAM was installed! I tried giving all sorts of rubbish analogies. First I made sure that they know what board to look into (motherboard). And then finally settled on to this one: there are 3 "ruler-like" strips placed next to each other, which are perpendicular to the motherboard and are placed on "white" strips. Lol, I have never had had to tell any one before how a RAM chip looks like :)

After this, they told that yes, they can see it. Next, it was easy to tell them how to remove one and then test whether the system powered on. My system back home has a 2GB, 1GB and a 512MB chip. One-by-one they removed the chips and checked, but all was in vain. So next, I asked them to put back the chips one-by-one, this was more harder to tell them, as you need to put them back properly (they go only one way in) as also you need to press the chips somewhat hard to place them firmly on the holder. It didn't work for the first two times. So I was almost gonna give up and in between I called up my computer guy back in Pune to ask if he could to be free to drop in at home that same day and fix up the things. He told that he would call me back in 10 mins and let me know! This was pretty surprising reply by any standards!

But in the mean time they could properly figure out how to place the chips and started the PC. Next I was able to remotely connect to it and could figure out that only one module was properly fitted. So I again called them and asked them to properly fit the other two. And viola, the next time I connected remotely, every thing was back to perfect and normal.

All of us were pretty happy for this. But I was pretty amazed, my parents fixed the PC!! and this was the first time ever they had opened it by themselves, though they have seen me doing this countless number of times :)

And to add to all the amusement, the computer guy form Pune called back, I am still recovering from this! Any way so I told him that my parents fixed it, though you might be needed some other time ;)

Ha and on the downside, its was all a 3 hour "fixing time", and cost me 500 INR for all the conversation we had, and well I stayed home for the whole day. But what the heck, it was worth it!

Wednesday, March 11, 2009

MeTA Studio online update

A new version is available (2.0.12032009).

Two reasons for this version:
- First, it is a bug fix release with a few new features added. You can also note changes in graphics APIs (which are far from complete). MapReduce is now more simpler to use with wrapper functions, essentially it boils down to:

res = mapreduce("/home/ganesh/meta/scripts/map.bsh",
"/home/ganesh/meta/scripts/reduce.bsh", data);

- Second, its a special day ;)

Have fun!

GMail times

Some days ago I noticed that GMail is giving weird timing information. This is related to what is shown on the top of the message (yyy minutes ago). Most of the time now they turn out to be negative!! I think they have started using clock reading from the user's computer to stamp their mails. So in case if some one has a time set in future, it gives -ve date. I dont think it was this way earlier, the time stamps *should* be taken from a known, correct source! Google please change this!!

Wednesday, March 04, 2009

4:44, 22 C

.. numbers are interesting, aren't they?

At times they can get serious too: Recipe for Disaster: The Formula That Killed Wall Street . Check out this interesting article on wired.com :)

Sunday, March 01, 2009

MeTA Studio update: MM/UFF, map-reduce and bug fixes

An online update for MeTA Studio is available (v. 2.0.02032009).
If you have not followed the instructions in the previous updates as put in (http://tovganesh.blogspot.com/2009/02/meta-studio-update-map-reduce-editor.html), kindly go through that before applying the current update.

There are some interesting things happening behind the scene with MeTA Studio development:
- Josh Milthorpe, a Ph.D. student at ANU, is actively contributing code and bug fixes to MeTA Studio. So hope to have some quite interesting contributions from him in near future :)

- Current version includes a very basic implementation of MM/UFF by Josh in MeTA Studio, but is not fully integrated yet. First plan is to get it working with the MoleculeEditor. To test out you can use some thing like the following from bsh prompt:


Note the APIs here are at a very primary stage, and may change as we progress.

- There is a major upgradation of map-reduce implementation. Now this supports handling of node failures as well as has multi-core support. Next plan is to get some useful application on this platform. All ideas in this respect are welcome!

- This version also includes stable release Apache math-commons lib (http://commons.apache.org/math/), which supplements and enhances math APIs that are already a part of MeTA Studio.

- As usual, the update includes many bug fixes. You may also spot some organisational changes in graphics rendering APIs, which is being slowly re-factored. If you have not written any script that explicitly depends on these very raw APIs (and I presume this is highly unlikely) nothing would break.

As always, if you have any issues / suggestions feel free to post them at: http://code.google.com/p/metastudio/issues/list

Have fun!

( Update: Found out some last minute bugs with the way the node failures are addressed in map-reduce implementation in MeTA Studio and is subsequently patched today with version (2.03032009) ..

This version also adds some enhancements to MM/UFF by Josh.

The number 03032009 seems to be interesting though ;)
- two 3 s
- one 2
- 3 x 3 = 9
- 3^2 = 9