Archive for March, 2005

Effort and ease of reading

Thursday, March 31st, 2005

Anyway, on to the point I am trying to make: programmming Python is a breeze, you can use any simple editor (preferrably with auto-indent) and happily code away. You can get serious stuff done this way, perhaps you’d need some way to handle multiple files in a nice way, but most graphical editors can do that.

Boy, is this different when you want to do serious programming in Java. You need to type lots more and need to make more of an effort before you can do interesting stuff.

All the typing you have to do to get things done, is inversely correlated to the ease of reading code. If you read Python, it doesn’t take very long to see what it means. This is partly because it is strict in using indentation as part of the syntax, but also because of the terseness of your commands.

This is very well illustrated in an example that Tim Bray mentioned in his blog. There he points at a website of a 16 year old kid from Norway who explained an amazing new idea to do Continuations on the Web (webpage seems to have been pushed offline, here’s the Google Cache version).
Imagine that that idea would be implemented in Java. Then it would a) be a lot more code and b) it would take more typing from him to explain what it does and c) it would take more energy for the reader to understand all this. Now I’m not saying that the fact that it is in Ruby makes it easy, but it sure makes it easier to read and understand.

And especially point c above makes you wonder why we’re bothering with Java anyway. Isn’t the whole idea about programming languages to make the computer do work for you?

Bit of background for this rant

Since about a year ago, I’ve been learning Python. But because I was developping stuff with webservices, I thought it might be nicer and easier to do in Java, also because the rest of the group here is developping in Java as well.
Learning Java all over again was interesting (last time I did anything with Java was in 1996 - 1997). Java 5.0 has interesting new stuff like generic programming, a foreach loop and introspection. Basically just stuff that every other programming language has, but Java has to make some effort to make it all work because of backward compatibility. I don’t mind this at all, it’s understandable and very commendable that they try to keep this much compatibility with the old versions.

Perhaps it’s my Python background, but lists are essential tools and making a list in Java is really really annoying. It’s better in Java 5.0, where you can do generic programming and write a generic list class, but my beloved Powerbook has 10.3.8 on it and there’s no Java 5.0 for it. We’ll just have to wait till Tiger comes along…

Another thing that bothers me about Java is that you need a good IDE for it if you want to reach the speed of development like with Python. Eclipse comes a long way (in fact there are plugins to use it for Python as well) and really helps with writing common things (accessors, constructors, etc). But the amount of typing you have to do is huge, especially compared to Python.

Pre-2005 Powerbook & Two finger scrolling

Monday, March 21st, 2005

I am the very happy owner of a pre-2005 15” powerbook. And until recently I used SideTrack to scroll using the mousepad. But recently Daniel Becker was smart enough to download Apples’ (old) mousedriver (covered by the APSL) and hacked in support for two-finger scrolling.

This works beautifully in most apps, but the non-nativeness of Firefox and Thunderbird unfortunately shows badly with scrolling in this way.

If you use these and want scrolling with your trackpad, then you best use the following settings. In Firefox, type about:config in the address bar and change the following settings:

  • For vertical scrolling:
    • Set mousewheel.withnokey.sysnumlines to false.

      In Windows there is a system wide setting for the number of lines to scroll. For some reason Firefox seems unable to cope coherently with the OS X settings and scrolling makes it seem like a nervous fox on speed. This setting makes Firefox use the following setting regarding the scrolling speed.

    • Play around with mousewheel.withnokey.numlines (bigger is faster), it takes effect immediately, so it’s easy to do. I have set it to 2.
  • For horizontal scrolling:
    • Set mousewheel.horizscroll.withnokey.action to 0.

      The default behavior for horizontal scrolling is forward/backward. While this may make sense for a regular mouse, it makes for very flaky behavior with a scrolling mousepad.

    • There is also the horizontal counterpart for the scrollingspeed: mousewheel.horizscroll.withnokey.numlines, which I have set to 3.

These same settings can be set in Thunderbird, but you need the about:config plugin to set these settings.

The Case of the Terminal(.app) Backspace

Friday, March 18th, 2005

Terminal.app in OS X is pretty nice. Nice looking terminal application with neat dragging and dropping support in OS X. But once in a while it drives me completely nuts when I use it to log into and start typing commands at the command prompt and editting stuff in vim. For some reason I can only get backspace to work on the command prompt or in vim, not both!. Fiddling with the “Delete key sends backspace” option alternates between those two behaviors.

Googling led me to the following rant of someone with the same problem. In the end, he suggested setting $TERM to xterm. This doesn’t do the trick for me, I had to go in and change the configuration of vim as well. Once I added the line: set term=ansi to my .vimrc I could go on with editting again.

I have the feeling that something is wrong there and someone at Apple should fix this. If I have some time in the future, I’ll try to dig into this more deeply and figure out why it is going wrong there.

Blosxom Configuration

Wednesday, March 16th, 2005

As promised earlier I would explain the configuration of this blog. The initial interest for Blosxom was made because someone I know already uses it. This however only made me curious about it and I went to investigate. Browsing through the site, I found a plethora of plugins and some very good documentation on how to install it. And (last but not least) it’s open source! So the choice was made.

After the initial walkthrough of the documentation, I had a bare, working blog, but it did not look very nice. So I set out to chance some stuff here and there, and make it conform to XHTML 1.0 Strict, because in my experience this is the HTML standard that all (serious) browsers understand and agree upon. This is reasonably simple, because Blosxom works with templates and every page is created on demand, using the flavour(e.g. html, rss) user requested. This means an almost ultimate seperation between content and representation, which follows nicely with the philosophy of XHTML 1.0 Strict and CSS. Anyway, enough ranting about that, onto the gory technical details.

The flavour I use is available here(.tgz). There’s some references to plugins there and some other plugins I use are:

  • SmartyPants - does some nice typographic conversion on quotes, etc.
  • antispam - automatically translates email addresses in blog-entries
  • breadcrumbs - provides a nice trail of categories when you select a category or specific entry
  • calendar - the calendar on the right. This is however an old version, because I dislike the new one even more than I do this. I want more control on the HTML codes of the calendar output and it just wants to provide me a preformed block and some useless other accessor functions with which I can’t build the same output.
  • categorytree - enables you to make a nice category tree, will create a page for that in the future.
  • date_fullname - makes nicely formed dates with full names of weekdays and monthdays
  • hotlists - makes a ‘hot’list of recent entries, suffers from the same problem as calendar
  • rss10 - should provide me with a RSS 1.0 feed, but haven’t been able to make this work yet.
  • seemore - allows me to split up long entries (like this one) (newest version doesn’t seem to work yet)

I couldn’t really find a nice way to do comments and writebacks/trackbacks with Blosxom, so instead I opted for using Haloscan. They allow you to create an account, use some bits of javascript and then you have instant comments and trackbacks for every blog entry, without any extra work on your end.

Concluding, Blosxom is very nice and flexible, but I’m getting the feeling that development on Blosxom has bled to death a bit. Because the website hasn’t been updated in a while, the creators weblog has not been updated in a while and most plugins at the website don’t seem to be in active development anymore either. Oh well, can’t complain, it’s a nice tool and not very complicated, might be a nice incentive to learn some more Perl (ugh! (1)) That’s it for now, but I’ll probably make some changes as I go and i’ll update this entry accordingly.


(1) Perl is a perfectly fine language, just not for me. I like languages that require you to make code look nice and don’t allow you to make something very cryptic (being able to do 7 line deCSS is funny, but makes it a huge nuisance when you want to reread/reuse old code.)

MRTG, Perl, FindBin and blogs

Wednesday, March 16th, 2005

Today proved again that blogs can be so useful!

Today I discovered that the mrtg user I created that runs all the mrtg processes had a huge mailbox and was getting new mail every time mrtg ran from the crontab.:

Use of uninitialized value in string at /usr/local/bin/mrtg line 78.
Empty compile time value given to use lib at /usr/local/bin/mrtg line 78
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/mrtg line 79.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/mrtg line 703.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/mrtg line 703.
ERROR: Can't Execute '/rateup'

So I did a Google and whaddayaknow, this blog turned up, supplying me the answer for the above problem:

In stead of

*/5 * * * * mrtg  /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg  --logging /var/log/mrtg.log

You should use:

*/5 * * * * mrtg  cd /tmp; /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg  --logging /var/log/mrtg.log