$ thought | blog

Place to serialize my thoughts…

Archive for June, 2006

Rhino, BeanShell comparison

with 3 comments

Update (22/May/2007): I have also included Groovy performance as per Tom's comment. The post is here.

Recently I got a requirement to provide scripting capabilities in our product. A while ago, I was reading about JSR 223 and thought to have hands on the scripting capabilities of Java. While searching Internet I came across a page which states number of programming languages for Java VM. The most appealing options for me were Rhino, BeanShell and JudoScript. Ofcourse Groovy, Ruby and others are good too, but I wanted a simple and close to Java scripting for my product.

To get a quick start, I chose Rhino and BeanShell. JudoScript sounded like lots of in-built capabilities and since I didn’t want a Swiss-knife kind of thing with me so I chose to go with generic approach of Rhino and BeanShell.

In our case, developers will write some small routines to process sql resultsets. Typically the operations will be getting values in different columns or creation of sets etc. So my job is to provide a framework which takes sql queries dynamically and pass on the resultset to script. Script will process resultset and return the Lists or HashMap to framework again so that further processing can be done. So from my perspective resultset processing abilities was a winning point. For those who are more interested in computational performance analysis, I hope they will love to see this page.

Coming back to data processing capabilities, I set a simple test case with following steps:

    • Get Resultset
    • Note start time
    • Process Resultset using Java / Rhino / Beanshell code.
    • Note end time

      I kept number of records as a variable in all of the executions. Thus I wanted to see the effect of increasing recordset size on performance. I started with 50 records and final reading was taken at 50000 records. Result of tests is as follows -

      Script Performance Analysis

      To help you understand clear the tabular representation of above data is -

      Num of Records Java Rhino BeanShell
      50 31 375 250
      500 110 391 453
      5000 359 844 1391
      50000 2375 5515 11406

      On your machine the figures may vary a little bit but the ratio should be roughly same. BeanShell's performance is dropped suddenly with the larger size of record set. On the other hand Rhino performs consistently and balances better with the size record set. For Java the ratio for 50:50000 records is 1:37 but for Rhino its 1:15. For Beanshell same ratio stands as 1:45! This clearly shows that there is consistency in performance of Rhino compared to BeanShell.

      Although Rhino is winner from the performance perspective, I need to admit Beanshell is homely for Java developers. The communication between beanshell and java is almost seamless. For Rhino you need to understand Scope, context and little more Rhino specific things but for BeanShell there is no complexity. So from simplicity perspective I vote for BeanShell.

      My advice to others will be, there is not much difference in both of the scripting engines. Normally neither we process (or at least not supposed to process) 100000 element sized lists nor so big datasets. So its mere matter of choice for majority of users. Go with BeanShell if your end-user is a Java Developer as its very easy to understand the operation and there is very little learning curve.

      If you like JavaScript or needs millisecond accurate performance guarantee then choose Rhino as it proves to be consistent. I didn't get chance to test E4x and other features but overall Ecmascript 4 is good. I will love to hear any other experiences regarding above two or any new engines.

      Written by Sachin

      June 28th, 2006 at 10:51 pm

      Posted in Programming

      Tagged with , ,

      Like New Reader Feature

      without comments

      Ever you wished about a feature in product and it happened right away? How quick? Well in my case it took 7 hours flat! Yesterday night before sleeping, I tried to organize my Google Reader subscriptions. I wanted to categorize them with labels. Man, that was real pain! :( For each label it will say "Fetching you subscription list" and the pane size keeps on changing. That was really painful for me to arrange my reading list.

      I opened my mail editor to send feedback to Google Reader that I want you to make it simpler! But I didn't send the mail and fall asleep. I wake in morning, go to Reader and amazingly I could see the screen below :)

      New Reader Feature

      Man, that was quick! I happily organized the reading list and I have decided to be with Google Reader for some more time.

      Kudos to Google team.

      Written by Sachin

      June 28th, 2006 at 8:22 am

      Posted in Developer,General

      Tagged with ,

      Open Standards

      with one comment

      I read today about new protocol for reading and writing data on web. Google has put the client libraries and other information on their website. I really appreciate the style of Google for providing open standards as well open application interfaces. We all know that Google earns a huge amount of money from their Ad programs but still, they are doing many things for free. Their every effort to make the web better place is clearly visible. Take example of their vast range of applications, (Gmail, Calendar, Spreadsheet, Reader, Suggest, Maps...) all applications are wonderful and I love them. Undoubtedly they brought the Ajax wave to mass. Many people were using XMLhttp before Google too, but it was not to masses, Google not only made it visible but they demonstrated how you can really simplify the applications!

      Similar things should happen for quite long from now. We need help from giants on the web. They need to help building and realizing the open standards so that Web 2.0 and subsequent versions of it will be much more powerful than anybody has seen or imagined!

       

      Written by Sachin

      June 27th, 2006 at 4:19 pm

      What Ubuntu User say?

      with 2 comments

      I was on vacation for last few days. :) I got chance to talk to once of my friend who is using Ubuntu on his laptop. He was using Breezy Badger distribution and the laptop was little old and upgraded one. I was curious to have a talk with him regarding his suggestion / feedback.

      He was also going through same cycle of happiness which I experienced before! What made me more curious was, he was using a 3-4 years old laptop which was upgraded in terms of RAM and other hardware. That was IBM Thinkpad with earlier Pentium 4 processors. He said, he could run it smoothly and there were no hardware issues at all! He could install everything very easily and comfortably. That is a reason for toast!

      He was happy with performance and also features. I would like to mention his one quote, which everybody will agree... "It is better than Windows XP!"

      Written by Sachin

      June 27th, 2006 at 4:04 pm

      Posted in Personal,Ubuntu

      Tagged with , ,

      Are we ready for Web 2.0?

      with one comment

      Hushhh... last week was a real rough! Got some time to breath and felt to write a post. I am currently developing software which has a web-based application component. We tried to ajaxify it to give better user experience. We did it really well. There is lot of buzz going on since last few months around Ajax. Ajax is going to play a vital role in Web 2.0. In this post I would like to shed some light on Ajax only. Before we go too ahead, what we need to think is, are we really ready for this?

      Ajax gives a very rich experience to user. Ajax gives richness of web and feel of desktop applications in true sense. While development, I felt that we are not that ready to hit the road. The first and foremost important thing is, the platform which runs the Ajax i.e. browsers are not supporting it natively. If browsers provide a clean abstract level implementation of Ajax then a new developer will not get confused by tons of different frameworks. Instead of number of frameworks, we need native support for Ajax and similar things. That will save lot much efforts of developer and in turn it will allow us to concentrate more on the business logic.

      GWT (Google Web Toolkit), Tibco GI, Echo2 and Laszlo DHTML are good efforts towards simplyfying the development cycle. Still, Echo2 and Laszlo needs server side runtimes and GWT has better still Java based approach. I will really appreciate if IE or Mozilla support the Ajax just like form handling or any other task in the JavaScript. There shouldn't be any headache to handle responses, marshall / unmarshall the XML etc. XML responses should be handled properly.

      The fact still remains that there is huge compatibility issue with JavaScript. ECMAScript 4 standard is out and I don't know why browsers don't support it. Flex people were successful by implementing the ECMAScript 4 standard natively which supports E4X, the new way to handle xml, and other many powerful features.

      Now I am not interested to start any flame war or address to JavaScript machos who will say Ajax is simple though. Still majority of people find it painful and we run into trouble many times.

      To be really ready for Web 2.0 we need Web 2.0 ready web-browsers. Instead of handful of frameworks we need native support from browsers. ECMAScript 4 should be supported by all leading browsers. Most of all, I plea to Microsoft for not making their own standard for browsers. That really creates huge application portability issues. If they really want to create own standard then let it be public so that other people can get benefit out of it!

      Peace.

       

      Written by Sachin

      June 22nd, 2006 at 10:21 pm

      Posted in Programming

      Tagged with ,