Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, August 8, 2011

Maven dependency for tools.jar in JDK7

Although it has been known for sometime now that JDK7 will bring the change to vendor properties name change from “Sun Microsystems Inc.” to “Oracle Corporation”, I thought it would serve as a good reminder since Java 7 final was just released.

If you have a maven project that uses tools.jar and adds that as a dependency to the project as follows:

...
<profiles>
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
...

For making this work with JDK 7, you have to change the java.vendor value to Oracle Corporation like this:

...
<profiles>
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Oracle Corporation</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
...

Tuesday, November 9, 2010

Netbeans Community Testing for 7.0 starts

Netbeans has just started its Community Acceptance Program (NetCAT 7.0) for Netbeans 7.0. Basically developers who are using Netbeans as their IDE need to download latest builds and report bugs. Good experience to get involved with testing and learn more about Netbeans. Also makes some friends with community and developers at Sun Microsystems.

Helps improve the IDE you use daily!!

Go HERE: http://wiki.netbeans.org/NetCAT

Monday, August 16, 2010

Netbeans UML Moves to Community

Today after the hand over conference call, we are proud to be the first set of community developers (The Since 2010 developers) of the Netbeans UML plugin. I’ve been a fan of the Netbeans UML plugin, as it was simple and helped produce neat looking UML diagrams, without a lot of fuss. When the Netbeans developers from Sun decided to abandon the UML plugin, I was pretty disappointed. Nevetheless, a few weeks earlier, some members of the Netbeans community were contacted to get involved in reviving the module and I was among the interested developers.

The primary goal of the community developers will be to create a stable release that can be put back on the Plugin Center. This means eliminating the P1 bugs and then P2 bugs which are listed on the dashboard against UML. I hope we can do this before the next release of Netbeans, which is Netbeans 6.10. There are about 3 P1 bugs and 19 P2 bugs today and I’m sure there are more coming on the way as we move to committing fixes and reaching code that works with Netbeans 6.9… It is indeed a milestone that UML has been handed over to the community. Next is the tough part of make it available to the users, so that they can then start filing more bugs and enhancement request and make our contributions more interesting. The developer wiki pages will be updated soon as we start committing code.

NetBeans IDE UML Features is listed under Netbeans 6.9 Features

I guess we aren’t yet here, but we wanna be there soon…

Saturday, August 7, 2010

Tabbed Interface to OpenMRS Global Properties

I’ve always hated to scroll through long lists when trying to find the thing I’m looking for. Computer interfaces which are designed as long list and give you a hard time to look through all of the things without a filter is definitely bad design. But even with a text field filter, long lists take a lot of time to load... The two applications that I’m working with these days, OpenMRS and DHIS2, both have these long lists that in my opinion are a pain to use.

The DHIS2 uses lists for data elements, indicators, users and these are not divided into pages. There is a text filter, but the time it takes to load the page when the list is long is excruciating. One of the recent examples, where we had over 5000 users in DHIS2 Punjab mobile application, it was excruciatingly slow to load that list of users. And then finding through that list to change anything is also quite slow and painful.

Similarly in OpenMRS, one of the things I often use for our modules is the global properties. Modules can use the global properties infrastructure to store options and it is a quick solution when you want to store some settings that can be configured by the user for your module. But as the number of modules or the number of options in a module increases, it becomes a pain to search the exact option from that long list of options. It also does not have a text filter, but you can always use the browser search to reach what you are looking for and text filters, don’t really solve much. Infact, may be the text filter in your application does not have a shortcut, while Ctrl+F would quickly give you a browser search text field.

Nevertheless, a quick hack by our developer Viet Nguyen (the JavaScript Ninja), was an OpenMRS module called moduleoptions. This is his first module, just to understand the OpenMRS framework and to me is quite a useful thing. It divides the global properties in tabs and makes the properties more manageable in my opinion. It provides better management to the long list of global properties and looks more convenient to use. It was developed in a few hours time and is definitely something that I would want to see as default when managing global properties. Below is a screenshot of how the global properties looks now:

module-options-screenshot

Wednesday, August 4, 2010

Netbeans 6.9.1 Released

Update1: Due to technical difficulties as mentioned here… The download links are not available

Update2: Its available for download again…

The latest bug fix release for Netbeans IDE was just released few minutes back. Netbeans 6.9.1 contains some critical bug fixes and includes some new updates to the JavaFX IDE. Hard to believe, but the resources into JavaFX continues…

NetBeans IDE 6.9.1 is a minor update to NetBeans IDE 6.9 and includes the following changes:

  • Availability of the latest IDE bundled with JavaFX SDK 1.3.1
  • Improvements to the JavaFX debugger
  • Important usability issues fixed in the JavaFX Composer and Editor
  • Critical bug fixes made to other modules since the 6.9 final release

