Search This Blog

Thursday, October 28, 2010

JCP

I guess that given what has happened the last months what has happened in the Java world it seems like finally the ember have ignited.

and finally one of the most important contributors and JCP EC members, Doug Lea leaves the JCP.

Im not including the fact that Sun/Oracle haven't managed to squeeze out a new Java release (JDK) from its hairy womb for almost 5 years. And the one that is worked on is been deferred to 2012.

I read the response from Henrik Ståhl, since it is my old colleague, my views might be slightly skewed. But I think I sense that he affirms my belief that Lea's response was one of haste. Now more than ever the JCP needs strong figures with strong ideas. I cannot find a single person right now in the EC. Which will fill Lea's shoes.

In fact, I don't think it is possible to develop software under the Committee form as it is done right now in Java. There is another software language being developed under a committee, C++ and look how great they are doing.

Instead it would have been better if Sun/Oracle chosen the Microsoft path. Microsoft assigned Anders Hjelsberg to be the dictator of C# and to some extent the CLR. And it is clearly visible in terms of the direction of the platform. When Java been bickering and missing the entire mulitcore train. The CLR have built-in parallel support for operating on datasets into the CLR. Java has spawned products like Scala, Clojure... But they are two many steps removed from the hardware to make the right decisions, like cache locality.

It would be better for Java if Oracle appointed an emperor of Java to rule the ecosystem and make the right decision.

Saturday, October 23, 2010

Great for Java and Apple

Apple announcing that they are not interested in maintaining Java anymore couldn't be better news for Java. As everyone knows that worked with Java on OSX knows it is a horror story. The release is probably the buggiest versions of Java I've been working with.
Apple, have never really understood or been interested in understanding Servers or server side programming.

For example, I had installed a 1G Ethernet at home, made sure that all switches and hubs actually were 1G. My MacPro had its 2 port 1G Ethernet card which i hocked up booth ports so that I would be able to do VPN and run on the local network at the same time. However network test after network test, showed embarrassingly slow. I managed to reach 30 MB/s where the theoretical limit lays around 120 MB/s. The OSX kernel is so badly written when it comes to networking it should really put a red face on Jobs, when he says that the latest machine is 'Amazingly fast'. Threading is another is even a sadder story.

I think that the point in time is critical for this being good news for Java developers. When 20% of all sold PCs is a Mac. I wonder how high that number is for the high-end PCs, the ones developers often buys. I doubt it is anything but higher, a lot higher!

So why is this critical? If you've ever been to a Java developer conference you'll quickly see that 70-80% of all laptops have an eaten apple on it. If Oracle would not pick up the ball, it would probably leave a huge part of the developer community looking at other languages. With all the things happening (or the things that never seems to happen like Java 7, closures etc) in the Java world it is certainly not the time to force developers to choose between OSX and Java.

I do not think that many would abandon their favorite hardware/OS for Java. Even though the lousy server properties of the Mac. Oracle cannot afford to alienate their biggest developer group, even though they are not using any of the Oracle operating systems.

It would be reasonable to think that Apple will 'give' the AWT code for Cocoa. If that would be the case a Java version on OSX made by Oracle could be released in 6-12 months.
However if Apple for some reason would not give the source to Oracle. I think there is a significantly longer time to release.
Which may be acceptable by developers, since the majority of Java developer are using Eclipse anyways. It is far from the ubiquitous Java model. But if Oracle were to release a headless version of Java for OSX, Eclipse would still maintain SWT for it.

It is certainly interesting times!

Wednesday, October 20, 2010

The sixsided machine

Short commute today, working from the Nashua office which has its benefits.

For one, I don't have to sit and wait for 25 minutes where Rte 3 meets 495 and the five lanes converge into 3 lanes.

Working here though is sometimes a bit depressive. The office filled by engineers that been working for the same company their entire lives. Well that is not completely true, they were acquired 20 years ago. When this other huge computer company disintegrated and was chomped up by hungrier sharks.

The atmosphere is very much the one of a sealed off cave, people have been working independently more or less from the rest of the company on the west coast. Their own products stopped selling long time ago so now all the engineers are working on either supporting what they once created or are sent of working for other teams. You can find the most interesting books on shelves on software that were designed in an era where one didn't have to worry about the bottlenecks introduced by the Internet. No one is really interested in doing anything new and management is only trying to maintain their headcount.

For the ones who have seen Office Space, this place is the same, it looks the same, there is the same sets of people who's only contribution is that they have 'People skills'. Or rather they know people from having been employed at the same company for 20 plus years or so.

Anyways, the reason I'm here is to discuss the latest marvel a box with so much computing power no one knows how to utilize it. It brings back memories of when I got my first Amiga, which had a palette of 4096 colors, coming from a computer with 16 colors it seems insane to have that much colors. This computer though is as big as a regular refrigerator and the amount of memory that this machine packs is mind-boggling. The only problem is that we don't quite know how to use it yet.

