Archive for November, 2007

latex sucks! (for presentations)

November 28th, 2007

Hold your fire.

Got your attention there, didn't I?

Latex is good at what it was built to do - markup big documents. Fine for writing reports, articles, books. The problem is that we have no other tools nearly as good, so we end up using latex for things it wasn't meant for. Like presentation slides.

Why is this? Well, let's see. There's Powerpoint. It's a toy. It's one step up from drawing each slide separately in Paint: it has no structure, it makes you duplicate all common elements, no indexing, no outline. What does it offer you? Oh yeah, a spell checker. It sucks. Then there's latex. You reuse everything you already know about it, it has a ton of helpful packages, and with beamer you can actually write slides without hurting too much. Except.. it's still latex.

Here is the problem. Presentation slides are not the same as prose. Everything latex is good at has to do with handling text. Everything presentations are supposed to be is not centered on text. Giving a presentation is just as much about showing as it is about telling. And you're already telling when you're talking, so you should compose your slides so that you can show people what you mean.

We have horrid tool support for writing presentations. No wonder almost every talk you see is frame after frame of bullet points that no one will remember anyway. People actually paste parts of their text from articles into slides, as if that is supposed to produce a good visual device!

I have given 8 presentations in the last 12 months, and I'm set to do 4 more by the end of the year. Almost all of them written in latex with beamer. And you know what? I didn't enjoy myself. On the surface it looks promising. The beamer class has a ton of features, you use regular latex, and you output a pdf. But when you get down to the details...

The ratio of illustrations, diagrams, source code and other example materials is much higher than it is in prose. It's supposed to be that way. This is what latex is awkward at. Presentations are visual, so the first thing people think about is the slide design. Well guess what, if you have the perfect design already, good for you, but if don't, you're stuck editing latex styles, which no one understands. Strike one.

Then there is importing images into your slides. Raster images work fairly well, but obviously you have the resize problem - a raster image displayed at a non-native resolution will look jagged. You don't want that. So you hack up a vector image in something like dia. But you can't use that directly in latex, you have to convert it to either eps or pdf. I have found the latter least painful of late. So now not only do you have to know latex and dia, you have to author Makefiles to get a sane build process out of this. That is if you can remember to include just the right latex packages in your document, make sure they are installed both locally and any other place you may want to do a last minute recompile. Strike two.

Speaking of Makefiles, everyone knows you have to recompile a latex document to see the changes you've made. But with presentations these changes are much more often concerned with layout than they are with content. And it's a huge pain to recompile again and again to debug something as simple as a two column layout (use \minipage and set the width in absolute units just right so they fit next to each other). So now I have a compile loop running every second that invokes make and I see the updates in kpdf. All because I want to tweak the layout of my content. Speaking of compiling, have you seen those latex error messages lately? They're not meant for humans. And as far as languages go, latex isn't exactly the most... robust of them all. Make one tiny mistake here and your compile detonates. Strike three.

It is a pain. It is a pain to have to recheck old documents to remind myself of how I included a piece of source code. Or how I handled a particular image. Latex is extremely hackish. It makes it friggin' hard to generalize anything so that it becomes reusable. I find myself copy pasting code all the time from one document to another. There is nothing sensible about how things are done, it's just a matter of writing something that works, and having a copy of it somewhere. The more presentations I write the more difficult to remember which trick I used where. An unmaintainable mess.

And then there's time pressure. When you're writing a technical document, you have the time to work out the little quirks you will encounter. It's a permanent document, it will continue to exist for years after the fact, it's worth the effort. But presentation slides are not. You just want to write them fairly quick so that you can give the talk and move on. You're not going to be investing time in this, it's a one time thing. And yet writing slides requires a lot more patience with latex than writing prose does.

Nevermind that, writing slides is a creative process. It is not filling in predefined sections of a document, like an article for a conference is. You want to be able to experiment, to try things just for the hell of it. Latex is horrid for this. Let's see if I can fit this figure next to the text here. Okay, let me first look up how I do that. How do you actually find this out? I already covered that earlier. Then try it, debug the layout, finally I can see if I got what I wanted. No, that didn't work out, let's switch it back to the way it was. Compile error. Goddamn it, now what? Okay, let me gradually undo to a state that does compile and that way I can figure out what's causing it.

Not. how. it. was. meant. to. be. done.

The Recruit: very refreshing

November 23rd, 2007

A different kind of spy movie. James (Colin Farrell) is the college kid who gets recruited into the CIA. We see him go from a civilian to an operative-in-training, in boot camp, learning the basic skills, not to mention learning some basic psychological devices.