The complete release notes can be found here… Netbeans 6.9.1 can be downloaded from here.

Tuesday, August 3, 2010

Slow JSP Editing in Netbeans 6.9

Haven’t blogged in a while, but today was reminded by a friend, that I need to write about this… We’ve been using Netbeans as our IDE for some years now.

I have been acknowledged as the most significant contributor in the Netbeans 6.9 NetFIX program, which is a where community members fix bugs in the Netbeans release… But this is something that I’ve completely missed. The JSP editor performance for free-form projects sucks real bad in the Netbeans 6.9 final release. The problem started somewhere in the beta1 release where the whole IDE hangs after any change in made through the JSP editor. This has been one of the showstopper bugs and yet it became part of the 6.9 release. The issue has been filed here.

Thankfully, the issue has been fixed and is part of the latest release of Netbeans and is a candidate for the Netbeans 6.9.1 which should be sometime during this month. In the meantime, if you have been affected by the slow performance, I suggest that you download the latest release from here. Also keep a watch of the final release of Netbeans 6.9.1 from the dashboard below:

Wednesday, August 5, 2009

“Garage model” Leprosy MIS

While the world’s managers and venture capitalists have lost faith in the “garage model” of business, I am still a firm believer that the best innovations come from individual efforts and not concentrated directional movement in large organizations. Today, was yet another day in the field showing how homebrew software has innovations that many large software suites lack.

Just to give a background on what I’m talking about - a product that I’ve been working on lately is a patient-tracking system for the National Leprosy Eradication Programme. Since DHIS2 is the widely deployed HMIS application in India and aggregated reports for the Government of India are generated through DHIS2, we needed some kind of patient-tracking, yet required aggregate numbers of these patients through DHIS2. For this purpose, the most ideal way we found out was using OpenMRS for the patient-tracking and then generating reports through DHIS2. Thus, we are able to create rich and generic medical records of a leprosy patient, which can later be used not just for leprosy patient care, but future medical treatment of the person for any other disease or health service provisioning.

But today when I arrived to demonstrate this system in Maharashtra State Health Society, I was pleasantly surprised to see a homebrew application. We finished our presentation on the system, demonstrated the application, decided upon pilot process, future meetings and the whole process before we can go live with the system state-wide. Just after we finished our stuff, one of the leprosy health officers told us that he had privately worked on something that was suited for the NLEP program. Most people just ignored his comment, but I was eager to see what he had developed.

And when I saw his application, I was very much stunned. A really nice and intuitive user-interface using Adobe Flex, neat use of data using good-looking reporting and visualization tools, basic reports using excel sheets and a neat-little data model, similar to the ideas in OpenMRS. Maybe the data-model is not suited to a medical records system like OpenMRS, but it very well met the requirements. From what I learnt, it was developed in about a month’s time by one developer, who happens to be the son of this medical officer.

“Commendable effort and nice design decisions”, is what I complemented the medical officer. But what got etched in my mind is that, some best software are written in “that car garage” on a single computer.

Saturday, June 6, 2009

Netbeans 6.7 RC2 Released & Your Feedback Required

The new and shiny Netbeans 6.7 RC2 was released today and if you haven’t tried it out yet, please go and download it. It has host of new features which you cannetbeans 128 1 read here. My favorite feature in Netbeans 6.7 has been the out-of-the-box Maven integration and the ability to create Hudson continuous integration servers.

But more importantly, after you have downloaded Netbeans 6.7 RC2 and played with it enough, please give feedback to the Netbeans developer team about the release. There is a survey called the Community Acceptance survey which is integral to guarantee that the release is acceptable to the community. Isn’t that what open-source software is all about – the community. Please fill in the survey and give your very important feedback.

Wednesday, June 3, 2009

Opera 10 Beta Released and a “Y2K” Discovery for the Web

Opera

Opera has released a beta version of Opera 10, which promises faster web rendering, more accurate standard compliance (e.g. 100/100 on ACID3), Opera Turbo Browsing, Auto-updates and a hell lot of new features. Opera has been well ahead of the curve in terms of features and implementing new standards and Opera 10 is surely on that path.

Y2K-Like Bug Discovered by Opera

While web browsers are one of the most widely used application for computers, not everyone has reached version 10 of the browser. Opera is currently beta testing v10 of its browser and in this process has discovered that a lot of browser detection scripts for websites have a bug of being able to detect only a single digit version number. Much like the Y2K-bug in applications, these browser detection scripts thus think of Opera 10 as Opera 1, and hence show one of these quirky little messages you can see in the image below:

