When Your Blog Works Against You

February 2nd, 2005

A little while back, Robert Scoble pointed to a job opening as an evangelist at Microsoft.  An evangelist looks like a pretty cushy job to me - flying around the world to conferences and posting on mailing lists and blogs a lot - something to look into becoming when I eventually get sick of coding all day.

Now by the job description I’d say I’m reasonably qualified for such a position and there’s good examples of evangelizing technologies on my blog.  Sadly, most of the technologies I comment positively about are competitors to Microsoft’s offerings and on a number of occasions I may have gone so far as to directly criticize Microsoft.  There appears to be a blog sized hole in my foot…

Someone let me know when Apple, Sun or Apache are hiring evangelists, I might have a better shot at that….

(Note to current employer: no I haven’t been spending my holidays looking for other jobs)

Pop Quiz Answers

February 2nd, 2005

Brian put forward a Java pop quiz and it happens to be an area I know very well:

Without breaking out a compiler, or BeanShell ;-), what is the output from the following:

System.out.println("**" + foo != null ? foo : "NULL" + "**");

 

The statement is equivalent to:

System.out.println(foo);

Why?

The left most + operator is the first thing to be evaluated.  So the if statement then evaluates whether or not "**" + foo is null which it never is and so the value of foo is always output.  Similarly, the "NULL" + "**" may as well have just been "NULL**", in fact the compiler optimizes it to be exactly that as javap shows:

13 ldc #3 <String "NULL**">

 

The lesson to learn from all this is that + is a very high ranking operator and will probably be evaluated first.  The other lesson is that using ?: for if leads to ambiguity and should usually be avoided.