Saturday, October 29, 2011

scenes from the haunted fishtank

One of the many downsides of being knocked on my ass for a month is that I've watched a lot more TV.
  • The Troll Hunter. I was expecting this to be really bad, but in fact it's excellent. It's Norwegian, and there are very clearly a horde of cultural references we won't get, but it's a fantastic movie. The lead actor is a Norwegian comedian, and he leaves me very, very curious about what Norwegian comedy looks like. (I'm not going to link to any descriptions about the movie. Just go rent the DVD, or stream it on Netflix, or pirate it, or whatever, right now.)
  • The A-Team. I was really expecting this to suck, and I think that's a completely reasonable expectation, but instead you get a quite well-done shootout-caper movie of a much higher quality than the schlocky-but-personable TV series of my childhood. Given Mister T, you might have to stretch to imagine B.A. Baracus having much depth, but MMA fighter Quinton "Rampage" Jackson turns out to be a genuinely good actor.
  • Breaking Bad. Hooooooly crap, this is one of the most masterful things to ever happen to television. The plot: a high school chemistry teacher is diagnosed with terminal cancer, and starts cooking methamphetamine to provide money for his family after he dies. That's the beginning. It's harsh: every episode is tense with impending doom, endless awkward moments and human train wrecks, carefully examined frame by frame in slow motion. It's about change, and how we choose to create ourselves and our lives with every choice we make. Here's a great essay comparing it to the three other Great TV Shows Of The Moment.
  • Heroes. Promising first season, but it sucks pretty quickly. I gave up and reading the episode synopses for the last 1.5 seasons.
  • Game of Thrones. Based on George R.R. Martin's Song of Ice and Fire novels. It's brutal in spots, as you (or I, at least) would expect from something authentically medieval. It's not for the squeamish, but I've found it aesthetically stunning from the opening shot of the first episode. And check out the opening credits. Also, dwarf actor Peter Dinklage!
Of course, except for The Troll Hunter, I recommend reading books and talking to people instead. =)

Thursday, October 20, 2011

polyglot

Since I've been teaching J how to program in Scratch off and on, I had the rare moment of talking to my parents about programming languages the other day. There's not usually much to say about specific programming languages with someone who doesn't write code--though there's lots to say about the nature of programming, and I have a blog post in the works about that--but I mentioned I was reading some horrible C++ code and it was a little tricky because I don't really know C++. I used it a couple semester in college and that was it. Mom said, "But you can tell it's horrible anyway?", which I can, and that got me thinking about why, and what I understand about programming languages and how they're related, and all kinds of stuff.

Programming languages are not mathematically related to human languages, but they're related inasfar as they're made by and for humans. Much like human linguists, we talk about "families" and "dialects", and languages influence each other's development, often with cycles of back-and-forth borrowing of ideas. To see this profusion, take a look at the canonical Programming Languages Family Tree, or O'Reilly Media's much prettier version (now somewhat out of date).

Making a programming language is now well-enough understood that college students do it in one semester. Making a programming language that's useful is a whole other project, and highly likely to fail. Solving a real-life problem isn't just about the language, but about its associated libraries, which need to:
  • manipulate files on disk and otherwise talk to the computing environment.
  • deal with networking.
  • deal with multiprocessing (doing more than one thing at a time).
  • provide utilities for common programmer needs, like finding the length of a string of text.
This is a lot of work, and programmers have limited time to learn new things and even less time to actually adopt them, so your language has to have something special to offer to get off the ground. Java, for instance, looks a lot like C++ but doesn't suck quite as much. Ruby, which I work in, lets you accomplish a lot of work with very little code. Python is similar to Ruby, but a bit easier to read. And so on.

Enough describing. Why can I be judgemental about C++ code when I don't know C++? Let's start with some languages I'm more familiar with. Here's a class in Java. A class is technically defined as "a thinger that combines data with the operations on that data". Like so:

public class MessageCounter
{
int count;
MessageList messages;

public void receive(Message msg) {
MessageList.add( msg );
count++;
}
}


(None of these examples are complete, by the way. I'm stripping out a bunch of stuff that's needed in real life but would just obscure my point.)

That receive() thing is a function (or sometimes subroutine), but for irrelevant historical reasons, when a function is part of a class, we call it a method. The ++ operator comes from C, and increments a variable by 1.

My second language was Perl:

module MessageCounter;

$counter = 0;
@messages = [];

sub receive {
my $msg = shift;
push @messages, $msg;
$counter++;
}


Okay, that's a bit out there, I'll grant you: Perl is not for the faint of heart. But see how there's still a block marked MessageCounter, we're clearly doing something with a structure named messages and the message we received, and there's that ++ again. sub is short for "subroutine".

Here's Ruby, invented some years after Perl by a guy who couldn't take Perl's punctuation any more.

class MessageCounter
def receive(msg)
@messages.push msg
@counter += 1
end
end


See? It's like Perl, but easier to read. Ruby lacks the ++ operator, so we say += 1: in this language family, = means "assign the right side to the left side", and @counter +=1 is shorthand for @counter = @counter + 1.