opera10-bankofamerica

While Opera 10 has hacked its way through by renaming its version as 9.80 and putting the browser version in the user-agent part, this problem begs a bigger question to be answered. Opera developers suggest browser-specific hacks and browser detection is not a good thing and such hacks should be avoided. Other people around the web seem to think these web developers need a spanking. While both these opinions are pointing towards the ideal web, none of these are realistic. Because of the way the browsers have understood the ambiguity of web standards differently, the normal web developer has no where to go. There are so many differences in the way IE/Firefox/Opera/Safari render HTML+CSS and execute JavaScript, there isn’t one holy grail that all of us can follow. To adapt to these changes, as web developers we need to hack our ways through some real painstaking quirks. And to avoid some pain, most of us pickup readily available browser detection scripts and feel happy that things work on all the browsers.

This will continue to happen for sometime in the foreseeable future, unless the browser companies sit together and decide how they want to render things... Or the experts from the standards committee write standards that are a little-less ambiguous.

Wednesday, November 19, 2008

Continuous Integration System Roundup

Continuous Integration Systems are one of the most important tools for agile software development. They automate the process of building and testing. A lot of people seem to have realized their importance and there are quite a few products in this arena. I already used Hudson and CruiseControl, but for OpenMRS we need to find one which is best suited to our needs. So I started out about 3 weeks back to create this roundup of continuous integration servers. This should be a useful roundup for any project with similar requirements.

Why does OpenMRS need a Continuous Integration System?

Any software development effort needs to take care that regression doesn’t happen with new code changes. Often a change in the API/module core results in breaking of modules dependent on an earlier method. A Continuous Integration System will rebuild OpenMRS after a change is committed and provide information on how that change is affecting related code.

OpenMRS would also benefit from an easy to understand UI that Continuous Integration Systems provide for number of failing tests. The number of passing or failing Unit Tests will indicate the quality of a build and help implementers/testers realize the stability of a build. We can also set some goals on how many test methods we need to write before an API method can be finalized or deprecated.

The work done in different branches and modules can be monitored and looked at easily by the community.

Building of OpenMRS Installer using NBI can be automated and new users can directly test with the latest build of OpenMRS using the cross-platform installer.

Thus to summarize, a continuous integration system will bring better release quality, more transparency, quicker bug finding and fixing, simplicity and TDD frame-of-mind.

Disadvantages for OpenMRS in using Continuous Integration System

  • Additional Load on Servers
  • Not every developer is motivated to write unit tests ;-)

Features that OpenMRS needs (Not exhaustive)

  1. Easy to monitor tests and easy to understand dashboard
  2. Support for SVN and Ant
  3. Dependency integration
  4. Email/RSS/IRC notifications when a build fails or bad code is committed
  5. Warning flags when a committed code doesn’t follow coding rules (naming, newline format,etc.)
  6. Allow code committers to modify build and test parameters from the GUI
  7. Optimal Performance
  8. Price & Open-source development

Comparison of Continuous Integration Systems:

  CruiseControl Continuum TeamCity Bamboo Hudson
Monitoring UI Dashboard introduced since v2.7 is not intuitive Dashboard only shows tests Advanced UI & dashboard. Advanced UI, Detailed reporting out-of-the-box, Intuitive Simple Dashboard, Plugins enhance reporting, Intuitive, somewhat detailed
SCM Support All Support SVN
Dependency Integration Scripts need to be written for each new dependency. Tracking different versions of dependency jars is very complex Easy for Maven2.0+ projects, but not so easy for other types of projects Dependency can be managed easily. Advanced UI for dependency management Dependency management is easy and intuitive. Different versions of same library not automated. Creating test/build plans allows dependency of different versions Dependency management is easy to configure. file fingerprinting simplifies identification of different versions. Automatically can detect and build project dependencies
Email/RSS/IRC Emails. Plugins - RSS, blog, IM with Jabber Email, IRC, IM with Jabber, MSN Email, Jabber, RSS, external HTML widget Emails, RSS, IM Notification using Jabber or OpenFire Plugin – Emails, RSS, IRC, Jabber, Google Calender, Twitter
Code Quality and Patterns Not very easy to define Could not find a way Can be defined with plugin for IntelliJ IDEA Managed through test plans. Manual test plans have to be created Plugin provides UI. Test plans can be created manually out-of-the-box
Security and User Management Easy to configure with different roles Roles can be easily defined Roles can be easily defined Simplistic UI for user build plan management. Easy integration with JIRA Easy to configure roles for users
Performance Fast Fast Somewhat slower in comparison, but includes a lot of features Fast in build and integration. Slightly slower in reports. Includes lots of features that may not be used. Distributed builds with slaves speeds up performance Comparatively lightweight out-of-the-box, but requires plugins. Distributed builds with slaves speeds up performance
Pricing Free & OpenSource. Paid version called Cruise available. Free & OpenSource Professional version is free, but enterprise is paid Free for opensource projects Free & OpenSource

