Friday, June 26, 2015

Can you suggest improvements in Java?

This is one of those abstract questions that often comes across in Java interview questions. More of than not, candidates are not able to give coherent answers to this question. The point to remember is that interviewer is also just fishing. He want to see if you can think through and is suitable for a senior level position.

There is no exact answer to this. At the same time answer to his question might end up impressing the interviewer and give up an upper hand while bargaining the salary.

Here's few things that can be improved in Java. A lot of improvements have come across in Java 1.7 and 1.8. More coming in Java 9 in 2016.

1. Java is slow: One major criticism of Java as compared to C++ is slowness. There has been a lot of discussion on this but nothing much has improved. Would like the JVM speed to be better.
With Java 8 a lot of bootstrapping has been made faster. But more needs to be done. 

2. Uncontrolled Garbage Collection: The Automated Garbage collection tends to make application unresponsive during full gc. My suggestion would be to relinquish some control of Garbage Collection to users. There can be custom gc for those who want control, but for advanced developers, this might aid end result.

3. Pattern Matching support for Switch: Switch now supports Strings, but there is an a need for Groovy/Scala type pattern matching.

4. Reflection: A security nightmare. More than the use, this has potential to be misused. I would do away with reflection API.

5. All is Object: With everything in Java orginating from Object class, I wonder if there any requirement of primitive types. I would do away with them.

6. Date Handling: Every time I want to handle Date in Java, it's pretty confusing. This should be made simpler and straight forward.

Major improvements in Java 7/8
1. Functional programming introduced in Java 8
2. Resources freed automatically, without need to do them in finally. This was improved in Java 7

1 comment: