Ant “replace” task does not preserve Unix file permissions

This is probably a well-known fact for everyone who has used Ant on Unix for a while, but an annoying discovery for me who have been hiding under a C++ rock. The five year old bug report File Permissions not preserved in replace task pretty much says it all: Java couldn’t stat files, and it seems like it still can’t.

Update The “replace” task destroys file ownership too, of course.

Beautiful Code

I’ve been reading Beautiful Code from time to time during the autumn. It’s mixed bag and I actually skipped some chapter that was too deep into maths for my taste. Chapter 22: A Spoonful of Sewage was an instant favorite; it is a a fascinating head-first dive into a bug hunt in Sun Solaris’ synchronization primitives. It was a bit over my head but interesting nevertheless. Another very interesting chapter was Chapter 23: Distributed Programming with MapReduce about Google’s “programming system for large-scale data processing problems”.

Only because of the title of this blog, I’d like to mention that more than one chapter mentions the Divide and Conquer approach used by the Quick Sort algorithm, including using a subtle bug found in early (or naive) C, C++ and Java implementations to show off JUnit.

I’ve thought of sorting the chapters by programming languages and see what language the most author used for his or her beautiful code. At least Lisp, Python, Perl, Ruby, Java, C# and C++ are present. Some day I want to do a bit of Lisp programming, but I haven’t found a suitable project yet. Maybe I should buy a Lisp book too first…

Where is my own Beautiful Code then? If “get the job done” is considered beautiful, it could be the PHP code for any of my web sites! 🙂 I’m pretty happy about the architecture for my unfinished MidaSync project; maybe I should try to describe it here some day.

For MidaSync I also wrote a D-BUS wrapper for C++ that I’m quite proud of, but at some point it became a bit “magic”. For example it relies on the presence of a partial specialization to create a D-BUS path from an object exposed through D-BUS. I’ve never released this properly and I think that the D-BUS wrapper in OpenWengo is used by today’s C++ developers in need of D-BUS support.

Old and new Ruby and Agile books

A bunch of computer books I had ordered arrived to the office last week. Since I’m working on-site at my client I’m not at the office very often so didn’t pick them up until today. The books are:

  • Agile Software Development With Scrum by Mike A. Beedle and Ken Schwaber
  • Agile Web Development With Rails (2nd ed.) by Dave Thomas, David Heinemeier and Leon Breedt
  • Everyday Scripting With Ruby by Brian Marick
  • Programming Ruby (2nd ed.) by Dave Thomas, Chad Fowler and Andy Hunt
  • User Stories Applied by Mike Cohn

Unfortunately two of them are already old. A version of Programming Ruby updated for Ruby 1.9 now exists in PDF format and Agile Web Development With Rails will most likely be updated due to the recent 2.0 release of Ruby on Rails. Maybe Everyday Scripting With Ruby will be updated too soon, but I hope that all of them will still be of use to me. I only use Ruby and Ruby on Rails for my personal projects anyway, but I think that both of them — the language and the framework — make too much impact to be ignored.

Speaking of Ruby on Rails: I read that Hemnet, the major Swedish site for real estate ads, is using Ruby on Rails. Cool!

I bought Agile Software Development With Scrum in order to read one of the major works about Scrum. I really ought to have read it before by Scrum Master certification but I can admit I didn’t. Now it’s time to make up for that.

The reason for buying User Stories Applied is that I want to improve my skills in handling customer requirements. My current client is very fond of use cases but I don’t think that diminishes the value of the book in any way.

Apache Ant is regrettably (?) using XML

I’ve done some Apache Ant build file hacking today and that made me recall that the original author of Ant, James Duncan Davidson, actually regretted using XML as the file format.

Mysteriously missing from today’s world wide web, but fortunately captured by the Wayback Machine, the blog entry Ant and XML is worth reading. The entry is concluded like this:

If I knew then what I knew now, I would have tried using a real scripting language, such as JavaScript via the Rhino component or Python via JPython, with bindings to Java objects which implemented the functionality expressed in todays tasks. Then, there would be a first class way to express logic and we wouldn’t be stuck with XML as a format that is too bulky for the way that people really want to use the tool.

Or maybe I should have just written a simple tree based text format that captured just what was needed to express a project and no more and which would avoid the temptation for people to want to build a Turing complete scripting environment out of Ant build files.

Both of these approaches would have meant more work for me at the time, but the result might have been better for the tens of thousands of people who use and edit Ant build files every day.

Hindsight is always 20/20.

The “real scripting language” part sounds just like Ruby’s build program Rake and “a simple tree based text format” sounds very much like YAML, a format well worth considering for hierarchical data structures.

Most ThinkPad T60p original battery for the money

The old battery for my IBM/Lenovo ThinkPad T60p went from bad to useless this autumn but it wasn’t until yesterday that I ordered a new 9-cell battery (7.8 Ah) directly from IBM Sweden where the 9-cell battery actually was cheaper than a 6-cell battery (5.2Ah) . I first looked at well-stocked reseller Dustin but after discovering that either battery was cheaper at IBM, even including shipping costs, I simply ordered and smiled.

Update 2007-12-13 The battery arrived already today!

$ cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         84240 mWh
last full capacity:      84240 mWh
battery technology:      rechargeable
design voltage:          10800 mV
design capacity warning: 4212 mWh
design capacity low:     200 mWh
capacity granularity 1:  1 mWh
capacity granularity 2:  1 mWh
model number:            92P1133
serial number:            1146
battery type:            LION
OEM info:                Panasonic

MySQL support for UTF-8 in Ruby on Rails

As a follow-up to my post about MySQL support for UTF-8 in PHP, here is the very same information for Ruby on Rails. In Rails it is a simple configuration entry in config/database.yml. I use the development configuration as an example:

  adapter: mysql
  database: dev
  username: dev
  password: secret
  socket: /var/run/mysqld/mysqld.sock
  encoding: UTF8

UTF-8 is obviously configured with the encoding setting. Don’t forget to update the test and production databases too!