Thursday, July 2, 2015

Handbook to Life in Ancient Mesopotamia

I'll give Handbook to Life in Ancient Mesopotamia by Stephen Bertman five stars, but I'm a bit conflicted about it.

In describing life in Mesopotamia, Bertman's book is very good. It left me with a feeling of understanding of the people who lived there at that time, at least as far as I can from a textbook. They are people, not dry facts. The chapters on everyday life, arts, architecture, and transportation were very good.

On the other hand, as another reviewer has said, it is rather stuffed full of lists. Further, it does specifically focus on Mesopotamia, dealing only peripherally with the surrounding civilizations (Egypt, Mittani, Hatti, the Levant, across the mountains in modern Iran). As a result, the impression of the chronology is pretty linear. Sumeria, Babylonia, and Assyria seem to be pearls on a temporal string rather than a group of cultures that interacted constantly with their surrounding cultures.

My other complaint is that Bertman occasionally goes off the rails: for example, after discussing the rather harsh punishments of Mesopotamian, especially Assyrian, justice, he writes, "It would be a facile and self-serving exercise for us who are spectators at our own permissive culture's decline to mock the efforts of ancients, however excessive, to stave off civilization's fall."

But, limiting my review to what the book is rather than what I might like it to be, I'll give it five stars. It does exactly what the title claims, very well.

Wednesday, April 22, 2015

2015 Atlanta Pen Show

Tl;dr: I went to the Atlanta Pen Show. It was fun.

I had originally planned on going to Atlanta on Friday, spending the night, and taking Saturday at the pen show, going to seminars and having a wonderful time. Then, I remembered that I'm an antisocial misanthrope with shyness issues from Texas, would be unlikely to actually speak to anyone, and that this is apparently a send-the-IRS-much-money year, so I waited until Saturday morning. I arose somewhat early, patted the Dianne, Penelope Doglington, and Zach on the head and prepared to leave. Zack glared at me and started waving his claws around; I cut the preparations short and just took off.

I hopped into the ol' 'vette and went through Section like the Four Ponies of the 'Pocalypse, leaving devastation and wreckage in my wake although I don't think anyone noticed; I whipped through Fort Payne like the North Wind, except that I was actually coming from the west; and took Rome, GA, and points Atlanta-ward like an invading army of crazed yankees driving Corvettes. However, as I didn't leave any parts behind, I assume my territorial claims have since been nullified.

Anyway, I arrived at the Wyndham about 11:45 because I'm not a morning person. That meant that I missed Susan Wirth's seminar on "How some pens can make anyone’s handwriting look good. How to find them at a Pen show," which I wanted to attend. Sigh. I did manage to avoid being dragged into the calligraphy class---that would have been like teaching a pig to talk; it wastes your time and annoys the pig. I did a quick lap of the show, which was two conference rooms and the halls between. It was packed, both with vendors and attendees. Then, I got to business.

Brian Anderson did have a Sailor King of Pen (just say it, "King of Pen"), which felt lovely and has an impressive nib. One of the things I was looking for at the show was lightweight, oversized pens, and that is one. Unfortunately, Mr. Anderson sold it to the guy standing next to me right after I finished playing with it, so I didn't spend several hundred dollars on one pen. (The rat bastard.)

On the other hand, I discovered that I don't particularly like the way Pilot Vanishing Points feel. It's a nice pen, but I no longer feel the need to look closer at one. For me, this show is the first time I've seen many of the pens I have looked at in person, and there is nothing like touching a pen and feeling its heft to judge how I would like it.

The Nock tables were occupied by a man with a terrifying beard.

Another thing that I was looking for was a reference to Parker Vacumatics. Given that they are beautiful and just feel right, and that they represent everything that is good, true, and just in the world, and that I love them, I decided I needed to get serious about collecting them, which meant learning much more about them. I was talking to Mike and Memi Turkington of M&M Pens and learned that Mike has some sort of weird fascination with Duofolds, but he suggested Geoffrey Parker, David Shepherd, and Dan Zazove's Parker Vacumatic book. Unfortunately, said book is apparently printed on unobtanium. Fortunately, they pointed me to the Pendemonium folks, who had a copy of said book for sale and it came home with me. The book is as attractive as the pens.

Overall, the show was very nice. Although vintage pens did seem to be much of the focus (something I enjoyed), there was a good mix of vintage and modern. The Franklin-Christoph booth, I believe, was doing a great business offering a wide selection of testers and custom-ground Masuyama nibs. (And Franklin-Christoph has some nice pens.) Anderson Pens also had a wide variety of different manufacturers (including the TWISBI 700 vac that followed me home). Every vendor I talked to had testers or was happy to let potential customers get their grubby mitts on their pens, including letting them dip and write. The customers, not the pens. Pens don't have fingers; they can't dip or write.

I spent a lot of time near Martin Ferguson's booth, and the other tables doing pen repair. Am I weird to think that's fun?

After the show, I stopped by Rockler Woodworking, which has some good options for pen stands, gift boxes, and zippered pen cases in their pen-turning supplies, in addition to their, you know, woodworking stuff. I had dinner at Nori Nori, eating very good sushi until I ruptured, and came home, flying like a great raven through the Georgia countryside. Except that the 'vette is red, not black, and doesn't fly.