What I really like about this story is how raw the characters are. This is not a story about a veteran in the field à la Jason Bourne, who knows everything, feels nothing, never fails. It's about a guy you can relate to, someone who is learning to understand, but still living through the pain of being put through all these things that are happening to him. The plot isn't brilliant, it's neat and tidy, almost simple. But the appeal of the movie isn't in that, it's in the characters, how real they are and how unrefined their reasoning and emotional response is.

The idea is nothing is what it seems, but they don't take this very far, they hold back so that the characters can tag along at their own pace. And that's.. nice. Most other stories try to push the envelope and many of them fail to resolve well. This one doesn't, and you can appreciate that they care more about the character development than the goal to have a complicated plot.

Enjoyable as it is, I just have to point out a few technical things. Forgive me, it's too much to look the other way, downright embarrassing at times. Okay, what the bad guys are after is "a virus", a computer virus. It turns out, though, that this is a magical virus that you can deploy right into the power socket in your house and it will infest the nation's whole power grid. Okay, that's just beyond bad. And James is the MIT kid who is a computer wiz. And we are supposed to buy this. Had they said it had something to do with electricity or whatever, maybe if they'd tried hard enough I'd bought it. But a computer virus on the power grid? Seriously, do 15min of research before you put that in a movie.

Secondly, as the guy duly explains, the CIA headquarters are well guarded, you can't take anything out of there. That's why the computers don't have disk drives. Yes, that's a quote. What kind of disk drives? Floppies? CDs? Zip drives? And you also can't print anything because they don't have printers. Uh-huh. Well that still leaves about a dozen different media you could use, including usb drives. And what do you know, that's precisely how the super clever villain exports this "virus" out of the building, hiding the usb stick in a coffee mug. Now, your typical computer virus is probably less than 1mb of source code, I mean these things have to be small to go unnoticed. But this mastermind is smuggling it out... in pieces. What do you got there, Photoshop? Like the whole thing wouldn't fit on the usb stick, so you have to do it in turns. Okay cmon, I'm on candid camera, who the hell would believe this?

accused of stooping low for laughs

November 21st, 2007

It was a Friday night. A bunch of us were sitting around a table in a bar drinking beer. Two guys, two women, and myself. The conversation was passing through a quiet period and we were talking about beer or buying beer, something like that. Alluding to how the beer isn't all that cheap. That's when I decided to shoot in with a joke: Well when your glass is starting to empty you could always go to the bathroom for a refill. It will be a little diluted, but hey. [correct for loss of precision in translation]

It wasn't very funny, but hey who can deliver all zingers? Some jokes are mediocre, you either tell them anyway or say nothing.

One of the women smiled, the other one didn't look up from her cell phone, probably didn't even hear it. Just about right. But the guys had a totally different reaction. One stared at me as if in disbelief. The other made a derogatory comment about how classless jokes are part of modern culture.

I was incredulous at the criticism. I had no idea what he meant. I asked the woman who had smiled at it, she didn't get it either. It wasn't until the next day it dawned on me.

What I meant was obviously that if you're running out of beer, you can go to the bathroom, where there is a sink, and fill up your glass with tap water. It would then be diluted, the remaining amount of beer in the glass would mix with the water. This was a natural instinct for me, going back to when we were kids and drank tea, but the tea was hot, so we would fill up half the glass with hot water and the rest with tap water to get the right temperature. The two guys had a different interpretation of the joke. I can't bring myself to spill it out for you, but I think you'll get it soon enough. It was indeed classless.

When I realized the alternative interpretation I was insulted. I have never stooped that low to get a laugh and people who do this.. well let's just say they're "not my kind of people".

So why does this happen? It has to do with cultural background. The same picture shown to people in different parts of the world can trigger very different interpretations based on what kind of world they live in. And we understand why this is so. Just like we interpret or "understand" visual images by the fact that our brain compares them with all kinds of things we have seen in the past, searching for a match, we associate everything we perceive sensually, or intellectually, with things we already know.

So when you're misinterpreted, and someone accuses you of expressing something classless, who is really the embarrassed party?

Jon of ngedit.com recalls how a benign hand gesture he helped spread was discovered to be very similar to an obscene hand gesture, well known in some circles. His rationale is:

If someone does know about the obscene version, then whose fault is it really?

I think making this sort of accusation says two things about you.

  1. The fact that your mind connected you with the obscene alternative, and you didn't discard this and think there must be some other meaning I'm not getting reveals that you are well familiar with expressions of this nature. Whether it is the case that you immediately found the obscene version and stopped thinking about it, or you found both and decided on the obscene version, well neither detracts from the fact that you calculated the obscene version a more probable choice, which says something about what kind of statements are natural "in your world".
  2. The fact that you concluded I had made the obscene statement, taking into account that I have never told jokes like that in your presence (or for that matter at any other time) says something about what you think I'm capable of. It also shows a not so kind hearted willingness to lump me in with a group I don't exactly belong to. No benefit of the doubt given here.

