Friday, November 21, 2008

Toe in (Shameless Shilling)

So after praising MagnaTune to the heavens the other day, I decided to look a little more closely at them. I'd already read most of their site, and had even looked into some reviews of their service; but I did a little more exploring.

They offer memberships: subscriptions to their site. There are two levels: Streaming, and Download. You don't have to be a member to purchase music from them, but members get a few interesting perks. Anyone can go to MagnaTune and listen to their entire catalogue streaming: but a membership buys you the same streams commercial-free. You also get site features like playlists. The download membership goes a little further: you can then download any album on the site, free of charge. There are three "rules" of membership:

  1. they ask you don't give away more than a single album a month,

  2. you must manually download the tunes: no crawlers or spiders, not LWP or wget, and

  3. membership is not shareable/transferrable;


Memberships used to have a minimum 3-month term, but now they offer them for as little as one month. Like everything at MagnaTune, you set the price: a streaming membership starts at $5/month, downloads at $10/month; but you may pay more.

I've been intrigued by this idea, so when the minimum term dropped to a month, I decided to try it out. I purchased a month's download membership last night. So for one month, I am free to stream or download MagnaTune's entire catalog, if I so choose. And it cost me about what I'd expect to pay for a CD from Amazon or Borders (I didn't cheap out and pay the $10 minimum).

What I download is DRM-free, it's mine to keep, whether I maintain my membership or not. And I'm perfectly free to burn it to disk, put it on my iPod, or whatever. I can even give an album away to a friend every month. And I can download the music in WAV files: they're CD-quality copies.

And best of all, it's 100% legal. MagnaTune is essentially a record label, rather than a reseller: they have full rights to distribute their music.

The only real downside is, the music is necessarily all indie. If you like indie music, that's no problem. If you like to purchase what's on the radio, it might be a difficult fit. Although interestingly, some of MagnaTune's artists are now showing up for purchase at iTunes. So more mainstream people are discovering them.

So how do I like it? I found about a dozen albums right away that I listed as favourites and have been listening to as streams. My two favourites of the bunch I downloaded as WAV files, and will burn to CD this weekend: Acoustic Abstracts and Horizons, both by guitar duet Heavy Mellow, from Tennessee. (You can, of course, go and listen to both those albums in their entirety, with or without paying for a membership. Why are you still here? Go listen!) Very relaxed and relaxing guitar music. I've also got some very good cello and viola music in my playlist, as well as some more folksy stuff.

I haven't had to look too hard to find good stuff there, and I've already gotten my money's worth in about 16 hours.

Will I renew at the end of my month-long experiment? I don't know. I'll have to see how the month goes. But based on my two purchases at MagnaTune (Goode Christemas Musicke and this membership), I'm really rather impressed.

If they can stay alive (they've been going for 5+ years already), I anticipate I may well turn into a very loyal customer.

Tuesday, November 18, 2008

It's not February

I generally buy two Christmas CDs a year. Yeah, that's a lot of Christmas music, but I like Christmas music. I also receive a fair number of Christmas CDs as gifts, because people know I like Christmas music.

I've occasionally purchased more than just two CDs, and frankly the convenience of online purchasing a la iTunes hasn't been a good thing in that respect.

Last year's purchases were A Traditional Christmas Carol Collection from The Sixteen and Christmas Carols from York Minster. The year before I purchased Christmas With The Academy and Christmas Songs by Diana Krall, both on iTunes.

This year's purchases are in, and I wanted to share them. First was The Best Carols in the World...Ever!. The title is cheesey, but the content is great. It's a collection of relatively rare (from an American perspective) carols done by a variety of reputable performers: King's College Choir and Medieval Baebes, for example. There are 52 carols in two CDs, which is a decent selection. It was definitely a deal.

The second was Goode Christemas Musicke.

This one is worthy of comment. Goode Christemas Musicke is almost the same concert as Dancing Day: the Dancing Day arrangement by John Rutter. Well, they're not the same: both start with Rutter's Dancing Day, but they follow them with different carols; but there is significant overlap. I think this album is performed slightly better, but the real improvement is in the recording. Where the Dancing Day album had some significant noise issues, this newer recording is impeccably clean.

But perhaps the most interesting thing is that the album is distributed through MagnaTune. MagnaTune is an online music distributor that handles independent musicians. They offer DRM-free recordings, and pay the artists directly. Every track is offered in full as a stream on their website, so you can listen to the entire CD before you buy it, and they let you re-download music you've purchased.

In short, MagnaTune is like an idealistic iTunes.

Perhaps most interestingly, MagnaTune asks you to give away three copies of each CD.

So I purchased Goode Christemas Musicke at MagnaTune and downloaded it in WAV format, CD-quality audio. Then I downloaded the album art and printed out a cover on photo paper. I burned a CD with the WAV files, then converted them to MP3 in iTunes and attached the album art. And now I have both DRM-free MP3 tracks from MagnaTunes and a full-quality CD copy.

All in all, an excellent deal.

Friday, November 14, 2008

Two Things

So I've been neglecting this blog recently: that's more laziness than anything else. But today I wanted to break the silence to mention two things.

First, there is an interesting editorial by Paul St. Pierre, "A voice from the grave's edge", apparently published in The Vancouver Sun. It's a most accurate and succinct write-up of the direction North American culture has taken in my lifetime. Whether one considers the changes in the USA since 9/11 or the Maoist speech controls in Canada, it's obvious to anyone who thinks that the world is changing, and not for the better. Ayn Rand seems less like a novelist and more like a prescient every day.

St. Pierre writes:
Our Canada is now very close to a condition in which everything that is not compulsory is forbidden. We have become prisoners of the state. Like modern jail prisoners, all our needs for balanced diet, climate-controlled shelter, approved and tested medication, mental health counselling, higher education, suitable entertainment, grief counselling and consensual safe sex are available free. The inmate lacks only freedom itself.

This one is well worth the read.

Second, I've been greatly enjoying West Coast beer, and really have to mention the seasonal offering from Alaskan Brewing Company. I discovered Alaskan's beers when I moved out here, and I've become a real fan. Alaskan Amber Ale is not the best beer I've ever had: but it's very, very good. And at around $1 per bottle at Costco (about the same on sale in Safeway or Fred Meyer), it's a real winner. Listen, I take beer seriously, and I've been drinking this stuff almost exclusively for the last month. Smithwick's and Guinness are better, but not much. This is really good stuff, and at a price point where I can't justify not buying it.

And this last summer, I enjoyed several bottles of the incredible Alaskan Summer Ale. It's nice to have a "summer ale" that's light in colour rather than taste.

But today I bought a 12-pack of Alaskan Winter Ale, and it's amazing. Check out the colour of this nectar:
From Alaskan Winter Ale

This is an insanely good beer. This is the sort of brew the ancient Teutons dreamed they'd drink in the halls of their pagan gods after dying in gloriously in battle. If you like beer and you have access to Alaskan ales, you need to get some of this.

Next to Sarah Palin, this is best thing to come out of Alaska.

Wednesday, November 5, 2008

Happy Election Day!

"VOTE, n. The instrument and symbol of a freeman's power to make a fool of himself and a wreck of his country."
-- Ambrose Bierce, The Devil's Dictionary

Monday, October 27, 2008

Over the top... er, front

So I took my first spill on my bike riding into work this morning.

I was right at the end of my 12 mile ride: I had gotten all the way to campus, and was crossing the street. I got to the curb and tried to pop my front tire onto it... and missed. I don't know whether I was tired from the ride, or whether I just timed it badly, but I went right over the handlebars.

So I hit the concrete on my elbow and rolled, then my bike landed atop me. Oof.

My elbow and my ego took the brunt of the damage: I'm having trouble bending my left arm right now, but nothing's broken (I think)---it's just a little stiff. My helmet's a little dinged up, but I don't recall hitting my head... I'm hoping that's not a symptom.

I had to pick up my water bottle and bike light, and I decided to walk the rest of the way... all 100m or so to this building.

Mother Earth better be @#$%# grateful.

Sunday, October 26, 2008

Mt. Rainier

If you haven't spent time in this area, you might have trouble understanding the extent to which Mt. Rainier dominates the landscape. It doesn't dominate the view so much as it defines it. Ames took this picture a couple miles from the house:
From Mt. Rainier

You can see Rainier from almost anywhere here, except the house where we live: we have some tall trees right at the east end of our yard.

Rainier is about 30 or 50 miles from our house, so we decided to head on out and take a look. We didn't actually anticipate getting there, but we figured we'd head out to explore in that direction and take a look around.

There are some interesting things between us and Rainier: Alder Dam was impressive
From Mt. Rainier


We wound through several small towns and finally got to Mt. Rainier National Forest. A day pass is $15, a 12-month pass is $30. So we bought a year pass.


We never actually got to Rainier, which wasn't really a surprise. But we did manage to go for a walk in the foothills. The landscape definitely reminds me of home:
From Mt. Rainier

The "lonely road at the base of the hill" look sure takes me back to BC.

There are a lot of mushrooms on the west coast, and I ended up tagging some in photos:
From Mt. Rainier

From Mt. Rainier


It was terribly refreshing to walk in the cold damp air. That's a winter-on-the-Pacific-coast thing. We might not get a lot of snow, but the winter damp cuts like a knife. I've been out in the cold (I mean real cold, not just freezing temperatures), and it has its challenges; but there is a unique coldness to the damp air on the coast. To be sure I've never wintered in Cambridge Bay, but you get the point. Most places get dry in the winter: our winter humidity presents a unique cold.

From Mt. Rainier


Anyhow, we spent some time walking on a path that followed a creek up a foothill
From Mt. Rainier

From Mt. Rainier


The creekbed itself is bright orange, I assume that's clay washing down from deposits upstream, but I don't know for sure.
From Mt. Rainier


There were some really interesting branches along the path: trees apparently had some unique challenges in that forest:
From Mt. Rainier

From Mt. Rainier

From Mt. Rainier


We even found a hollow tree.

It wasn't an epic journey or anything, but it was certainly a nice way to spend a Saturday afternoon.
From Mt. Rainier

Friday, October 17, 2008

Perl Collections

I read this comment on Yegge's blog from February 2008:

For example, if you see this in Perl:

%x = map { $_ => 1 } @words;
@words = keys %x;

without a comment, you should fire, or at the very least yell at, whoever wrote it. (There are efficiency reasons for not writing that as well, but mainly it's a clarity issue.)


I've been mulling this over for the last couple weeks, and I've decided The Comment deserves comment. I would actually respond to this in the comments on that blog, but they've been closed a long time, and so I'm putting my comments here.


I doubt anyone but me cares about this: I'm just venting here.


Let's begin with the most obvious counterpoint: if you have an employee you're paying to write Perl, and he or she can't understand

%x = map { $_ => 1 } @words;
@words = keys %x;

you're getting ripped off. No-one getting paid to read or write Perl can be excused for not immediately seeing what that code does. That is not advanced code, the variables are clearly named, and the idiom is well-known. If you can't grok that code, you need to bone up on your Perl. If Perl is just another tool in your toolkit as a professional, you might not immediately see what it does... but in that case, you ought to expect to be opening the Camel Book fairly frequently anyhow. In that case you don't expect to immediately understand what every line of Perl does as soon as you see it; but you do expect to be looking things up.


I'm not claiming that's the best way to get a unique list (List::MoreUtils::uniq is much better, for example); but it's a very short solution that will work consistently. It might not be the fastest solution, but it's reasonable, correct, and terse. And frankly, it's also fairly clear.


Part of the problem goes back to what a former boss I highly respect told me once: people write bad Perl because they can. Perl is a simple language to learn, and it's very forgiving. One result of that is, there is a decided lack of "raising the bar" on Perl newbies. And frankly, one of the great things about Perl is the community that encourages newbies, rather than harassing them. So maybe ugly Perl is an acceptable trade-off. Maybe the benefits of a DWIM language and a welcoming community far outweigh any evils stemming from naive and/or verbose code.


But maybe there is a middle path, where newbies can be encouraged to write better Perl without being harrangued and beaten. Maybe it's possible to gently and casually get the message across that baby talk is great for babies, but inappropriate for adolescents. Naivety and inexperience are nothing to be ashamed of, but they're not something to be proud of either. I think that's what my boss was trying to tell me.


And incidentally, it was that boss that really forced me to learn Perl properly. I knew Perl before, but my Perl really sucked. He forced me to use it, and raised the bar on me whenever I started to make progress. I'm no Perl expert, but whatever small advances I've made started when he put the pressure on me to write better Perl, instead of stuff that actually ran.


I think there is a related factor here too: Perl is a huge language. It was designed that way, and there are nooks and crannies that can go unexplored for years. I'm no Perl guru, but I know a lot more Perl now than I did two years ago, when I had already written a lot of Perl professionally. It seems I'm constantly saying "Well, I thought I knew Perl before, but now I realize I didn't". This is part of the famous TIMTOWTODI: having many ways to do any given task implies a fairly large and flexible vocabulary. It also implies a learning curve that is very long, even if it might well be very steep at times. Perl is a language that can surprise you even if you've been learning it for years.


I've found my Perl has gotten simpler and less like line noise over time. I've been known to write comments here and there, and my variable names have gotten more descriptive; but that's not what I mean. I find I almost never use && or || anymore, preferring and and or. I frequently use a die unless... idiom now: I find having a die at the start of a line emphasizes this is a potential exit point much more strongly. I also prefer to use do_something() if... instead of if(...){do_something()}, as it just seems to flow better. And I avoid if not, using unless.


One place my Perl has decidedly changed is, I now use list operators much more frequently. Maybe that's because I've spent some time writing actual, working code in Lisp, maybe not. But one thing is certain, I use map, grep, split, and join a lot more now. I used to do things like

foreach $line (sort @lines) {
print "$line\n";
}
print "\n";

Now I write that as:

print join ("\n", sort @lines), "\n";

I'm not sure that's really an improvement, except I prefer to use fewer lines to do the same amount of work. One line to accomplish a task in a reasonably clear manner seems like a better ROI for my Carpal Tunnel pains than four.


But I'm not trying to argue I'm brilliant, or anything like it. I'm merely using my own Perl as an example: over time, my Perl has changed its form decidedly---for the better, I think. When I started writing Perl, my programs looked like I had messed up my terminal settings: they were full of cryptic symbols and complicated key words. Now it reads more and more like English. I think that's an improvement.


And particularly when it comes to list operators, I've found replacing a lot of my for or foreach blocks with map blocks has had the net effect of making it easier to follow the code flow in my head. It's not always the most readable, but there's a sense where readable is in the eyes of the beholder. I honestly find grep inside map more readable than nested loops. It lets me keep track of things like counting variables and nested scopes a lot more easily.


So I'm looking at the "bad Perl" example in The Comment, and I'm wondering exactly what the problem with it is. It seems there is a fear of list operations, which seems to be a particular instance of a fear of not explicitly shuffling variables.


Before I read The Comment, a friend had asked me how to do a word count in Perl. I have to admit my solution looked a lot like "bad Perl":

my %count = map { my $word = $_;
$word => scalar grep { $_ eq $word } @words } @words;

It's not terribly efficient to call grep inside map, I understand that. But you'll end up with a nested loop no matter what you do: mine is only two lines long, and seems reasonably clear. Isn't that the point? I assume if we're working in Perl, then performance is not the main consideration: C or Java or Lisp can all knock out a word count a lot faster. We generally choose Perl because it's a great language for thinking: it's a great language for ripping apart a problem quickly and simply. That's frankly why I came back to Perl from Java: I wanted to get stuff done.


So if we want a language to think in, why wouldn't we use as much of it as we can? Why wouldn't we pick up little idioms and bits of vocabulary that make thinking easier? Why wouldn't we sum up several lines of foreach into a single, short map? That's why we have things like synonyms, right? That's why we develop vocabularies in natural languages to encapsulate ideas that pop up. We use words in modern Physics now that Newton didn't use: that's because we've gotten new ideas, and they've required new words. Sure, Newton's English was Turing-complete (so to speak), but it's a lot easier to model modern Physics with our extensions to it, and our newer vocabulary is generally considered a good thing.


So I've decided that not only is The Comment inaccurate, it's actually a step back. Good Perl, like good English, is concise and accurate. Gratuitously using arcane vocabulary in Perl is bad, just like it is in English. But deliberately limiting your vocabulary at the cost of brevity and clarity in spoken languages is laughable (try it: carry on a conversation without using nouns introduced in the last century, and see how ridiculous you sound); and I've concluded it's the same in Perl. I've become convinced the Right Thing to do is to encourage wider vocabulary, both in my own code and in others'. And if that forces the poor sap who maintains my code to look a few things up in the Camel Book, well he can thank me later, when his Perl is a little more fluent and his vocabulary a little broader.