Java is Getting Old

March 13, 2010 § 1 Comment

For the last 6 months, I have been programming with both Java & Python. Python is new for me. Java is my whole time programming language, its almost 8 years that I do Java programing (since the first years of University). I love Java, I love its huge community which is very important for a programming language success, and finally its greatest IDE ever Eclipse.

However, there is a problem in Java, the language syntax is not evolving, I remember one of the last improvements of Java 1.6 was a new look & feel (Nimbus)! do we need another look & feel? do we need Java for desktop programming? come on Java is dead for this field, focus on your power, the web, backend applications, messaging systems, and what about an addition of some of the things I am proposing here?

I still remember the day Java introduced the for each loop in the Java 1.5 release (which by the way was available for years in other programming languages):

String[] myArray = new String[10];

for ( String str: myArray ) {



This was a very welcomed change, it increased productivity when using collection classes (do you still use an Iterator)? productivity comes from writing less annoying/repetitive code, like getting the Iterator object, doing a while loop, iterating over the collection… bla bla bla.

These are the moments when your brain as programmer turns off, and your fingers does the work (there is no thinking, just annoying code). This was not a very big problem when everybody had to do it this way. but when I got used to the for each loop, I started working on a project developed in Java 1.4. Every time I came to iterate over a Collection frustration increased because I was feeling unproductive (I know that I can use eclipse templates). Steve McConnell in his book Code Complete 2, lists the ratio of high level language statements to equivalent C Code, which shows the weakness of Java productivity compared to Python.

This is exactly what is happening with me after using Python, there are some great syntaxes in Python that I really really really wish Java would introduce in their next release, they are trivial ones, and easy to introduce in the language, but they have a great impact on productivity, I report two of them:

1. Multi line Strings (Block strings)

These are strings that consist of multiple lines, Python supports them using three single ( ‘ ) or double ( ” ) quotations for example, an SQL query string could be written like this in python:

sql = “””

select *

from table1

where table1.col1 = 10


However in Java it is usually done using a StringBuilder/StringBuffer like this (for those who do the same thing with a String don’t do it, they will slow down performance, remember Strings are immutable):

StringBuilder sql = new StringBuilder();

sql.append(“select *”);

sql.append(“from table1”);

sql.append(“where table1.col1 = 10”);

  1. I know you can write it in one line and its still readable, but assume the query is very big and can’t be contained in a line of 120 columns (code readability)
  2. I don’t want to put it in a .properties file, I just want this query string in my code, and I want it to look nice, don’t start with MVC.

2. Array & Collection Operations Using Operators Instead of Methods

A lot of our programming deals with arrays and collections, we get array values using indexes, we get subsets of an array (slicing), we swap items in arrays… etc, again Python beats Java in this too, for example in Java if you want to get the last character of a String you do:

String str = “ABCDEFG”;

char last = str.charAt(str.length() – 1);

Yes it is not rocket science but its frustrating, in python strings are lists of characters so what applies to lists applies to strings too, and getting the last character is like navigating the list backwards, making the code more readable, and faster to write (BTW, the Java code is 65 characters length, while the python one is 30 characters, the HALF):

str = “ABCDEFG”

last = str[-1]

Here are some other operations that can be done in python on any type of lists, which are not supported in Java, I used strings for simplicity:

str = “ABCDEFG”

str1 = str[1:3] #Substring from 1-3 (BC)

str2 = str[ :4] #substring from 0-4 (ABCD)

str3 = str[:-2] #substring up to length -2 (ABCDE)

str4 = str[0::2] #start from 0 and do steps of 2 (ACEG)

str5 = str[::-1] #start from 0 and do -1 steps, in other words invert the string (GFEDCBA)

These are a subset of the most important features that I wish Java will include in their next releases, its really annoying to do these stuff by calling class methods, I don’t care if Object Oriented allows this or not (a String is an object, and slicing should be done by a method) ok let there be a substring method, but I want to extract substrings like python too, its faster, easier, and more readable, and make it up to the programmer to choose between the bulky methods, or the intuitive operators.

One last thing, In this post I mentioned things that Python does in a great way, and that I wish Java will support them, but it doesn’t mean that Python is better than Java, there are many things I hate about python too, the most important one is the decision to use indentation instead of braces ( { ) for code blocks, which drives me crazy, there are many issues in Python too, Nothing is Perfect.

The Road To Java Certification 2

August 28, 2009 § Leave a comment

After getting 90% in the SCJP certificate, I was more hungry for Java certifications, so I decided to take both the SCWCD and SCBCD exams, yes I prepared for both exams in parallel. Why? because my company offered to pay for the SCWCD, and I wanted to get certified as fast as possible and it seemed a bit strange to ask for the SCBCD in the same time, so I decided to buy it by my own, and ask for a refund later (which I didn’t have because I changed company after one week of my certification).

Since I work in the web development field, preparing for the SCWCD was not from zero, I already worked intensively with Servlets, JSPs, JSTL, and other stuff. For the SCBCD I already had a good experience with Hibernate and ORM technologies which helped a bit, but almost zero experience in EJB3 session beans, so preparing for the SCBCD required more time and attention.

Again the first thing to do before starting your study is to know what is the exam about by reading the exam objectives, for both the SCWCD and SCBCD. Pay attention to the business component objectives because there is no complete book that will cover the whole exam material, so you will need to know what stuff to learn, from different sources.

Books to Read
The best book for the SCWCD exam is Head First Servlets & JSP known as HFSJ by Brayan Bashman, Kathy Sierra and Bert Bates. This book is really amazing, it introduces the material in a unique and entertaining way that will make you very enthusiast to read and learn more and more (In this book, Servlets talk with Application Servers, very funny and interesting conversations). There is a mock exam at the end of the book DON’T DO IT before reading the book once or twice, this mock exam is very close to the real one.

For the SCBCD the situation is different, When I did it there was no book dedicated for the exam, so I had to check more carefully the exam objectives and select appropriate chapters from different books, the books I studied for the exam are:

1. Enterprise JavaBeans 3.0.
2. Manning: EJB3 in Action.
3. Pro EJB3.

The first two books would be enough (I just skimmed the Pro EJB3), in addition to these books its highly recommended to read the Mikalai Zaikin study notes, read them after you finished reading at least one book.

Mockup questions
For the SCWCD the mock questions at the end of the HFSJ book are enough, but to get more confidence here are some links:

1. JavaRanch Mock Exam
2. JDiscuss
3. Marcus Green Exam

for the SCBCD exam, I bought the EnthuWare exam simulator, I bought it because there was no complete book that covered the whole material (like the HFSJ for the SCWCD), so I wanted to be more confident. This simulator have something around 400 questions, do them all and you will pass the exam without problems.

Finally as the Java Programmer certification, if you have any question or any doubt just post it on the JavaRanch, there are dedicated forums for each exam.

What You Learned?
After getting certified what changed? the nice thing is that now I better know how to use the technology. But something more important is that now I know how it works from the inside, I know how the Application Server works with those J2EE components. In addition I got stronger web development architecting skills, I can build better and robust architectures for web applications, in addition to portable and distributable applications.

And finally as I mentioned they are other two lines in your CV that will help making you pass recruiters quality filter.

Whats Next?
I didn’t decided yet, but I was thinking of one or two Oracle certifications, but not right now. For now I just want to relax and have fun, no more certifications for 6 months 🙂

Next: Worst 5 Code Snippets Till Now

The Road To Java Certifications 1

August 22, 2009 § Leave a comment

In the dates 08/2008 & 06/2009 I prepared and obtained some Java certifications, I got the Sun Certified Java Programmer (SCJP), the Sun Certified Web Components Developer (SCWCD), and finally the Sun Certified Business Components Developer (SCBCD). In this post I will talk about this experience and how I prepared for these exams.

Why Should I get certified?
This is an important question that you have to answer. For me getting a certification was important for two reasons:

1. Its a paper proof for recruiters that you know the technology.
2. You will gain a deeper understanding in the technology.

The most important is the first point, the IT market is full of competition, if you want to find a good job you have to show that you are better than others, and certifications help doing so. To apply for a job you normally send your CV to recruiters, which in turn filter good CVs from not that good CVs based only on what they see in your CV, your goal is to get your CV pass this filtering process and get called for an interview (where you will show them how you Rock).

Keep in mind that even if you have a certification it doesn’t mean you master that certification technology, working experience is important too. In the end Sun Microsystems will not make passing a certification exam impossible, this is business and if nobody is going to pass certification exams Sun will not sell exam vouchers. So keep in mind that having a certification is good, but not having a certification doesn’t mean you are not good. Bottom line: experience beat certification but certification is a plus.

SCJP Preparation
This is the first serious certification exam provided from Sun Microsystems, actually you can take another exam before SCJP named Sun Certified Java Associate (SCJA) in which you will get questions like:

Q1. Java is a _______________ language. (A)Procedural, (B)Object Oriented, (C)Query.

So get started from SCJP and leave SCJA for marketing people that want to show their colleagues they know Java. Now lets get prepared for the SCJP exam.

Read the SCJP exam objectives
It’s very important to know what are the exam objectives in order to know what to study, and what not to study.

Study Book
The Best book is the Sun Certified Programmer for Java 5 by Katherine Sierra & Bert Bates known as K&B, this is the only book you will need to pass the exam, don’t waste your time reading from other books. The book is well structured, and provides a group of mock questions at the end of each chapter that will help you better understand the concepts. I read this book twice and I felt almost ready for the exam. (WAIT!! you need to do other stuff).

Note: When I did the exam it was for Java 5, however future versions of Java will be available for sure, so you may find the same book for Java 6 (or even Java 11g. Will Oracle name the next version of Java like this?).

Mockup Questions
Its is very important to exercise on mock questions, I found the java inquisition exam simulator very helpful. It seems that inquisition questions are a bit tougher than the real exam, so if you score 70% in inquisition you will for sure pass the real exam (unless you got the 70% by luck). In addition the following links contain some useful questions:

Java Beat
Java Ranch Mock Questions

You Don’t Understand Some Stuff?
If during your study you have some questions and need answers, visit the Java ranch forum, subscribe and post your questions there, you well get almost immediate feedback, they will help you a lot, I may answer some of your questions too 😉

How Much Time Will I Need?
I hate this question, but its always asked. The answer is IT DEPENDS on you, if you have a good experience in Java and you are a fast learning guy you could prepare for the exam in 1 week, you may even pass the exam without studying if you are really good in Java (but do you have to Risk?).

My suggestion is to read the entire K&B book provided above, and do the mock questions after each chapter, and based on your results decide wether you are ready or not.

How to Buy the Exam and Schedule it?
I recommend visiting the SCJP FAQ page in the Java Ranch, you will find many useful information about how to buy the exam voucher, schedule the exam with a prometric center, in addition to a group of links to online mock questions, and other SCJP experiences and success stories.

One final thing, if you search on the internet you will read a lot of successful stories about people who got certified, you will read that John studied 3 days only and got 100%, Mary studied 2 months, half an hour a day and got 98%, yes it is possible but keep in mind that people tend to share their success stories and hide their failures, reading a lot of successful stories around doesn’t mean that everyone passes the exam. You have to prepare well and do your best.

Wish you Good Luck, in your own preparation.

NextThe Road to Java Certification 2

Where Am I?

You are currently browsing the Java category at Omar Al Kababji.