Netbeans 6.5 Final Released

After some delay in the release due to quality issues, Netbeans 6.5 is out for download. It is netbeans 128 2 indeed a feature-rich build and some great changes have been added for this new release. Along with the new features, I can vouch that Netbeans 6.5 is also a pretty stable release since I was part of NetCAT 6.5 (Netbeans Community Acceptance Program).

The list of new features can be found here… My favorite features are the improvements in Database Query, Python, HTTP Client Monitor, JavaScript Debugger and PHP. If you are a developer from the php world, I would really suggest that you take a closer look at Netbeans 6.5. I love the documentation and code hints that Netbeans will give you.

Netbeans also completed 10yrs a few weeks back and celebrate by downloading Netbeans 6.5 here.

Friday, September 5, 2008

Programming: The finest steel has to go through the hottest fire

As the college season is in full flow, I'm back to my philosophical self and I've something for my students... Last week, I was conducting the regular Assembly Programming practicals, where I'm supposed to teach students 8085/8086/8051 ASM programming. Now, as much as I love programming and finding solutions to problem, I also love another thing: Creating problems for others to solve... and even if I know the answers, I would never give away the answer... come what may!!

So we started with all the instructions, available registers and memory allocation. Somewhere down the line, we started with a program to multiply 2 numbers. Now, as simple as I thought it was, my students didn't seem to think the same way. I told them that repeated addition was actually multiplication and they affirmatively nodded their heads, but the program wouldn't just come out from them. After close to an hour and me giving them numerous hints, we were still stuck at the loop!! They demonstrated it easily in a single line of C or C++ or Java, but ASM wasn't just clicking. That's when I affirmed, "Don't worry, programming doesn't come naturally to anyone... We all learn it our own way!!" And the class was stunned, similar to what I've seen at my office's training sessions... and the next question most of the times is, "Then how does it come naturally to you ??"...

"The finest steel has to go through the hottest fire!"... I read it somewhere, but then that's what is true about your individual talents. A singer's voice, a painter's hand, a composer's notes, a poet's verse... all may be claimed to have come from God or by birth, but its the desire to overcome obstacles and practice is what makes them achieve perfection.

Programming is very much an acquired skill, just like most things in life. Even logic for that matter doesn't come by birth. As we observe others follow a pattern of doing things, we follow that same pattern. The more we do the same thing in a way that is acceptable to our intellect, the more it becomes part of our existence and more natural the action becomes. When we first learn to speak, we probably think its harder than anything we have done before. Now as we know to speak, its easier than easy. Same is with programming. The more code that we observe, the more code we write, programming becomes more natural. Whoever says that logic to solve problems came easy, is either boasting his own ego or hasn't thought logically about it.

I was at the vegetable vendor the other day, who was talking of a way to solve the Bihar floods which made some 20million people homeless. His solution sounded really promising and as I know him for some years now, I knew he was intelligent. Huh... I wondered if programming would come naturally to him. He had never seen or used a computer ever but had passed high school. So if he could find a solution, it would mean that programming (read: finding solutions) came naturally to him. So, while he was selling vegetables, I sat beside him and blabbered the same things, I had told to my students at that lecture, but this time it was in Hindi and avoiding most tech-words. While I was speaking, I didn't even know if he was listening... He was busy selling vegetables, with his ~10yr old son and the aunties that came by kept smiling while looking at me. After a while, I asked him if he could multiple 2 numbers, given the instructions I explained... He thought for a while, picked up a few ladies finger (those long green vegetables), which he represented as instructions and explained me a perfect program to multiply numbers, not just 8-bit or 16-bit that would fit in a register-pair, but a multiplication program that would store larger numbers in ordered memory locations... Wow... that was superb!!... Unbelievable and brilliant, I said to myself!! I told him real instructions like ADD r1 r2, MOV r M,  ... and I told him to use those instructions and make a program to calculate modulus of a number. Hmmm... he thought for a while, but this time couldn't find a solution. He asked me many questions though, which he thought would give him an answer... But alas, no solution was found!!

