Double.NaN Is Evil

I don't know what Sun had in mind when creating Double.NaN number. It is very inintuitive to use. I am sure every single developer out there fell in the trap of trying to find out if a double was NaN or not using:
Double.NaN == myDouble


This does not work (I don't know the real reason why), one has to use:
Double.isNaN(myDouble)

Not intuitive!

Grails Spring Union Not Surprising

Looking out at some old post. I found out I was not far from the truth in January 2008 when I stated:“In 2008 the Ruby On Rails mentality will continue to prevail. In the Java world, Grails is the most likely to benefit from it. (…) It could also be something based around Spring as their current MVC solution is not very good and very old fashioned."I don’t think I will be right with the provocative Java is dead. A post recently titled No Future In Java makes some good points about where the future of Java still is: the web applications. Grails is probably today the best contender in the Java world, far ahead from the others, and it leverages the Java developers. However I am not sure one can say that RIA is a fad, or that RIA will only be done in a super powerful browser in the future. Microsoft might be a game changer here. The real advantages of the browser application so far are: easy deployment (the killer argument IMHO), “simple” security. I would not be surprised if in the near future, Microsoft advertises a solution for RIA easily deployed, based on standard protocols (HTTP?), a bit like IBM does with Eclipse RIA, but much more ambitious.

Java Is Dead

These days, I have the feeling that Java is dead. Even if, or maybe because I have used Java so much in the past 10 years, I have this feeling.

In 1998 Java was revolutionary. It was a very simple to learn object oriented language with modern concepts and familiar syntax. Furthermore the standard library had neat features like internet networking and it could be integrated in the browser. All this at a time when the internet just started to be popular.

Today we have very few evolutions, a huge library (with lots of useful and useless stuff in). Some good stuff has been added like concurrent utils, but not many things changed overall. Open source languages like Python are much more dynamic in their library maintenance. The language does not seem to provide anything interesting when compared to the alternatives, like .NET or even with the “scripting languages” like Python. In the browser it has failed where Flash has succeeded.

Lots of things are too complicated to build in Java when compared to other languages. I feel Swing, database access (JDBC), JSP could be vastly improved to help developer productivity. Why is ORM less important in the Microsoft world? because the standard database layer of Microsoft is not as crappy as JDBC. Why don’t they have tons of web frameworks? because ASP.NET is decent, does more than JSP and does not get too much in your way at the same time. Microsoft finds the right balance between library complexity, power and developer friendlyness.

Browser applications are less popular, and desktop apps integrated to a “3-tier” architecture more popular. Java on the desktop is really weak. Give me .NET or QT anytime. There are still no big Java desktop apps on everyday people desktops except Eclipse (IBM has really done an impressive job with it). It is almost 2009 and I still have no Java app except the dev environment for my Java programmer job on my Linux desktop. I know that in my everyday job, I would be more productive with a .NET environment, just because Java sucks so much on the client side. Borland Delphi was more productive 10 years ago!

Java on the Mobile is a failure. Almost nobody uses it and is plagged with compatibility problems. However there is hope here, with Android from Google.

The only advantage of Java compared to .NET is that it is free. You have Tomcat, Glassfish for free. You can deploy on Linux. If you are a poor developer that’s quite an advantage. But most company pay for Java, they want the “security” of an IBM and they deploy on Windows machines. It does not make sense, those companies should buy the better Microsoft stack instead of IBM. And I am sure more and more will. Vista might be the big Microsoft failure, I am sure it will be fixed with Windows 7, and Microsoft dev tools are just getting better and better.

Scala, Groovy, JRuby don’t fix anything, they are just toy programming languages and are based on the JVM, on the Java libraries. In the lot, Scala does better because it has the concept of library, and they do try to build more interesting libraries than Sun. But it is too complex to be ever popular.

All the open source libraries in Java are fine but who needs to choose between 20 web frameworks, 5 loggers, etc.. There are very few really useful ones: hibernate, lucene, jmeter, junit.

If Java has no logical place in most companies, if it does not provide anything more than the alternatives, and is very weak on the desktop, what’s left to Java? the code base and the developers? That’s about it. It sounds a lot like Cobol in the early 90s. Java is dead.

Why ArchLinux Is Better Than Ubuntu

It has been now a week since I have installed ArchLinux on my home computer. I daily use Ubuntu 8.10 at work.

Since the Ubuntu upgrade from 8.04 to 8.10 I have had problems with my Xorg settings. I just found out the nvidia-settings utility does not manage to save the configuration anymore. So I have to lookup on google and try to fix it. And that annoys me. That annoys me because the promess of Ubuntu is that everything works out of the box. In reality, you have to mess with the configuration as much as with ArchLinux.

There are 2 negative points of ArchLinux when compared to Ubuntu:

  • The install on a new computer takes a lot of time (not the 30min of Ubuntu) to have a decent desktop running. It can only be done by people ready to fiddle with config files0. But it is well documented in the Arch wiki. So ArchLinux is definately not newbie oriented.
  • Some proprietary software might not be installed easily. For a long time Oracle was not trivial to install. Now there is an AUR file for it, so it is quite simple.

Now the positive side:

  • good KDE 4.1.3 available
  • more up-to-date packages
  • “transparent” updates - no big breaking the system at each release.
  • learn to use the useful configuration files. They are not many to use in ArchLinux. One feels much more in control on what’s installed and what’s happening. They are not many config files to know in the end. Configuration ends up being no more difficult (for someone not addicted to point and click) than in Ubuntu.
  • fast boot
  • no crap forced upon you, for example PulseAudio. I have less problems with pure ALSA.
  • does not disappoint. You know you have to fiddle with the config from the start.

KDE 4.1.3 (again) on ArchLinux

I tried another silly thing with Linux, ArchLinux. The setup is quite rough as you have to edit many config files manually. But if you know a bit your way around it takes only a few hours to have everything running well. The installation manual on the wiki is detailed enough to correct all eventual mistakes humans do.

I decided to try once more KDE 4 on it, as at first it was just a silly experiment: I was really not sure ArchLinux would be workable. In the end I am pleasantly surprised, KDE 4.1.3 is way way better than any other versions of KDE I have tried before. It is stable and quite pretty. It took the team a lot of time to get there but now I think KDE 4 is a very good window manager, pleasant to use.

It’s a big change from older versions which were too unstable/had too few features to be of any use.

I am not convinced with ArchLinux compared to Ubuntu. The setup is much more complex, less packages are available. True you learn a bit more with ArchLinux. We will see if it can keep working well for a few years.

Stupid Programmer Interviews

I have read a blog post a few days ago about someone thinking a good programmer interview question was:

How does a hash table work?

While it is a very interesting question, I doubt many programmers (even relatively good ones) can answer that question. If I look back and think of all the employees in all the companies I have known, I can count on one hand people that can answer that question. I can think of 3 or 4 I met in one company, and maybe another 1 or 2 in different companies. And I don’t think anyone would have been able to go deeper in the details like mentioning closed-addressed vs open-addressed possible implementations.

I am so negative, because a question about some important details of the inner working of the Java HashMap was raised at work a week ago. I was the only one (because I had read several times about hash tables) to be aware that the equals method of the key object was called every time you do a table.get(xxx) or a table.put(xxx, yyy). Others thought only the hashCode() method was used.

This kind of interview question creates a high bias towards people coming straight out of school if they have Hashtable in their program. For people with more experience, it is highly likely if they ever read about it that they forgot the details (and maybe more than the details).

This can seem shocking as hash tables are used almost everywhere these days, but it’s a reality.

The Art of Multiprocessor Programming Book Review

I don’t remember why I started to subscribe to the Java concurrency-interest list. I find that overall, it is an excellent mailing list.

There was a post at one point about the Dante Inferno’s problem. It triggered my attention, so I decided to buy the book the post was referring to, The Art of Multiprocessor Programming by M Herlihy and N. Shavit.

The books starts with the basics, and is very didactic in its approach. I enjoyed to learn how locks work and how to build them almost out of nothing. The progression is good, starting with a half broken but simple lock and evolving to the more standard algorithm, like the Bakery Lock algorithm. The algorithms are extremely well explained. Later it explains the differences between spin locks (Bakery for example) and blocking locks, while presenting new algorithms for blocking locks. What is described in the many chapters is mainly how to write the javax.concurrency.utils library, why, and what to add to it. Here are the main subjects I found interesting even if they are not always well presented:

  • Bitonic networks: I had not read about it before and I found the subject fascinating. Go and click on the link if you don’t know what I am talking about.
  • Skip Lists: while I found the subject to be very interesting, I found the skip lists were not presented in a very clear manner. I find the wikipedia page about Skip Lists and the original paper much better to understand skip lists. Fortunately the authors talk about how to make it more concurrent friendly, and that part is well explained.
  • Software transactional memory: I have the same opinion than with skip list, except the wikipedia page is very short on details, and the book does give much more details. We feel it is the end of the book and the authors took less time to present it an easily understandable manner. One need to read the chapter several times or to have read before about it to really understand.

I like books that make me learn new concepts. In The Art of Multiprocessor Programming, there are plenty of concepts, ideas I had never heard about before, even though most of it is probably well known to specialists in the field. So even if some rare subjects could be presented better, I recommend that book to anybody interested in concurrent programming.

OO Desillusion

I have read many inspiring books about object oriented programming. I find B. Meyer Object Oriented Software Construction one of the best in the lot. B. Meyer tries to explain in a progressive way why OO is better, by introducing it bit by bit. I have read different related design patterns book, the GoF one, Martin Fowler ones. I have been programming Java for about 10 years now. And yet, today, I feel unconvinced.

Maybe it is because I have been recently on different bigger projects, maybe it is because I have worked with different people. What I see today, is a tendency to overcomplexity. A simple example is you need a code to do only 3 different things in particular cases. Instead of using if-then-else, because it reminds you of the devils of procedural programming, you write 3 classes and 1 interface. Now the usual excuse for such a behavior is to say, we don’t know, maybe there will be a 4th one, my code will make it easy to handle the 4th one. Often when there are requirements change, you don’t expect at all where it will be, and it is not what a developer thought would change that actually changes. So the dev with the 3 classes has now to change its interface, update the 3 classes, and create a 4th one. The “procedural” guy has no such problem because he did not try to abstract something that did not need any abstraction in the first place.

Now on millions lines of code software, it is important to have a few basic principles in the overall design, to identify components that talk to each other, to define a global structure. But at the developer dimension, there is often no need for that, except in the few cases where it makes sense.

I do use design patterns sometimes, when I feel it is the simplest flexible way, but it is quite rare overall. There are 2 common jokes about design patterns. One is from people who don’t know what they are. They often take the piss of architects doing design patterns all the time that in the end don’t really know how to do things and spend a lot of time and money on crap. Other is from Pythonists and Rubyists. They say that you do not need design patterns if the language is done right.

The Java language, with the Generics, and the propositions for Java 7 is also evolving in the overcomplex side (ok, the Generics are probably much worse than Java 7 propositions). Soon people will be more confortable reading Haskell. Joke aside, Haskell while being different to read, has really something for it. It brings a new way of writing programs, moves the complexity somewhere else.

I still think lots of ideas in B. Meyer book are valid today. But an essential part must be missing. Overdesign seems to be too recurrent in OO projects.

Linus vs OpenBSD

Today’s popular story is Linus Torvalds message to OpenBSD where he writes:

I think the OpenBSD crowd is a bunch of masturbating monkeys

Beside that provoking sentence he has a valid point. Security bugs should not be more important than other bugs. Too often, management and psychology encourage making security bugs a very important issue and security people VIPs. I have seen this over and over.

Suse 11 with KDE4

I was very disappointed by KDE 4.0 when I first tried it on an ubuntu machine. It was just unusable. I would not have even considered it as a beta.

I changed the system on my home laptop because Ubuntu with KDE 4 was there. I decided to go for something more roots. I had good memories of Gentoo when I tried it some years ago. Maybe I just became too old to appreciate it anymore. But after spending several hours on a Grub error 2 problem, seeing the live CD does not even use grub so you can’t use the CD to boot from hard drive and fix the problem easily, wondering if the problem was a problematic Grub version with my drive or not (I never had problems with Grub and other distros on that same machine before), I decided to install OpenSuse 11.

I was surprised (and impressed by Suse) that KDE 4.xx shipped with OpenSuse was usable! Except the program menu, it’s not worse than KDE 3.

Previous

Next