Older blog entries for pcolijn (starting at number 125)

RSS

So RSS is quickly becoming the new hotness. I've been using Google Reader lately to read PlaNit, Slashdot, and whatever else tickles my fancy. It's quite nice, and I can read my news anywhere (both an advantage and a disadvantage, I suppose).

However, none of the common blogging tools seem to be able to do upgrades or migrations in an RSS-friendly way. It seems almost every day, somebody on Planet GNOME upgrades their blog, and all their entries appear at the top. It's enough to make me want to write my own bloody agregator that isn't so braindead. Or at least fix Google's, the next time I'm there :)

In other news, we're all doomed.

Politics

Lots of people have been talking about this, so I'll try to keep it short. I watched the English debate (didn't have time to catch the French one, unfortunately). The take away was that Harper seemed calm, Martin and Layton seemed desperate, and Duceppe was, as usual, the most intelligent of the bunch. Too bad he wants to tear apart the country. The thing that really bugs me about the Conservative campaign is that they've totally steered clear of all their stupid social policies on things like same-sex marriage and abortion. While it's politically a good strategy, it's just slimy not to talk about that stuff to get in, and then try to do it later. The prospect of a Con minority actually wouldn't bother me that much if it weren't for their wacko religious redneck leanings. Don't believe me? Dude, I grew up in Alberta. I've met Preston Manning, spoken with Con candidates in Calgary, and believe me, it's rough. You have to remember that these aren't the same Tories we used to have. They're mostly Reform now. For an example of where "traditional" Tories stand, see Belinda Stronach.

On Java, continued

apenwarr: You're correct that it's definitely possible (and reasonable) to have an immutable base class (interface), and a mutable subclass (subinterface) that extends it. That is indeed how I would write things normally. Unfortunately, that is not the convention in Java. The Collections API doesn't do it that way, and it has become the "accepted norm" to have one main interface, for which certain operations will be unsupported. The main reason for this, as explained to me by on of the main implementors of Java who now works at Google, is that when people tried to do the immutable base class thing, codebases just became too unruly. Aggravated, of course, by Java's requirement that class Foo be in Foo.java and not any other file. I suppose that's more a complaint about the conventions than the language. Still just as annoying, however:

Collection<String> getStringList();