I went back home and realized that may be it is the mumbo-jumbo words that divert our conscious efforts to find a solution. It may very well be the emotion of success that stops us from continuing to find the next problem and its solution. My students had passed earlier classes with 90% and more marks and were among the best students academically in the city.  Did that success get to them ??... Whatever it was, I realized persistence to find an answer to a problem gave us much better understanding of ourselves... May be programming teaches us to understand ourselves better than the problem at hand!!

Wednesday, September 3, 2008

A Look At Free/OpenSource Cross-Platform Installers

Software Distribution is an essential part of Software Development and can sometimes be the first impression that can make or break the user's opinion about a software. We, as software programmers forget the importance of easy distribution and easy installation of software that we develop. We do not understand the problems that a new computer user or a non-programmer may face. And I experienced this first hand about 2 weeks back, when a physician friend of mine heard that I was working on OpenMRS.

I was lucky enough to work on OpenMRS this summer and learnt a lot more about Medical Informatics during this period than I expected. Hearing this, my friend openrmswanted to install OpenMRS at his clinic which already used Tally (hehe... isn't that innovative??) for storing patient records, observations and prescriptions. He practices at Kolkata, visits different hospitals and sometimes the patients he attended at a hospital come to his clinic. When I told him that OpenMRS was a webapp, he got all excited and I narrated him all the features that OpenMRS could provide and help him manage his patients better through the web, only if he could host OpenMRS from his clinic. I'll skip the other interesting parts and his extra-terrestrial expressions ;-), since we are actually talking about software distribution.

So then came the day when I was about to leave office and he was in his clinic trying to install OpenMRS. It was Independence Day and the clinic was closed but he was excited to experience the new-age medical informatics :-)) When I first got his call he had downloaded the Windows Installer. I was pretty sure it was for an older version and hence told him to instead download the OpenMRS Appliance, which is a VM Image that can be run from one of the virtual machine softwares. Yaw Anokwa made this wonderful Virtual Image with Ubuntu + All Necessary Stuff (tomcat, mysql, demo data) and OpenMRS running. You just have to have VirtualBox or VMPlayer or VmWare Workstation and load the VMimage and wait for Ubuntu to start. It is simple, fast and safe to play with... But for novice users, I just realized it wasn't easy enough. My friend installed VirtualBox and loaded the image. It booted fine, but the network wasn't working and OpenMRS webapp could not be reached from the Windows host. After being on call for close to an hour, we just couldn't make the networking work!! I advised him to install VMPlayer instead and run the image. This time everything ran fine, but some changes had to be made in the Norton 360 Firewall. He kept complaining that Windows XP was punishably slow and then I realized that his 512Mb wasn't enough to virtualize :-( ... So we were back to where it all started!! The Windows Installer that OpenMRS distributes is based on Bitrock. He first tried the OpenMRS 1.1 Installer, but it is an older version that hasn't been upgraded for a year or so... Everything installed fine and he was happy to use it, but it didn't have the features I talked about that were added in newer releases of OpenMRS. I walked him through the manual installation and finally we managed to get OpenMRS up-and-running at 2am in the morning and he having spent about 8hrs on it. Last week when I asked him, he still wasn't using OpenMRS for his clinic and hospital. May be the first experience made him bitter!!

With that episode in my mind, I pledged him that within the next month or so I'll give him and easy to install setup and he'll be happy using OpenMRS. And that's when began my chase to find an easy to use, cross-platform installer framework. OpenMRS has lots of implementations on different platforms (Windows, Linux and Mac) and hence I wanted the installer to be cross-platform. At my office, we generally use Windows Installer or NSIS for making installers. But those are only for Windows. These 2 frameworks are so simple and extensible to use that I was thinking if there was something similar and cross-platform, I could make an OpenMRS Installer in an hour. But sadly, that wasn't the case... I tried a variety of installer frameworks, but couldn't find any of them as simple as NSIS or Windows Installer (msi). The following are the installer frameworks I tried working on:

Installer Framework Short Description Problems
1.) Antigen Antigen (Ant Installer Generator) is a tool to take an Ant build script, combine it with a GUI and wrap it up as an executable jar file. Its primary purpose is to create powerful graphical installers from Ant scripts. Couldn't get it to execute ant-calls at lots of places. Didn't work in openSuSE 11.0 due to some incomplete ant configurations. Hasn't been updated in a long time
2.) IzPack IzPack-generated installers require Java. They are simple, efficient and fast to use. Simple executable deployment is best done through IzPack. Isn't very powerful. Good for simple image deployment, but isn't highly configurable and powerful.
3.) OpenInstaller A newer cross-platform installer framework that is completely customizable and written in Java. Glassfish uses this installer framework. Not much documentation. Complex to implement and doesn't look native on all platforms
4.) Netbeans Installer (nbi) A completely customizable and powerful installer framework. Configuration Logic is written in Java and can be used to do anything and everything that Java programs can do. Old documentation. Requires some effort to get up and running with all the scripts.