After all that, here's C++, which predates all three.

class MessageCounter
{
int counter;
MessageList messages;

public void receive( Message msg ) {
messages.add( msg );
counter++;
}
}


That's right. There's a one-word difference from the Java. C++ is a huge, awful language, and even professional C++ programmers often don't know all of it, but much like seeing Catalán when you know Spanish, you can usually get the gist.

As for judging quality, because all these languages belong in a very, very large category called imperative languages, and furthermore (because they have classes) they're object-oriented,
(Pedants: Yes, Perl is not object-oriented. Hush, it's not important right now.)
there are common principles, the subject of many many books, of how to organize programs in a way that is comprehensible. The code I was reading violated many of those principles.

See? Simple!

Tuesday, October 18, 2011

it seems I'm awake

We're experiencing some household-wide Epic Sleep Failure here at the Snugglehaus. I often sleep erratically anyway, then Anna came down with this brutal cold and cough, and now I have the cough, though it seems not as bad as she did. (As a girlfriend told me years ago, in a delightful fake Russian accent: "Strong, like bull. Smart, like tractor.") Our sangha's retreat is this weekend, and if I feel like this, I won't be able to go. I'm normally fairly robust, though, so there's a good chance I'll be better. If not, I have a quiet weekend alone in the house, which isn't so bad.

I can do 15 push-ups! The last 5 hurt my upper incision, which is healed on the surface but will take some time to knit together underneath. It's hard for me to imagine how debilitating a traditional open surgery must be, where they make a huge incision in the abdominal wall. It's such a strange feeling to try and use a normally-reliable muscle and it's just...broken. A couple years ago I was throwing a football around with some kids at Thanksgiving, and after one particular throw my shoulder hurt and one of the muscles (the front part of the deltoid, from the diagrams) stopped working for a few months. I couldn't do push-ups, which meant I couldn't get up in aikido the way I was used to: where before I would put my hands down and push up, I learned to put my elbow down instead, and use my sturdy, jointless upper arm for support. I assume I tore the muscle or something: it got better very slowly, and it was at least 18 months before it was fully healed.

It turns out, though, there's no working around the need for my upper abdominal muscles.

J's excitement at programming in Scratch continues. Sometimes I show him stuff, sometimes he figures things out; he found a bunch of code examples I didn't know were there, and picking those apart seems to be a good way for him to learn. He digs through the icon library and makes varyingly elaborate stories about how the knight was mean and so he's being punished by J making him spin around and grow small. It's pretty adorable.

Not that I've been at work much this past month, but we're finally done with our Quality Initiative (which left me with a single vague assignment I wasn't interested in) and back to re-designing the transcoding system (which is really interesting and it's what I want to do). Now, of course, I have to design and build extremely high-quality components from scratch. This is something I can do, of course, but I feel like it's not necessarily something I have done, so there's a certain sense that I'm now playing with the pros and this is the time to bring my A-game. There's a strong leadership aspect, too: the team already has a leader, but they're looking to me for the vision of the re-design, and I need to communicate with and get everyone understanding and participating. There are several parts of the thing that I don't actually know how to build yet. (It's a big, complicated thing. The broad strokes are clear, many details are not.) I'm happy to be back onto that.

And apparently I'm getting married in three (3!) weeks. We have the expected last-minute RSVPs and cancellations, crabby or insane relatives, ordering cupcakes, writing checks, sorting out final details. Anna and I finally picked witnesses to stand up and sign paperwork and handle logistics the day of the event (because we shouldn't have to worry about stuff, even if we'll be able to, which I doubt): they're both named Ann, so I decided mine would be the Best Ann and Anna's would be the Ann of Honor.

Thursday, October 13, 2011

warm hand to warm hand

There's a wide variety of things I know a fair bit about. My housemate in Chile, Steve, often remarked on how exciting it was to randomly discover things like
  • I was on the diving team in high school (varsity one year, because there were only 4 divers and one guy broke his foot).
  • I did archery for a while.
  • I learned ceramics and jewelry-making for about a year.
  • I know a lot about blacksmithing.
  • I'm a very good cook.
  • I helped crew a sailboat in Mexico for 3 months.
  • I once moved to Wisconsin to become a professional a cappella singer.
The list goes on like that.

It turns out, though, that my general hobby is dilettantism, and there are far fewer things I know well enough to teach in any depth:
  • sailing
  • aikido
  • computer programming
I've been pretty excited about teaching J how to program, because I think he'll love it and it's something I really enjoy. I finally got the chance, when J talked about to Anna and he was incredibly excited about it last night, so tonight he took his entire hour of allotted Computer Time to playing with Scratch, a simple graphical programming environment designed for this purpose. I had all of 15 minutes to mess with it last night before cracking it open with J today.


He was SO EXCITED. I couldn't stand it. I would direct him to something, like a loop or an instruction to change the picture's color or whatever, and he would start playing around with it and telling a story, flailing with excitement every time he made something happen. That's a big part of the joy of programming: you think something, type into the computer, and the computer does things. Later on, you make many computers do things. Often in a coordinated fashion. It just gets better and better.

So awesome. For a whole hour!

Now I have to learn how to use the thing so I can teach him more stuff. =)

Dennis M. Ritchie, 1941-2011

Everyone knows Steve Jobs died, because everyone knows who Steve Jobs was. Steve Jobs made sure everyone knew who Steve Jobs was, by being the public visionary of Apple, then Pixar, then NeXT (you're easily forgiven for not recognizing that one), which Apple bought as the foundation for Mac OS X, making him the public visionary of Apple again. Everyone knew him because he personally masterminded and introduced dozens of things that changed our everyday life.

If you're a non-Microsoft computer geek, though, you probably owe your career to Dennis Ritchie, who died on October 9th. With Brian Kernighan, he created the C programming language, which was mostly invented so that Ritchie and Ken Thompson could write the Unix operating system. Steve Jobs' NeXT was based on Unix1, and Linux was a complete re-implementation of the Unix design.


(Those cabinets behind Ritchie and Thompson is the computer, and there's paper in that computer terminal.)


It's hard to overestimate Ritchie's impact. My entire career has been programming software in Unix-like environments, and that looks like it will be true for a long time. Even DOS, the hoary undercarriage of Windows, was actually a half-assed braindead Unix rip-off. You may recognize
c:\\Documents\Your Mom\Friday Night.doc
but that started out as
/home/chris/writeups/your_mom/friday_night.txt
If you're an advanced DOS user, you may have done something like
list | more
where the output of list gets "piped" through the pager more so you can actually read it if it's more than one page. You wouldn't know it from DOS, but pipes were Unix's gift to the world, enabling people to write small, general-purpose tools and string them together to create extremely complex effects (also known as the Unix philosophy). This sort of thing is routine in Unix:
grep apple some_file.txt | sort | uniq -c
Which, in order, finds all lines in some_file.txt with the word "apple", sorts them, and simultaneously removes duplicates and counts the occurrences of each line.

The C programming language and its Frankenstein descendant C++ have been so popular that any new programming language needs to either have C-like syntax, or have a really compelling reason not to. Languages that kept C's lower-level syntax (like 'x=5' for "assign the value 5 to the variable x") include C++, Objective-C, Java, Microsoft's C#, Perl, Python, and Ruby.

I don't know when this was made, but they're already greybeards.




In his quieter, harder-to-understand way, Dennis Ritchie changed the world every bit as widely as Steve Jobs did. Well done.

1 Well, kind of. The history of "Unix" and its derivatives and copies is a tangled mess: here is a "simplified diagram" of the Unix timeline.

Sunday, October 9, 2011

recent events

I tried going for a run Friday!

I'm not trying that again for a while. The impact made stuff hurt. I do need some exercise, but something less jarring. I guess I can try swimming; sadly, the only things I really like doing are running and aikido, and I can't do either right now.

We had a weekend of doing roughly nothing, since Anna's not feeling well and I think I'm fending off whatever she's got. There are various wedding things to do, even for me, so losing the weekend doesn't feel stellar, but it'll be fine.

Speaking of: less than 4 weeks now! We're looking forward to it, and we'll be very glad when the marrying part is over with and we can continue on with being married. For our honeymoon we'll be getting sloppy drunk in all the highest-quality strip clubs of Portland.

Well, I will. I think Anna was planning to go look at art museums or a quilt convention or something. Whatever. Chick stuff.

I've had several opportunities to remove Anna's power of speech over the years: early on, by jokingly using the word "girlfriend"; then a couple of times by oblique reference to marriage; once we were engaged, I once made her seize up completely by referring to her as "Mrs. D---". (Behold my feeble attempt at blog anonymity.)

However, she has decided to escalate everything by changing her name. I'm not sure I can top that, at least without some planning. I'm sure I'll think of something.

It brings up some interesting stuff for me, though. It's this very unexpected jolt insisting that I'm all grown up now. Which I am, of course. I now have a matching set of dishes to prove it. I've fulfilled my life's ambition to own a butter dish. I thought I was as grown up as I could get!

Imagine my shock.

Wednesday, October 5, 2011

music for the rainy season

A while ago it occurred to me to look up the history of the Shaker song "Simple Gifts". Incredibly, until Aaron Copland used it in "Appalachian Spring" in 1944, it was apparently unknown. It's so familiar to us now that it's hard for me to imagine a world without that melody in it.





The music was re-purposed in 1963 to create the hymn "Lord of the Dance", which I heard at Episcopalian summer camp long before I knew about the Shaker song. I think the version I heard was by the early Christian rock band Petra, but I can't find any evidence they ever recorded it.





If you venture much into the obscure, you might have been briefly misled when a guy named Chris Clark released a very strange, squelchy, crunchy, wonderful electronic track by the same name but completely different music:





Then one day I heard this, and sometimes I just load up this video and listen to it a few times, because it's one of the prettiest things I've ever heard.





That's all.