But now in the wider context, what can be said about jokes like this? The woman who had smiled at the joke obviously got the intended message. So telling it to her was harmless. As far as the two guys are concerned, they have themselves to blame for associating what was said with what apparently they are used to hearing. And unintentionally also revealed something about themselves we wouldn't otherwise have known.

There is a choice to make here. Anything you say could potentially be misinterpreted. Sometimes you are aware of this, knowing what kind of material passes for humor. So you can censor yourself and rephrase everything you want to say so that the meaning cannot be twisted. But it's not exactly the most satisfying thing to be unable to express thought directly.

In the alternate case, you say what you wanted to say, and part of your audience may appreciate it, while you give the pathetic people what they want. He said balls hahahahaha *insert a 30 minute veritable battle of wits as your audience tells every joke about balls they can think of as you patiently wait for them to get it over with*. Of course, as a last resort you can shun the bad company. But then, of course, you're not socializing anymore, you outcast you.

However, it's really up to you as a receiver to make the judgment. Personally I like to give people the benefit of the doubt even when I'm fairly sure they meant to be classless. So I don't laugh, I offer an alternative interpretation. At this point you have two choices. You can either admit defeat and save face, or you can persist. Most people persist, and sort of shyly confirm their intentions by rephrasing the joke. Shyly because they hoped the first version would be clear enough without having said too much. But then when they've restated it and I still don't laugh, check mate. No coming back from the fact that you just told an unfunny, classless joke. But hey, I gave you the chance to recover.

tribalism in our time

November 19th, 2007

People get into heated debates all the time, over the same old issues - politics, religion, historical facts, old scores etc. It should be clear enough that people who have a personal stake in the matter, like a member of their family having been wronged for example, have more obstacles to overcome in order to stay objective about the issue. That much is perfectly understandable. But so often we debate things where we have no personal interest, things that we consider to be "good for society" or bad for it. Even so, one really has to make an effort to remain objective in these matters.

While the central objective of debate is supposed to be the search for truth, what we often witness is people digging trenches and sitting in them for the sake of it. What should not come as a surprise is that this kind of strategy is detrimental to the debate at hand. If you aren't willing to give up your position in the interest of making progress in the discussion, then the undertaking is futile.

What is interesting is that people are much more reluctant to give anything up when they have the backing of a front, than when they stand alone as a rational individual. A person with a very strong conviction acquired on his own generally has nothing to lose except to admit the flaws of his own reasoning - which is something we are all willing to concede (some more than others). But take that same person when he identifies himself with a group, and he will require overwhelming, indisputable evidence of the most blatant kind to admit his error. Why is that? Because admitting to be wrong is not only an admission of your own imperfection. It is the first (and sometimes significant) step toward disassociating yourself with your group.

This is tribalism.

It is important for us to belong to something. The very presence of groups in society makes it irregular to stand completely unattached. But these associations come at a price. It gives people a license to stop thinking on their own. And it makes it harder for them to think independently whenever they may want to.

There are many important debates which need to be had, but more importantly need to be resolved. Many of these are stuck in a positional war of trenches, where the same tired arguments are exchanged and responses often come in the form of settling scores. Furthermore, because the debates do not concern people, but groups, they must be made accessible to all members of the group. This is where the issue and the arguments are trivialized and simplified down to a collection of slogans and other sound bites. You and I can have an intelligent argument about something, but if we are to make ourselves understood by our respective groups, we have to dumb it down a lot.

