Saturday, December 21, 2013

Back to native

Usually the end of the year is time to take a step back, reflect on the past and plan for the future. For me it is also a time for a change. After 9 years working in Java (SE) I will switch back to C++. So I'll use the opportunity to share some thoughts I have accumulated in recent years.
Generally I avoid being a language zealot (like some of my colleagues ;). For me it is more important to create simple and beautiful solutions leveraging whatever technology is available.

Some say Java tends to be too ceremonial and I would agree on that.
Nowadays the industry has accepted that checked exceptions are not so useful after all.
Proper resource management with all this exception handling feels very clumsy and is definitely inferior compared to the good old RIIA mechanism available in C++.
Some design mistakes from the yearly day of Java are still present for the sake of compatibility. These are things like decorator pattern overuse in stream handling and all these unnecessary methods in Object most of which you rarely use but constantly pay the price for.

It was interesting for me to see how C++ has advanced for the last decade. I see there are many new and useful features C++11. For example lambdas are now part of the standard while in Java they have been delayed for years and are still not present.
The preprocessor and the necessity to use it has always been for me one of the major issues in C++. So I was hoping that this was addressed somehow in the recent evolution of the language. Alas! All these #include and #define directives and the involved text substitution without any awareness of the language feel like a stone age hack. And it is still there.
Even before I started working in Java I thought it would be great if C++ could be compiled to some standard intermediate format. This could improve both compile-time and runtime performance. When you compile to machine instructions ahead-of-time (AOT) you rarely know the exact CPU where the code will run, so you cannot take advantage of new CPU features. I was glad to find recently that there is already a considerable effort in that direction - namely LLVM project even though it is not C/C++ specific.

No comments:

Post a Comment