So finally, I decided to work on using the Netbeans Installer. Netbeans Installer already has components like Tomcat, MySQL, Glassfish, OpenESB and their deployment scripts. And I thought it will simplify my effort... Dmitry Lipin of Sun Microsystems, the lead developer of the NBI team has been of great help over the past weeks and has helped a lot in explaining about nbi... While I was building the installer, 2 other colleagues of mine got interested in OpenMRS and have helped build some parts and want to contribute to OpenMRS code in a larger way!!

I have successfully been able to build an Installer/Uninstaller that can deploy Tomcat/Glassfish, MySQL and the OpenMRS web application on Windows, Linux, OSX, Solaris. The demo data set, JRE/JDK and starting the respective servers are yet to be completed.

Update: The OpenMRS Windows Installer based on Bitrock has been upgraded to install the latest version of OpenMRS. Is it useful for the OpenMRS community to have a cross-platform installer?? Or do the Windows guys only need an Installer ??

Students Review Contest for MySQL & Glassfish

Sun Microsystems has announced a students review contest for MySQL and Glassfish, where students have to develop an application using MySQL and Glassfish. The project has to be part of the java.net website and a review has to be written on MySQL and Glasssfish.

The contest is useful for students who are learning to develop web application and will also help Sun if students get interested in these products. The contest has the following prizes to be won:

  • A chance to win a grand prize of $500 in Visa debit card, and
  • Five chances to win a prize of $250 in Visa debit card

Other than the prizes, students should also be interested in the contest because its a nice learning experience and students will also improve their writing skills by blogging. There is also a certificate that is given to all the winners and its good to show-off you accolades. I won the 2nd prize on the students reviews contest last time and it was an interesting contest to participate.

Chhandomay Mandal manages these student contests and he's very polite and always ready to help. Ask him questions here.

Google Chrome's Beats Others at JavaScript Performance

With Google Chrome released, one of its most awesome features is the excellent JavaScript performance. It is a complete new re-write of the JavaScript VM and uses what is called the V8 Engine by the Google developers who worked on the new JavaScript engine. Here is a JavaScript Performance Analysis for developers to look at comparing different browsers.

Google uses a lot of AJAX and the new V8 engine is the king in JavaScript performance done using Dromaeo :

Browser Time (lower the better)
Chrome 0.2.149.27 488.80ms
Firefox 3.0.1 1775.00ms
Opera 9.52 1767.60ms
Safari 3.1.2 2075.00ms

The memory usage of Chrome is also pretty good and the built-in task manager for looking at the memory/CPU usage of tabs is interesting and useful. It can also help in analyzing which tab is creating some kind of menace or using more memory. You can close that tab and get some free memory. This is just an initial preview, but the JavaScript performance is top-notch!!

Wednesday, August 13, 2008

Netbeans 6.5 Beta Released

Netbeans, “the only IDE that you need” is undergoing a major overhaul and the new version is called Netbeans 6.5. Today after weeks of development and testing, Netbeans passed a few test criteria and has been decided to be stable enough by the Netbeans team to be called a Beta. Now begins the real stabilizing process and ironing out the bugs that remain.

netbeans6.5

Since, I’ve been doing the Netbeans Community Acceptance Testing (NETCAT 6.5) Program, I’ve been closely watching how the entire development has gone through. New features were quickly implemented and each development team co-ordinated with all the quality managers and community to get the best features out in this version. Congratulations to the Netbeans development team on the release and I’m sure a lot of other developers are excited to use the new features.

The following are some noteworthy features, and the complete list can be found here:

1.) PHP – Php support has vastly improved and will ship out-of-the-box with Netbeans, unlike previously where a plugin from the plugin center had to be installed.

2.) Database Tools – The new database tools for designing queries, viewing connections, tables, views, procedures is great. It still a work in progress, but I must say its a pretty good job for a first-time release.

3.) Glassfish v3 has been integrated with Netbeans 6.5 and Glasshfish v3 is surely more sleeker, faster and modular than v2.

4.) There are host of other improvements like Groovy and Grails, SQL Editor Improvements (code completion, save/recall queries, and more), RESTful web services from database tables or from JPA entities, JavaScript debugging on Firefox 2 and IE.

You can download the beta from here and please report any errors that prop up in your work. Enjoy the build and happy coding!!

Friday, July 4, 2008

First Look: Google Test Framework Simplifies Testing

