Friday, December 01, 2006

December 1: World AIDS Day!

World AIDS Day, 1 December is an opportunity for people worldwide to unite in the fight against HIV and AIDS. This year, it's up to you, me and us to stop the spread of HIV and end prejudice. (Copied from, read more at

(RED) was created by Bono and Bobby Shriver, Chairman of DATA to raise awareness and money for The Global Fund by teaming up with the world's most iconic brands to produce (PRODUCT)RED branded products. A percentage of each (PRODUCT)RED product sold is given to The Global Fund. The money helps women and children affected by HIV/AIDS in Africa.

What's the meaning of the parentheses or brackets? Well, we call them "the embrace." Each company that becomes (RED) places its logo in this embrace and is then elevated to the power of red. Thus the name -- (PRODUCT)RED.

You, the consumer, can take your purchase to the power of (RED) simply by upgrading your choice. Thus the proposition: (YOU)RED. Be embraced, take your own fine self to the power of (RED). What better way to become a good-looking samaritan?!

(Copied from,

Together WE CAN
STOP the spread of HIV
END HIV prejudice

Related Links at Wikipedia: AIDS, HIV

Tuesday, November 28, 2006

String vs. StringBuffer

Out of the following two ways to create a String, usage B is better and must be preferred over usage A.
Usage A:
String string = new StringBuffer("Left ").append(" Center ").append(" Right").toString();
Usage B:
String string = "Left " + " Center " + " Right";

Wherever there is a need to concatenate long strings, I have seen several people based on their previous experience (!) insist to use StringBuffer. One of my colleagues, is so convinced, that he prefers to use StringBuffer even within the log messages. Now, I have always read that StringBuffer must be used when either there is a need to update the string or the actual string creation is required to be done at the runtime (for e.g. conditional creation of strings). This is because of the fact that String in Java is immutable, hence on every update a new String object needs to be created, thereby making the operation inefficient.

Even though having this feeling for a long time, I was not able to convince much people about this until I was given this link from a friend. After reading the blog, I thought of doing an analysis myself and here is what I found out.

I created a following sample program to find out the variation in the generated byte code:

public class StringPerformanceTest {
public void useString() {
String string = "Left " + " Center " + " Right";

public void useStringBuffer() {
String string = new StringBuffer("Left ").append(" Center ").append(" Right").toString();

Here is the complete byte code of the program (using Java version 1.5.0_06):

public class StringPerformanceTest extends java.lang.Object{
public StringPerformanceTest();
0: aload_0
1: invokespecial #1; //Method java/lang/Object."":()V
4: return

public void useString();
0: ldc #2; //String Left Center Right
2: astore_1
3: return

public void useStringBuffer();
0: new #3; //class java/lang/StringBuffer
3: dup
4: ldc #4; //String Left
6: invokespecial #5; //Method java/lang/StringBuffer."":(Ljava/lang/String;)V
9: ldc #6; //String Center
11: invokevirtual #7; //Method java/lang/StringBuffer.append:(Ljava/lang/String;)Ljava/lang/StringBuffer;
14: ldc #8; //String Right
16: invokevirtual #7; //Method java/lang/StringBuffer.append:(Ljava/lang/String;)Ljava/lang/StringBuffer;
19: invokevirtual #9; //Method java/lang/StringBuffer.toString:()Ljava/lang/String;
22: astore_1
23: return


It is clear from the byte code that on using concatenation operator only 3 instructions will be called (useString), whereas on using StringBuffer number of instructions that shall be executed is much more (useStringBuffer). Besides, against the common thinking, only one object is created even while using concatenation operator.

Performance Concerns

When a String is created using concatenation operators, it is created at the compile time itself, whereas when the String is created using StringBuffer, the strings are created at run-time thereby hitting the performance when there is no need to create them at runtime. More the number of append() calls, more will be the performance hit.

It is better to create strings using concatenation rather than using StringBuffer for the same purpose.

Thursday, September 21, 2006

Back after long time

I am back on my personal blog after a long time. Don't know exactly but I just don't feel like writing on self. However, presently I am trying to play with wiki and learn Groovy.

I have just finished learning about Confluence and now I know quite a bit about using it. Sill need to find time to learn about its advanced features. Once I am done with Groovy, I guess I will be able to use script within confluence.

Today, I was also able to set TiddlyWiki locally and on TiddlySpot.

Sunday, June 04, 2006

CRT: Quality Terminal Emulation for Internet and Intranet

This one is strictly for geeks. If you have never used anything like Telnet or PuTTY then please do not read further as you may get

CRT is a Windows terminal emulator from VanDyke Software. The supported protocols are Telnet, RLogin, and Serial. This is a very easy to use software and is highly customizable.

First of all it features a multi-session tabbed interface which means you can simultaneous have multiple sessions all from one window. Besides, it also lets you customize each tab separately. One great feature is that you may log all sessions (that is not availble is most software I know about). Besides you can easily clone these tabs to make new sessions. Another great feature is that it lets you save your settings and configurations.

CRT also provides a wide range of emulations including VT100, VT102, VT220, ANSI, SCO ANSI, Wyse 50/60, Xterm, and Linux console. Multibyte character sets are supported for Japanese, Korean, and Chinese. Other features include auto logon and SOCKS and generic firewalls.

CRT Homepage:

Saturday, April 01, 2006

Being Cyrus

Yesterday I went to watch Being Cyrus. And what move is that. The acting is fantastic. Saif Ali Khan plays the lead. The plot begins with Saif's childhood and revolved around the thoughts of a man who had a poor childhood. He keeps getting dreams (or were those nightmares) about his childhood and about the people arond him. Dreams that sometime scare him and sometime give him the energy to do what he wants to do.
The direction of movie is very good with beautiful acting from all the actors. Must watch movie.