$ thought | blog

Place to serialize my thoughts…

Archive for the ‘Java’ tag

Java: static and transient keywords

with one comment

I came across transient keyword and wanted to get few more details about it. This is one of the most ignored or rarely used keyword by me. It is really funny but, I never really used this keyword extensively. The main reason is, this keyword has a very specific use and most of the applications don't need that for building the business applications. As per info here, when any object state is getting serialized, static and transient variables will be ignored for serialization. Still, Java compiler doesn't give any warning or prohibit from making a variable static and transient at the same time. I don't think this as error but a warning should make more sense in this case.

Written by Sachin

April 20th, 2008 at 9:37 pm

Posted in Java,Programming

Tagged with ,

Update on performance of Scripting languages

with one comment

I wrote a post related to Beanshell and Rhino performance comparison about year ago. I received a comment to that post which talks about Groovy performance comparison which should be attached to these results. The latest performance of Groovy and Beanshell are posted on Groovy list which can be found here.

I will love to spend some time and get results for the latest releases of all the scripting languages. In meantime, there must be some improvement on Rhino and Beanshell side (I hope so :) )!

Written by Sachin

May 22nd, 2007 at 8:30 am

Java on Multicore: Is definately good!

without comments

This is another new discussion topic in Java circle. To get the background for this post you would like this good article. This post has some great comments so don't miss that either. Followed by this and this article. There are different opinions about the topic. I studied Parallel computing & architecture as my graduate studies. So I would like to poke my nose in this topic. ;)

This discussion is circling around GC threads and JavaEE threading model. Although experienced bloggers have already touch length and breadth of the topic, I would like to express my view in this regard. Operating system designers and architects thought a lot about Uniprocessor and Multiprocessor execution methods. There is huge literature present on these topics on public sources. But multicore techniques are relatively new.

Java scales very well on multi-processor servers from long time. Since multi-core is similar to multiprocessor in great sense, there should be increase in performance. Although as Billy mentioned there is GC bottleneck but, that is something can be worked out through JVM only. If JVM can utilize different processor for GC then why not different core?

In addition to that, there are very sophisticated parallel computing algorithms and utilities which may increase the performance by re-writing the existing application or designing new applications to work better on multi-core architectures.

This problem can be worked out and not impossible. If Java is having problem so do all the other monolithic applications which were designed by keeping in mind uniprocessor / unicore architectures.

And there is always option to use libraries like Pervasive Datarush and Javolution to increase application performance without bothering about details of architectures :)

Written by Sachin

December 24th, 2006 at 9:44 am

Posted in Developer,Java

Tagged with ,

Most ignored class of Java!

with 7 comments

I am working with java for more than 5 years. From college to professional life, Java deserved an important position as a programming language. Recently I came across a conversation in my team. One of junior developer used ArrayList to store bean objects. To avoid duplicate objects in the list, he used a simple loop for comparing state of the beans.

I suggested him to use HashSet instead of ArrayList (but forgot to tell how HashSet works ;) !) He just changed data structure and came back to me with a complaint of HashSet not working!!! (This is true! :) )

Then I suggested him to visit API doc for HashSet and then he realized that he also need to override equals() and hashCode() methods from Object class. But all this didn't stop there, he was not clear about implementing hashCode method despite of extensive API doc. It made me think about our ignorance of fundamentals.

Then I continued my search and conducted a short survey with my friends. There are total 11 methods in Java 1.4.2 version of java.lang.Object class. Most of them were not knowing how to implement hashCode() method. I am sure if they needed it badly, they will do as they are talented developers.

I found that people know complete Java Collection hierarchy, they know details of Vector class and Concurrency utilities. They know socket programming and design patterns but they miss Object class in major portion.

We tend to find other ways to implement the functionality which is provided by equals() & hashCode() by introducing extra loops or else. Now I don't wonder if I found few more highly ignored things from Java!

Do you know any similar ignored classes / interfaces?

Written by Sachin

December 23rd, 2006 at 8:13 pm

Posted in Java,Programming

Tagged with

Java: Not so stupid series

with 3 comments

I always read the "Not so stupid questions" series on Java Today. It was becoming difficult for me to keep the questions list. Sometime, you need the questions list and you don't find it; don't you hate that? First thing came to mind was my blog! After all we are supposed to use these tools to organize our personal information; isn't it? Blogs were invented for that,so I thought to make a list as a post and let others find the entire list in one place.

I googled for stupid questions list but I couldn't find a single page enlisting all of them. :( But this problem is not there anymore. You would like to bookmark this page for your reference ;)

(Not So) Stupid Questions series:

Q 01: Should I try to declare more of my methods to be static?

Q 02: Some side-effects of String equality don't make sense

Q 03: Some uses of the private keyword don't make sense.

Q 04: I have no idea when to create a new package and what should go in it.

Q 05: When should I implement an interface, over inheriting from a parent class?

Q 06: How can you justify Dimension java.awt.Component.getMinimumSize() when Dimension does not implement Comparable?

Q 07: There are some weird Java operators I don't understand.

Q 08: What's the deal with serialVersionUID?

Q 09: I'm attending my first JavaOne. What should I plan on?

Q 10: Other than bundling my classes, what good does a JAR do me?

Q 11: I have a question about a Java feature. Who do I ask?

Q 12: Can I use the 'Java' name in an open-source project?

Q 13: Why do constructors have to start with a call to super()?

Q 14: Why is if (true); considered valid Java syntax?

Q 15: How can a constructor be private?

At the time of writing this post, only 15 questions were available. If any additional questions are appeared, I will update the post.

Written by Sachin

December 23rd, 2006 at 2:58 pm

Posted in Articles,Java

Tagged with