Here endeth the saga.

Friday, April 17, 2015

Operator overloading in Rust post updated

A couple of years ago, back in 0.6 days, I wrote a post on operator overloading in Rust. I've now updated it for Rust 1.0.0-beta, which simplified the code greatly.

As a bonus, it now includes some discussion of Rust macros!

Operator overloading in Rust

Sunday, April 12, 2015

Update on rust-toys

With the release of rust 1.0.0-beta, I've received a ping about updating my code from 0.11. Unfortunately, I hit the following:

        let line : String = line.unwrap();
        let line : &str = line.as_str().trim();

The variable line coming in is a io::Result (Is it me or are there two Result types in the standard library, std::result::Result and std::io::Result?); unwrap() returns a String (or blows up), which I then need to convert to a string slice (&str) in order to trim whitespace, using something like String::as_str or Str::as_slice.

Unfortunately, that code fails to compile with:

src/bin/mk_anadict.rs:18:32: 18:40 error: use of unstable library feature 'convert': waiting on RFC revision
src/bin/mk_anadict.rs:18         let line : &str = line.as_str().trim();
                                                        ^~~~~~~~
src/bin/mk_anadict.rs:18:40: 18:40 help: add #![feature(convert)] to the crate attributes to enable

And the convert feature is not allowed in the beta release channel. (There was a fix for the error message suggestion, to prevent the compiler from showing "add #![feature..." when that won't work, but it didn't make it into the beta release.

I'm going to bail on this for the moment, until the standard library settles down a bit.

PS. Wait, what?

I realized I hadn't tried one thing: calling trim() on the String itself.

        let line : String = line.unwrap();
        let line : &str = line.trim();

It works. I don't know how.

Later. Hah. Because there is a Str implementation for String. I think. As I recall, there wasn't previously, which was why I needed to get the str explicitly.

Saturday, April 11, 2015

One stupid shell scripting trick everyone should know

Let's say that I am installing Rust 1.0.0.beta, which comes as a pre-compiled binary package with an install script. Now, this is probably a good thing, because building rustc from source was slow and the rustc source doesn't include cargo, and thus probably other nifty things, but it does have a downside: if you use the --prefix argument to set a local installation directory, say in your home directory, you get an error message running rustc.

error while loading shared libraries: librustc_driver-4e7c5e5c.so: cannot open shared object file: No such file or directory

The rustc executable cannot find the shared libraries that it needs because their custom location is not built into the executable. Nor, if you didn't run install.sh as root, has their location been added to the system's search path; that is the point of the error message at the end of the installation.

install: running ldconfig
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
install: WARNING: failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error

So, what to do?

You could fix the ldconfig situation, but fooling with the system configuration irritates my lazy bump.

The obvious solution would be to set the LD_LIBRARY_PATH variable to include the Rust lib directory, but LD_LIBRARY_PATH has been the source of weird problems and frequently complicates debugging, so setting it globally or in your shell initialization script is an enterprise fraught with peril. But there is a simple trick that is handy for these sorts of situations.

First, in the Rust bin directory, move all of the executables to a new name, say rustc to rustc.bin, rustdoc to rustdoc.bin, etc. The cargo program doesn't have any links to the Rust libraries and the rust-gdb program is already a script, but doing this to all of them won't hurt anything.

Second, in the bin directory or any other location of your choice, create another short shell script.

#!/bin/sh

RUST_HOME=/home/mcguire/soft/rust

export LD_RUN_PATH=$RUST_HOME/lib

LD_LIBRARY_PATH=$RUST_HOME/lib exec $0.bin "$@"

I named it environment-script. Make sure it is marked as executable.

This script does a little more than necessary, but the basic idea should be clear: it sets the LD_LIBRARY_PATH environment variable in the last line to the location of the Rust libraries, then uses exec (a small optimization) to call another program ("$0.bin"), passing along all of the command line arguments ('"$@"'). I will explain the details here after the final step.

Third, in the rust bin directory next to the newly-named rustc.bin, create a symbolic link to the environment-script named with the original name of the Rust program. Do this for all of the Rust programs.

ln -s environment-script rustc
ln -s environment-script cargo
...

After doing this, you should be able to run rustc --version and get the version string without an error message.

$ rustc --version
rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)

What is happening here? Running rustc invokes the environment-script, which uses the shell's syntax for setting the LD_LIBRARY_PATH variable for the execution of the exec command. The exec command takes the rest of its arguments and calls them, as a normal shell command. However, with exec, the process running the environment-script becomes the next command rather than running it in a sub-process. (Like I said, a small optimization.)

The program that gets run is given by $0.bin. $0 evaluates to the name the script was called as; in this case that will be "rustc". As a result, it invokes rustc.bin, the renamed executable. The script uses the shell syntax "$@" (the quotation marks are important) to pass any command line arguments along unchanged. In the end, rustc.bin is executed with an argument of --version and an environment setting necessary for it to find its shared libraries.

The LD_RUN_PATH environment variable is similar to LD_LIBRARY_PATH, except that its value should be added to the library search path compiled into any programs that rustc produces, allowing them to find the Rust libraries if they need them.

Tl;dr: Wrapper scripts! Learn them! Love them! Live them! Is there nothing they cannot do?