A whole new world
I was just reading the latest 'The Java Specialists' Newsletter' - I am not sure if I have mentioned this newsletter and the name of Dr. Heinz M. Kabutz on this blog before - when I realized how interesting and potentially far reaching implications the usage of Strings can have. I consider myself to be a competent Java developer and I know that if I want to concatenate Strings I should use a StringBuilder or StringBuffer. However, I did not know that I should not synchronize on a String. I probably would not have done it anyway, since some long time ago I've learned to synchronize on an Object instance, but I did not know why I should do it this way. I also did not know what exactly String.intern()is good for. I have seen it many times browsing the Java Docs, but never really took the time to understand it.
Anyways, reading the newsletter I got intrigued and started to surf the net for more information and soon realized how far reaching the simple usage of a String can become and that String manipulation could be the cause of performance problems. This blog entry I found especially interesting - Java String performance. However, I don't think you should refactor all your String usage now. I am a firm believer in profiling before improving, but it is still interesting to keep certain facts about such a simple thing as String usage stored away in some dark corner of your brain.
This little excursion into the world of Strings also reminded me of an article I read a while ago (unfortunately I just cannot dig it up again - maybe someone else can help?). In essence the article tried to answer the question whether all the layers of abstraction we have within the IT world really make it easier, quicker and safer to implement applications. Somehow it does, however each single abstraction is build by humans, meaning it is as prone to error and bugs than the very application you try to write using these abstractions. If you are sitting somewhere at the top of this pile of abstractions and a lower level abstraction fails how possible is it that you are able to understand and fix the problem? Will it not become harder and harder to control all these layers and abstractions. Taking the example of a String - who out there can still explain to me all the layers involved manipulating this string. Starting with the JVM, over to the OS and IO operations all the ways down to CPU registers.