You might think, for example, that it would be perfectly valid to do getStringList().add("foo");. However, getStringList() is just an accessor and may very well return an implementation of Collection that does not support add() (and the compiler would never warn you in that case, because the exception thrown is unchecked). Even worse is the so-called "defensive copying pattern," where getStringList() will allocate a new Collection<String>, copying everything into it and then returning the new collection. In that case everything is slower just to protect against the possibility that someone wants to modify your collection, and your code will compile and run absolutely fine but do something completely unexpected. So you're right, there's a sensible way to do things, but large parts of the JDK (which isn't technically part of the language, but is so heavily used it might as well be) do things badly, so it's still a major annoyance. Finally, a "const Foo" makes more sense to me than having both ImmutableFoo and Foo, and it's less boilerplate, so I still argue that C++'s const concept is superior to separate mutable/immutable interfaces in Java. And of course, in C++ you get the choice; you can do either.

As far as GC is concerned, I agree that you have to think about object lifecycles. You always do, and you're right that some people interpret GC as a "free lunch" not to think about things any more. I don't have a good solution for that, but I would still argue that GC is valuable in Java in a lot of cases, in particular for short-lived objects that are larger than you'd typically want to allocate on the stack. In my experience, a lot of objects fall into this category, so GC is valuable. Of course that varies depending on the type of software you are developing.

I haven't heard of people using object pools too much in Java, and never saw any code that did that myself, so I don't think allocation and constructor-invocation time is much of a worry (even it was perhaps in the past).

Oops. I originally posted this a while ago, but forgot to update Advogato.

Holidays n'at

Holidays were good. Extremely busy, but good. I hate Christmas shopping more and more each year. The thing is I'm not a "gift card" kind of person. I just don't like it, it's barely better than giving money. There's a lot to be said for really thinking about someone you know, and what they'd like. It's a good contrast to the rest of the year, when most people are thinking "me me me," and I think the whole gift card phenomenon is basically a cop-out. Of course, when you do decide to actually get gifts for everyone, it gets much more time consuming. But it worked itself out in the end; people seemed to like the gifts I got them.

Owen and Shane at the fiddle, New Year's eve

Waterloo

Back in the 'loo now. This place just has a way of sucking the life right out of you. Between the dreary days and spending lots of time in MC, it's enough to make you just feel tired and apathetic all the time. Hoh well, only 4 more months and then this stinkin' town can kiss my ass.

On Java

So I spent a fair bit of my last term coding (gasp!) Java. To be sure, there was a fair amount of C++, Python, Perl and even some more Ruby. But the majority of my work was in Java. Java gets lots of C++ fanboys screaming about how it sucks because it's slow or it has GC or it doesn't have pointers. I'm not going to take the fanboy approach, but will instead, for your amusement (or horror, depending on how you see it) describe my "hit list" for Java.

There's no const. The way this is typically worked-around is using interfaces. Let's say you have the interface IFoo. You write an implementation UnmodifiableFoo that wraps an IFoo and throws UnsupportedOperationException for all the mutation operations (BTW, this is the decorator design pattern). What's wrong with this? First, you have to write UnmodifiableFoo yourself, which is of course error-prone. Second, because UnsupportedOperationException is an unchecked exception, there will likely be lots of code out there that calls the mutation operations without catching that exception. So you pass an UnmodifiableFoo into a method taking an IFoo, the compiler happily does that for you, and things blow up at runtime. You can't throw a checked exception without changing the interface, so basically you're hosed if you want to try to add immutable implementations after writing the interface. In C++, the contract of the method that the compiler checks can specify that it wants a non-const reference because it will be doing mutations. AFAIK, there is no way to have the Java compiler do anything similar for you.

References are not explicit. This is easy to get used to, but it inevitably confuses newcomers. Also, there's no way to have a reference to a primitive type (most of what you want that for is accomplished with "out" parameters in C#).

While C++ has them as well, exceptions are much more heavily used in Java. I tend to prefer return codes. The argument for exceptions is that you force the programmer to do something when an exceptional condition occurs. In fact, you do not:

try { methodThatThrowsStupidException(); } catch (StupidException ex) { }

Sure, you made them write a catch block. Who cares? The other thing that inevitably occurs is that programmers, fed up with writing try and catch blocks, inevitably end up having gigantic, 500-line try blocks. Then when an exception occurs, you have no real idea what went wrong. I guess I prefer return codes because I feel that it's pretty easy to tell by looking at the code whether you're checking them or not. Exceptions essentially de-localise error-handling code, and I don't like that.

Finally, the generics in Java leave a lot to be desired. I've written about this before so I won't go into the gory details here. Suffice it to say that writing a generic class in Java can be quite the pain in the rump.

Now, I know I promised that I'd steer clear of "fanboy" tactics, but I actually will say something about GC. It's not appropriate in a lot of situations, like embedded or real-time systems, but I do think that C++ programmers spend way too much time tracking down segfaults and memory corruption. Of course I agree with Joel that it's important to understand pointers and have experience debugging that kind of thing. But so much time is spent tracking these things down, and it's only when you have good common practices (smart pointers, or auto_free semantics, or whatever else) and your development team adheres to them religiously that it becomes much less worrisome. Since most projects end up using external code and add new programmers, that situation of common best practices and strict adherence is extremely rare, so the memory management problem remains a big one, and GC is one solution that is appropriate in many situations.

Stupid Country

So normally, even though I am in a rather stupid country led by a rather stupid leader, things aren't too bad since northern California is one of the most liberal areas of the country, and Googlers tend to be pretty forward-thinking too (sorta comes with the territory).

However, every once in a while something happens to remind me that this country really is incredibly fucked up. This evening, I'm biking home from work, like I always do. I happen to have laundry with me, because we do that at Google. All of a sudden I get stopped by a cop.

He explains to me that there's been a burglary near by and he just wants to ask me a few questions. Fine; I show him my driver's license, my work badge, explain that all that's in my backpack is laundry and let him look through it. Then he calls another cop, who arrives and asks me the same questions again. Then, out of the blue, they become very interested in my shoes. Then a third cop comes to examine said shoes. At this point I'm doing everything I can to contain my laughter. Here are 3 cops, looking at my fucking shoes at 1am, while the actual robber (if indeed there was one) is long gone.

But what's even worse is that cops around here actually do crap like this. This is the third time I've been stopped because there has been a "robbery near by." It just seems so bizarre to me that the cops have nothing better to do than drive around the office parks of Mountain View, CA protecting random companies from buglaries. I mean, isn't that what people buy insurance and install security systems for? Meanwhile, across the bay there are probably people shooting each other in Oakland. Like I say, fucked up country.

Pure Genius

So I get some email from mrwise, and what ads does Gmail decide to show me? Why, ads for fart machines of course! Classic.

Madness

So my recent insane thought began with looking at meebo and being impressed with how well they've essentially implemented a window manager and various widgets in DHTML and JavaScript.

Then, in recent days, I came across all kinds of crap like this where people are constantly tweaking various widgets in JavaScript to make the onchange handler less annoying in IE or make select drop-downs nicer in FireFox or what-have-you.

So what you have is some very impressive, rich applications on the Web that all behave wildly inconsistenly because one dude likes the IE select behaviour so he tweaked it to work that way in FireFox and another guy likes his checkboxes inverted so he tweaked the onchange handler, etc.

So then my thought was "we need a toolkit for JavaScript." Yeah, big whoop, everybody and their dog has said that and claimed it to be some kind of sweeping revelation. But what if we made things a little more interesting and implemented an existing toolkit in JavaScript? Like, say, GTK? I am going to step down to the level of various technology pundits (*cough* Dvorak *cough*) and make a bold declaration:

It's time we stop playing around with web pages and start developing software for the web.

If that didn't make you gag, I don't know what will.

Terminal "speed"

behdad writes about optimising gnome-terminal. He won't get any complaints from me, but I don't think the comparison with xterm is all that useful:

  • A bitmap font is used in xterm, while a TrueType (and likely anti-aliased) font is used in gnome-terminal. Clearly the anti-aliasing impacts performance.
  • There is no treatment of how often each terminal is updating. I can make gnome-terminal appear to be screaming fast compared to xterm in this test simply by having it update the screen far less often. This is partially a usability question; when you can't keep up, how often do you update? There's no clear answer, unfortunately.
  • I don't think people care particularly how fast their terminal is while minimised (at the very least, it's secondary when it comes to optimising).
  • There was no treatment of memory usage per terminal window, which is important when you want to have lots of terminals open. For a while (GNOME 2.2 days) gnome-terminal ate up a good few MB for every open terminal, which is not exactly friendly. I don't know how it is these days.
Jar Jar Binks

So when drheld, mag and I lived here last term, we were dismayed to discover a Jar Jar Binks dancing toy on the porch of the house. We had no idea whose it is, but it worked; if you pushed a button on it Jar Jar would without fail do a little dance for you.

It's still here this term, and what's more, its batteries still haven't died. To allow the rest of the world to enjoy this wonder of technology, we uploaded a video of it to Google Video. (Flash required, unfortunately.)

Meebo

This thing is pretty bloody cool. AIM, ICQ, MSN and Jabber all in a (non-sucky!) web client, for free. These guys even implemented a window manager in HTML. Best part: no annoying GAIM popups! Yay! Anyway, give it a try; you'll be amazed how good it actually is for a web-based IM client.

116 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!