I read this post about Azuls Zing launch where the conclusion was

"The result is that the 11U Vega appliances could do the JVM work of somewhere between hundreds and thousands of physical servers running a Java stack. And yes, a lot of people thought these performance gains were just not possible."

I certainly belong to the group of people who have a hard time to understand how that statement can be true. Also it seems to miss the elephant in the room, the high availability (HA for short). I dearly would like to see the models how HA is calculated for a monolithic box like this. Scaling is easy, scaling safely is almost impossible.

Tuesday, October 19, 2010

Coding Standards

Is there anything that is more religiously charged in a normally atheist world as Coding standards in the Software industry?

So I was in this discussion today about modernizing our style or at least make it more available to all the engineers working on the product. The modernizing, steams from the fact that the coding standard was developed 15 years ago, when Java was still in its cradle. No IDEs existed yet and no one even considered a Java coding standard.

I guess historically most Java developers came from C++, hence it became natural to use the same habits. Therefore our coding standard contains remains of these habits. Like fields are prepended with 'm_'. Fields/local and arguments use some pseudo-hungarian notation to indicate the use and type of variables and constants. Some examples being:
  • c for counters like 'int Foo'
  • i for integer like 'int iFoo'
  • a for arrays like 'int[] aFoo'
The list is long and for a developer that left C and went into the Java world it seems strange that this denotation is needed in a highly typed object oriented language like Java. Personally I can only remember one good reason for employ hungarian notation.

For those who remember the hassle of dealing with strings in C, I would like you to recollect BSTR (Binary strings) and char*. One is zero terminated by a single char '/0' the other includes the length in the first 4 bytes and is zero terminated by two characters '/0/0'.

Since any real world program would contain both types of strings it made perfect sense to use some notation of indicate what type of string was dealt with:
  • bstrMyString for BSTR*
  • pszMyString for char*
However Java, in a world were the IDE provides amazing mind boggling re-factoring functions and incredible code navigation. Something I never thought possible when I ran my first IDE (Seka assembler for those who are nerdy enough to know). I'm going to generalize a bit here so hang on. There is no need since all Java types are equal, all are references to something on the heap. Everything derives from Object. I hold my mouse over the field and can see, comments and declaration. Furthermore if I would try to pass a field or local into something that wouldn't accept that particular type I see it immediately.

Another interesting argument is that we want to be able to see what type a field is directly from its name. Since we are using the normal Java Bean pattern, it doesn't really work though:

public int getFoo()
{
return m_iFoo;
}

int iFoo = m_iFoo; // fine and dandy
int iFoo = getFoo(); // how can we be sure what getFoo() returns an int


The argument to keep hungarian notation in Java is and will always be about religion and out of sentimental reasons. One factor could be that cosmetically the code looks more advanced more like C code? I cannot explain it in any rational terms though.

Anyways, the commute went fine today, the first couple of miles took 40 min though because of some accident at 128/rte 3. which meant that I missed my sons baseball game tonight.

Lower and Upper Generics

Every one that been using Java for some time have run into generics. Having worked on building a JVM for seven years I thought that I knew all about them. I guess I could blame the fact on that almost all type information is erased by the time the byte code comes to the JVM.

So the other day I got a question from a colleague at work about a syntax. He is working on a new API and would like to make use of generics. He drew three different declarations

public Bus getBus();

public Bus<? extends T> getBus();

public Bus <? super T> getBus();

I scratched my head and said I defiantly knew about the first two. First is the Exact Bound, meaning T and only T, no super type of T (Object) or derived version of T (T'). Will be returned by the getBus() property.

Second option, ? extends T, meaning T and all it's derivatives (T', T'') etc. But not Object or any super type of T. What normally is declared as Upper Bound. All types that implements or extends T qualify as type argument.

The third one, I'd never seen before. The third one didn't make any sense. I asked him if it compiled and he answered back that it did.
Logically the syntax would imply that anything that T is derived of would be allowed to be returned by the method. Reasonably this syntax must be called Lower Bound as the covariant version of Bus is normally called Upper Bound.

The other interesting part of the syntax is that it only seems to apply to the initialization of a variable/field/return i.e. a reference. As soon as the reference is used the Upper Bound rules apply. Example take the following hierarchy:

public static class Super

{

}


public static class Foo extends Super

{

}


public static class Bar extends Foo

{

}


Then the following does not compile

List <? super T> Foo list = new ArrayList();


list.add(new Super()); // error


list.add(new Object()); // error


Which the syntax List<? super Foo> list seems to imply. That, whatever is being assigned to list needs to be instantiated with a super type of T (in the example Foo). So it cannot be assigned an ArrayList of Bar for example.

list = new ArrayList<Bar>();


Does not compile! When using a Lower bound generics however like the supplied type must be of the same type or derivative of the type.