Software Testing is probably one of the most boring and tedious task to a lot of people, but there are still people like me who love writing unit tests. But GoogleTesting among a lot of developers I know, its always the guys from lower-part of the food-chain that write tests. Google has something for testers that will surely make them happy. Google announced today a new Google Testing Framework (GTF) in their Testing Blog.

GTF is a new testing framework for programs written in C++ that Google has open-sourced today. It is a collection of libraries that Google previously used to test their own softwares, but I’m wondering how that could be true, considering Python is Google’s favorite language!! ;-)

But jokes apart, as soon as the new testing framework was released, I set out with a few of my colleagues to test out the framework. We are one of those guys who are excited about testing and ways to simplify testing. The first thing we noticed even before starting with the library was that it was compatible with a host of compilers and versions. We’ve seen a few test frameworks for specific compilers or platforms, but GTF supports Linux, Windows, OSX and host of compilers ranging from gcc to Microsoft’s VC++.

Another excellent thing about the framework was that it’s easy to learn the basics as well has advanced features. Its very similar to xUnit tests and has good features to compare with CppUnit. The basics can be learnt from here and the advanced guide is here. Predicate Assertions are probably one of my favorite features, that we encountered quickly in a program that we were having trouble to debug. There are also a host of other assertions available and we’ve not got into very deep with all the assertions. But from the initial look at the framework, most of us very ranking it as one of the best testing frameworks out there...

There is still some of us who think Boost Framework is very good and some still think Visual Assist plugin tool (of Visual Studio fame) is pretty good. But the first look at Google Testing Framework has definitely made us stand up!

Thursday, June 26, 2008

Barcode Fun With OpenMRS

The Registration Module is supposed to generate Barcode images that will be printed on stickers and given to patients on their ID cards. This will help easier logo  identification of patients and quicker patient registration. For this purpose, we use the “Patient Identifier” to create barcodes. The “Patient Identifier” is hopefully unique and will help create bug-free barcodes.

Barcodes have a lot of different standards like Code39, Code128, UPC-A, UPC-E etc. Each of these standards were designed for a specific industry and application. And the Registration Module should support different standards so that it can be easy for the implementers of OpenMRS to choose any standard that they want. Thus, began my journey to find a way to generate customizable and easy barcodes.

Having just finished with the commit for the barcode generation in my registration module, I am extremely happy to say that Barcode Generation through the Registration Module is very easy. Still have to implement a print dialog box, but then the way to generate barcode is done through a pre-built servlet... I used an open-source barcode library called Barcode4j, which can generate barcodes in a variety of standards as well as image formats.

Barcode4j is an excellent library and after comparing about 15 different barcode libraries, I found it to be the most easy-to-use and extensible. Barcode4j already provides a Java Servlet which needs to be passed different parameters and it generates the barcode image “just-like-that”. The only thing I had to do was create a mapping for the servlet in the modules “config.xml”.

And that was it... Those nice black lines were shown on screen beside the patient search results. Now I needed to see if the barcodes are accurate and working. I took a printout of the image and scanned it through the barcode scanner. Hurray!! It worked!! And thus I realized that the servlet was accurately creating barcodes. Now moving onto creating a nice AJAX print dialog and probably some useful UI for creating identity cards.

Tuesday, June 17, 2008

Windows Beats Linux/OSX at Handwriting

Lately I’ve been trying to code an application which requires some form of natural handwriting recognition. Natural Handwriting is basically the way you write on your Tablet/Pocket PC/Palm/Mobile, either using a stylus on your touch-screen or on the desktop using mouse. And after looking at different options available for handwriting recognition, Windows beats every other operating system including Linux and Mac OSX hands down!!

For the last month or so I’ve tried every possible handwriting recognition software and API out there. Paid, free and open-source API or Programs for Windows, Linux and OSX. Out of all the ones I tried, only one seemed to be perfectly working and easy to develop upon and its from Microsoft. Microsoft has this ultra-amazing API called InkAnalysis, but obviously and sadly for me, works only on Windows. And sad because the application for which I’m developing this handwriting recognition module is a popular open-source kids software and mainly targeted towards Linux distros.

InkAnalysis is a powerful API that performs 2 complementary activities of handwriting recognition and layout classification. InkAnalysis API has very good Interfaces for detecting the layout of any  given document and based on the understanding of the layout it performs handwriting recognition. Even without training it amazingly detects a wide variety of handwriting that even I had a hard time reading as a professor when checking my students’ answer sheets. The API was earlier only available as part of the Windows Vista SDK, but Microsoft has also released the API through the Tablet PC Platform SDK. This means applications that use InkAnalysis API can be run on not only Windows Vista but also Windows XP SP2, SP3 and the future... And the best showcase of the accuracy and strength of the API is through the built-in Windows Vista app called Tablet PC Input (check below screenshot)

