Monday, May 18, 2009

Guarneri Quartet retiring

I just heard that the Guarneri Quartet is retiring this year. Ordinarily, I would not take much note of such news, because although I've enjoyed the occasional Guarneri Quartet recording I've heard over the years, it's not a quartet I've seen live or had some special fondness for. But, this news came to me while the Guarneri Quartet by chance happened to be fresh in my mind, in a way.

First, while I was going through my LP collection several days ago, I happened to examine my 3-LP set of Brahms' three piano quartets and Schumann's piano quintet recorded by Artur Rubinstein and a young Guarneri Quartet in 1967. I had decided to keep this set, the source of my first exposure to these particular works, and therefore something of a sentimental favorite.

Second, while I had been Googling to see if there existed a CD reissue of this LP set (the answer was yes), I had found that Rubinstein and the Guarneri Quartet had also recorded Mozart's piano quartets, so I had checked the CD out of the local library and had listened to parts of it just a couple of days ago.

I have to confess that the performances were not to my taste. I favor a quicker, more dramatic interpretation of Mozart. I like how in the past two decades, period instrument scholarship and practice have resulted in very exciting, revitalized performances of music from Bach to Beethoven, both on period instruments and on modern instruments.

I guess all I'm saying here is that re-examining my music collection has led me to discard some recordings, while saving other recordings, from the past. Nothing stands still, not even the past and our appreciation of or criticism of it.

Saturday, May 9, 2009

LPs: the end of an era?

I recently decided that I should finally get rid of most of my classical music LP collection (over a hundred albums). Most of it was acquired secondhand at library sales, garage sales, and the like back in the late 1980s and early 1990s, when I found classical CDs to be way too expensive, and the selections at the time were limited also, with many old recordings still not yet reissued. I only ever bought a handful of LPs brand new, in around 1989, even as it was already clear that CDs were going to win for keeps.

In any case, how could I argue when I could and did, for example, buy a nice three-LP box of Mozart's six "Haydn" string quartets, performed by the Quartetto Italiano, for just $4? At random, I decided to listen to a side, and sat down, closed my eyes, and listened to Mozart's string quartet no. 16 in E-flat major, K. 428. The slight crackling noise from the LP didn't bother me much at all. Yes, there was life before digital recordings. Recorded in 1966, this LP sounds just fine; the sound is natural and full enough, and you can make out the different parts.

To my surprise, when I tried to search online for a CD reissue of these performances, I found a CD box set of the complete Mozart quartets by the Quartetto Italiano, but it was out of print! How ironic. This CD set was issued in 1991, apparently, a couple of years after I had bought the LP set (of just the six quartets dedicated to Hadyn), but now is out of print. So much for my expectation that I would be able to listen to CD performances nowadays. So I'm keeping this LP set instead of getting rid of it as originally planned!

I'm going to have to look up many of the other LPs to see if they have existing CD reissues.

It's something of a shame that the Quartetto Italiano's Mozart recordings are now an endangered species. They weren't necessarily my favorite, and stylistically one hears more driven performances these days, but they were good.

Addendum: I am apparently wrong that these recordings are endangered. In another twist of irony, I've seen Google links suggesting that there are torrents out there of these performances! That means immortality, of course. I do not download torrents of music, but I am tickled to think that there are aficionados of the Quartetto Italiano out there keeping their performances alive even after the Philips label stopped selling them.

Wednesday, May 6, 2009

Forever hatching

What if the baby universe,
opening her sleepy eyes for the first time,
saw the warm bath of her own light,
self-generated and reflecting within
the walls of her inner shell?

No outside to hatch into,
always awake,
always being born,
within and for herself,
forever hatching without complaint?

Tuesday, May 5, 2009

Adventures in static typing

The computer language I use most when programming is Java. It is not a language I love, but it gets the job done. Sometimes, though, I wish it would allow me to express more within a static type system.

I have been using JAXB in order to do data binding from an XML schema to Java. The generated Java code is not bad, but sometimes, using it is awkward. For example, the XML schema fragment


<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="k"/>
<xs:element ref="r"/>
<xs:element ref="a"/>
</xs:choice>


gets compiled into the Java fragment


/**
* Gets the value of the ksAndRS property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the ksAndRS property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getKSAndRS().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in
* the list
* {@link K }
* {@link A }
* {@link R }
*
*
*/
public List<Object> getKSAndRS() {
if (ksAndRS == null) {
ksAndRS = new ArrayList<Object>();
}
return this.ksAndErrorsAndRS;
}


In other words, all the possible items are stuffed into a List<Object>. This is annoying because the client of the code must be written to perform a runtime check, for each item in the list, of what type the item actually has. For example:


for (Object item : u.getKSAndRS()) {
System.println(doItem(item));
}


where there are definitions


String doItem() throws UnexpectedTypeException {
if (item instanceof K) {
return doK((K) item);
}
else if (item instanceof A) {
return doA((A) item);
}
else if (item instanceof R) {
return doR((R) item);
}
else {
throw new UnexpectedTypeException("u list",
item);
}
}

String doK(K item) {
return "saw K";
}

String doR(R item) {
return "saw R";
}

String doA(A item) {
return "saw K";
}


Ugly stuff. I have to look at the generated Javadoc comment to know what types to look for and handle, and perform these casts. You might wonder why I need the final case, in which I throw an exception for a situation that "cannot" happen. Well, apart from it being defensive programming, it is critical for maintenance purposes. As it turns out, I change the XML schema fairly often, and therefore regenerate the Java code often. Suppose I added another possibility to the schema, e.g:


<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="k"/>
<xs:element ref="r"/>
<xs:element ref="a"/>
<xs:element ref="newthing"/>
</xs:choice>


If I didn't use defensive programming, I could totally forget (being a human being) to update the client code to add a test for the newthing type introduced, and the program would silently do nothing for data that uses the new case.

Here's where a better static type system comes in. I think polymorphic variants, as found in the programming language Objective Caml (OCaml), are the perfect solution, especially since many of these XML elements can occur in many different contexts in different lists. For example, consider the following OCaml code:


type itemType = [`K | `R | `A]

(* Dummy implementation. *)
let getKSAndRS : unit -> itemType list = function
() -> [`K; `R; `K; `A; `R]

let doItem : itemType -> string = function
| `K -> "saw K"
| `R -> "saw R"
| `A -> "saw A"

let _ = List.iter print_endline
(List.map doItem (getKSAndRS ()))


The output is


saw K
saw R
saw K
saw A
saw R


We immediately see one advantage of using this type system: the compiler complains if somehow we forget to treat a case, e.g.,


(* Missing case for `A *)
let doItem : itemType -> string = function
| `K -> "saw K"
| `R -> "saw R"


leads to


File "poly.ml", line 8, characters 4-6:
Error: This pattern matches values of type [< `K | `R ]
but is here used to match values of type itemType
The first variant type does not allow tag(s) `A


Another advantage is the advantage over using just ordinary variant types (also known as algebraic datatypes or sum types), as found in core ML and Haskell and other similar languages. The advantage is that these labels can be used in more than one type, e.g.,


type anotherItemType = [`A | `C | `Z]

(* Dummy implementation. *)
let getCSAndZS : unit -> anotherItemType list = function
() -> [`Z; `A; `C; `A; `Z]

let doAnotherItem : anotherItemType -> string = function
| `C -> "saw C"
| `Z -> "saw Z"
| `A -> "saw A"

let _ = List.iter print_endline
(List.map doAnotherItem (getCSAndZS ()))


can be added in the same module in the same program without `A in one context conflicting with that in the other one.

So not only do we have static type safety, but also, for maintenance purposes, if the definitions of the types change, the compiler will warn us if we either are still handling a case that no longer exists or have not written new code to handle a case that has been added. Unfortunately, it is not practical for me to use languages such as OCaml, for a whole set of reasons, but maybe one day the world will be ready for them. Meanwhile, some people in industry, such as Jane Street Capital, do make use of OCaml, even devoting a blog to their experiences with it. They use features such as polymorphic variants, as described in this paper.

Monday, May 4, 2009

Starling Quartet mini-concert review

Tonight, totally on a whim, I went to a mini-concert of the Starling Quartet, the student honors quartet of the CMU school of music. I had simply by sheer accident noticed in my email inbox the weekly calendar and seen "Quartet" and decided to stop by. I'm a sucker for string quartet performances, and the last one I'd been to had been a concert by the Parker Quartet, the quartet-in-residence at CMU, on February 21.

For reference: the Starling Quartet consisted of Anat Kardontchik, Leonidas Caceres, Andrew Griffin, and Ana Isabel Zorro.

I went into the Kresge Recital Hall not having any idea what the program was. There weren't any programs around when I got there ten minutes early, and not many people inside either. Then people started coming in. Hey, this was the first day of finals at CMU, after all. Eventually about 25 people showed up in the audience. (About halfway through the concert, some guy started passing out programs. Before that, the violist announced what was being played.)

The concert lasted only about 40 minutes total, because no complete quartets were performed, just selected movements.

The first piece was the first and last movements of Hadyn's String Quartet in G Major, Op. 76, No. 1. Ha, I was glad they weren't playing the whole thing, because I had just heard the whole thing in February performed by the Parker Quartet! Anyway, the Starling Quartet performed the outer movements with real verve and alertness. I love this music. It's funny, for almost two decades I thought Haydn was boring, didn't bother to listen to much of his music, but now I find it so witty and delightful.

The second piece was Samuel Barber's famous Adagio for Strings, in the original string quartet version rather than the souped up string orchestra version. More precisely, this is the second movement of the three-movement String Quartet, Op. 11, by Barber. I have always preferred the original string quartet version, because it is so much more intimate and intense, the voices of just four individuals. I had never seen it performed live, so this was a special treat. And wow, I was impressed by the communication between the performers, the sonority of the harmonies, the emotion channeled into sound. The audience was so quiet that during the silence after the big climax in the music, there was pure stillness in the entire hall. I could not help but shed some tears while experiencing this music as it should be experienced, live, performed by four souls sharing it with each other and with the audience. Barber's masterpiece never gets old.

The third piece was the first movement of Mendelssohn's String Quartet in A Minor, Op. 13. The first and second violinists switched places for this piece. I'm not such a big fan of Mendelssohn, so I was not familiar with this piece, but it was very passionate and fiery, and allowed the performers to demonstrate a lot of virtuosity and intensity.

All in all, the little concert was a nice after-work treat, free of charge. I went away proud of these students who displayed so much enthusiasm, understanding, and feeling for some excellent music. I think anyone who lives near a university should now and then take advantage of free or cheap music performances on campus.

Finally entering the world of blogging

Here we go.