Looking at the hot issues today, this is exactly what we have. There is mac vs pc, pro-life vs pro-choice (what well chosen names too), for-the-troops vs against-the-troops, republican vs democrat (however this one didn't work as well, so they found a more fitting pair in conservative vs liberal), catholic vs protestant vs muslim vs whatever and so on. This is a very effective way of sidetracking the issue into a tribal battle. What matters is not what is true, but who is winning and who is losing. Did Clinton lie about Lewinsky? Did Kerry bad mouth the military? Huge talking points. Meanwhile, let's not care at all about anything remotely important.

As a long time sports fan, I have had the occasion to observe tribalism in its purest form. Just like any other grouping, sports fans have very strong ties to their groups. But what makes it so interesting is how abstract their affiliation is. They pledge allegiance to.. nothing in particular. To an abstract entity of a club, essentially. And their debates are just as vicious and intense as of any group, with the distinction that they aren't really fighting *for* anything. Whether a team wins or loses, global warming continues, people will kill in the name of a god, and we still pay the same taxes. Sports have no influence on society at all. And because this is so, it gives a valuable insight into tribalism, and how predisposed we are for it.

There are further characteristics of sports affiliation. Loyalty is the central principle. You must stick with your team whatever the circumstances may be. And you cannot choose several teams either, to buy yourself some insurance against failure, lest you be labeled an outcast. There are no concrete rules for how to treat disputes with other groups, but in practice these discussions are dominated by self serving arguments and self interest. What's interesting is that the debates that are had are not jaded by the same cynicism you might find in politics, because the underlying principles are still that of athletic excellence and justice. However, sports fans are incurable hypocrites. So even though people express themselves (their teams, rather) in the most noble of terms, there is no actual interest in seeing justice served. The only thing that matters is that my team wins. I say this on the back of a long process of gathering data and trying to disprove the hypothesis of hypocrisy, but alas.

Now, political or religious debates are really no more intelligent, fair, or honest than debates between sports fans. And they are no more incisive or focused either, a big part of it is mud throwing. Very little progress (if any) is made, because people are too busy defending the symbolic banner they are fighting under. Finding truth is a distant second objective.

KVM: the state of the game

November 16th, 2007

KVM is one of those things I've kept an eye open for ever since I heard about it. First of all, I should mention that there is currently a great deal happening on the virtualization front, here's a list of virtual machines to look over. What is more, it is not so much a wealth of competing products, because it seems that everyone has their own little twist on the matter, and none of these are completely equivalent solutions. There is a host of different terms to describe these techniques to boot.

I've known about VMware for 5-6 years, and that is how I originally started out playing around with linux in a safe and easy environment. Since then there have been many linux centric projects that have made waves at some time or another, not all of which I've tried. I think User Mode Linux was the first one I heard about. It ran a modified host kernel and could host multiple guest machines that would also be running a modified kernel. You could use it to host Virtual Private Servers, which has been common now for a while, but wasn't all that common back then. You could also set up honeypots with them. There was also a VMware competitor called Win4Lin (for Win9x) which was like a poor man's VMware. It would run fairly well, but it was far from being equally polished and feature complete. It also had the advantage of being strictly an application, no kernel hooks. A couple of years later there was a new project that was very loud, namely Xen. Xen is one of those odd projects that had a lot of potential and broad support, and yet didn't quite have the kind of adoption one would expect. It was quite a complicated piece of code that required a lot of setting up and so on, but Fedora shipped it by default (I'm not sure if they still do) and it worked out of the box. Again it was a modified host kernel, but the guests could run completely unmodified. I'm not sure how recent this is, but nowadays Xen also runs various operating systems, although in some cases they need to be modified. Then there was CoLinux, which approached the issue from the opposite side of the table: Linux as guest. I never got around to trying it as I never had to use Windows for long stretches of time, but a lot of people (those poor souls trapped on Windows) were very enthusiastic about it.

So what about KVM? Well, KVM is interesting because of how "close to the metal" it is. Obviously, any kind of virtualization adds some overhead due to the unavoidable indirection. But KVM actually does not position itself above the kernel, as most virtual machines do, but uses kernel primitives to host guests (in fact it sets up a whole new kernel execution mode guest for this). It also uses cpu virtualization extensions (current Intel and AMD chips) to gain speed. All of this is fairly recent stuff, KVM was merged into the kernel for 2.6.20. So, of course, the major advantage of KVM is that it's well supported and well tested in kernel mainline.

However, KVM is not a virtual machine in itself, in the sense of being a complete application. It's more like an access layer which exposes a /dev/kvm interface. The way to run KVM is through QEMU, which is actually an emulator. I haven't mentioned emulators so far, but they are in a sense the second type of virtualizer/emulator software. The difference is that a virtualizer creates a virtual machines with virtual hardware (eg. network adapter) for the guest operating system to run on, but the cpu is still that of the host. An emulator instead emulated the guest cpu, and therefore has to translate every machine instruction into a different one. This means that you can run say a powerpc guest on an x86 host. It sounds very cool, but it's orders of magnitude slower, so it's not as much of a hot topic.

But back to KVM. As I said, the application is still QEMU, but it's accelerated through KVM. I had been looking forward to taking it for a spin, especially now that I also have an Intel chip with the virtualizing extensions. On Ubuntu it's all ready to go, just install the userland applications from the repo (qemu and kvm) and you're set. Qemu is quite nice and simple to use, but the combo is temperamental and unforgiving. You can set up your guest machine in 2 minutes, but with Windows I had quite a number of fatal crashes (Exception 13) that aren't that obvious to figure out. Furthermore, it seems that even linux distros aren't trivial to run on KVM/QEMU. In terms of a complete machine virtualization it leaves something to be desired. Notably, the video flickers quite visibly while running on a vesa driver. That isn't to say that other virtual machines cannot or will not use KVM as part of their solution.

But for the time being VirtualBox (something of a lightweight VMware, which is also free software) is more convenient.

Disclaimer: This entry is something of a historical account of my exposure to virtual machines. I did not do any fact checking here, and the statements only reflect what I recall about the particular products.