TabletInput 

During the trials of all the different APIs and programs, I had high expectations of finding something from Apple that “just works”. With the iPhone they seemed to me like the “touch” geniuses and handwriting would definitely be in touch category. But alas! OSX InkWell isn’t good enough. It makes too many mistakes and correcting them doesn’t work very well. Training or no training it had hard time recognizing natural cursive handwriting. Even the API was pretty complex to use and the didn’t have enough explanation.

OSX

Finally I came back to where I started... Looking for a API that would work with Linux, preferably was open-source licensed. I tried a few and none were close to useable. HRE from Sun was archiac and complex, Tomoe is for Japanese and Chinese script only, LipiTK from HP Labs doesn’t work like advertised and support won’t reply back to emails. Google’s revived Tesseract is only a OCR-engine, good for typed text and not handwriting. OCRopus is also work-in-progress and not working at the moment. With all my hopes down on the project, I finally reached CellWriter. CellWriter seems to be a good working handwriting recognition, but doesn’t work as modestly as InkWell or perfectly as InkAnalysis. CellWriter uses a cell-based, single-character recognizer. It requires training without which it can’t understand much, but once trained is pretty accurate at character recognition. But I tried applying it to multiple cells and it doesn’t quite work. May be a good character recognizer, but not handwriting recognition.

I thus concluded Microsoft is way ahead of the competition on handwriting recognition. Handwritten input system is useful for a lot of people and developers from the open-source community have yet to realize this fact. After all the Vista rant is popular on the web, someone should have seen its good side!!

Monday, June 16, 2008

Improving Java Web Performance With C/C++

From the very first day that I had been working on OpenMRS, I felt that OpenMRS ran a little slower than I expected. Probably the old OpenMRS demo server openmrs_logo adds to the slowness. Later, when we were discussing about how Hibernate sessions should be implemented in OpenMRS and Java Web Apps in general, I was again brought to think about OpenMRS performance.

Since OpenMRS community generally implements on Tomcat, my main aim was to improve performance of the servlet container. One simple way to improve performance, which I had heard of earlier was the use of Apache has the “Apache Portable Runtime” (APR) project with Native Libraries. The APR uses native libraries with JNI to improve the server performance on a specific platform. In short, Tomcat is given some local OS steroids and currently works on Windows and POSIX-based systems.

The APR library is somewhat an irony for 2 main reasons:

  • I’ve heard this argument that Tomcat runs faster than Apache in some benchmarks. These guys argue that Java is faster than C/C++ and hence Tomcat wins.
  • On the other hand, APR and Native Tomcat uses JNI code written in C/C++ to improve performance.

Either ways, I think generalizing the above statements isn’t correct and hence I went forward to see if APR does improve performance of our web application. I used Windows Vista and Tomcat 6.0.16 for the test and Windows is probably what most OpenMRS implementations use. You can download the native binaries for Windows from here & APR from here.  Add the extracted files to Path and place the tcnative-1.dll in APR’s bin folder.

And the first thing I observed tomcat started little faster and even OpenMRS initialized slightly faster.

 
Before
After
OpenMRS initialization 192ms 183ms
Tomcat Server Startup 12892ms 11449ms

But startup improvement is not all. We want to check how good the application is performing and Apache Benchmark (ab) is a good way to test static content, but isn’t very good at dynamic content... I wanted to use Faban after I remembered Scott Oak’s writeup from last year, but couldn’t find enough time for the testing with Faban...

Instead, I used JMeter which is a nice generalized test that replicates how a user interacts with the web application. You can send POST requests with parameters and also simulate your test plan, just like a normal web user would use your application. Here are some of the results on different OpenMRS pages with 10 concurrent requests and average of 3 runs on my dual core server:

 
Without APR
With APR
OpenMRS homepage 225.7ms/request 185.7ms/request
User Login 1464.2ms/request 1185.3ms/request
Find patient 95ms/request 80ms/request
Patient dashboard 2887.6ms/request 1984.3ms/request

My first observation was that the first run on the test completely sucks. The later runs improve performance drastically. This is because of tomcat 6 has good caching mechanism and was shown with or without APR. Another thing I observed was that beyond 500 concurrent users the application was crying and tomcat was hanging up. APR or no APR didn’t matter much... I’ve yet to analyze why it wouldn’t scale any further, but must be something related to Hibernate sessions. May be some experienced developer can look into these figures, perform some more specific benchmarks and improve scalability.