My /usr/bin/cmp obsession

Few months ago my colleague was having some issues with /usr/bin/cmp. So naturally I thought it would be great to write it in haskell and figure out how the diffutils's cmp works. So I did and somehow I got hooked on this specific piece of code.

Interestingly, turns out the haskell implementation was a bit faster [1] but that's a story that yet needs to happen properly.

Anyway I've been thinking I should learn some assembly programming lately and since I'm having a vacation and don't feel like doing something particularly useful, I thought "Hey, /usr/bin/cmp".

Today, after 7 days and making 3 SSCCEs [2] to figure out how this works, I finally managed to get a basic cmp in nasm x86_64 for linux working.

Yay! Now I know some assembly and 3 implementations of cmp in 3 very different languages. I have more plans with these but now I should get back to doing some useful stuff.

[1] Should be working basicly the same way as the diffutils's cmp. Master right now (ff0de407e17372b33164d96cf825cd83fb9121bb) contains latest (incomplete) experiment with mmap which was more than twice as fast. Both measurements were on 100MB file with last byte changed.
[2]Which you can view and navigate via readmes starting at

dry-run is bad design

I've seen --dry-run to be used and it gets on my nerves as it often horribly degenerates into doing weird things. Being badly documented as it can be used with different options/subcommands in different ways and sometimes it gets into commands where it just can not work as it's fundamentally impossible to generate the whole effects pipeline without executing at least part of it.

I have come to conclusion that --dry-run is Application Interface Smell. It may seem like a good idea at first to just add dry run but it is completely meaningless without context. At first, you have the context. But as your application grows the context vanishes.

There is a program flaggie for gentoo which helps you manipulate use flags and keywords and stuff. It has no dry-run and it has the following interface:

flaggie [<options>] [<global-actions>] [<packages> <actions>] [...]

      --drop-unmatched-flags  Drop flags which are not found in package's
                              IUSE, KEYWORDS and/or LICENSE variables

I have not used this option yet so I don't know what it does for sure but I presume it just deletes the matched entries in your /etc/portage/package.use.

You might be tempted to add --dry-run to just show what it is going to delete. Instead, I want you to consider your application interface design. Why not …:

flaggie unmatched-flags drop
flaggie unmatched-flags show

Real Steel. Real Frustration.

I'm gonna take this step by step, so this is basicly one big spoiler.

First we can see that Jackman gets into a fight against a bull and while I'm no expert on bulls I guess it's not a complete nonsense considering the bull is double the Ambushes weight. We don't hear the number for Ambush but we know it's about half a metric ton for Atom. By the way, it's also about the weight of one testicle of largest whales, at least according to this article.

However, I think bulls are used to fight other meaty things with their horns, not rock hard steel boxes by ramming them harder. So yeah, I think the bull would get flattened by that hit in the head.

So while I'm thinking this is absurd, Jackman let's the bull rip Ambush apart by being a moron with ADHD and not paying attention.

Then Jackman gets lucky, goes and buys the Noisy Boy. A repaired fighting robot. And then tests it without any precaution whatsoever, standing just a few meters away. And then he goes and trashes it too by making a stupid cocky decision without any training with the new bot and new interface.

And the interface. Oh boy the voice interface. Why would you use that? Isn't that obviously slower and less versatile than the remote control? But oh well, besides the shadowing, the whole control thing is totaly unbeliavable but I can give that the benefit of the doubt.

Now this is the part where we can see that Jackam seems to think that only the tool makes the craftsman while Max seems to understand that altough the tools are important, it's more about the craftsman than the tool.

The Max manages to get himself a robot but first he needs to be rescued from certain death by Jackman pulling him up by his hands from a robot arm Max hangs on. In heavy rain. Covered in mud. Yeah, I'm sure he wouldn't just slip out of this grasp and died in the fall.

Anyway, Max decides he wants that robot but Jackman fucks him over and he still gets that robot. How does an eleven years old boy get a thousand pounds heavy robot out of a muddy ditch in a scrap yard all by himself?

Anyway, he gets it and wins his first match. So at this point I'm thinking that while Jackman is the poster boy, the main character is really Max and I'm starting to think I might actually enjoy this movie.

However, it turns out this was Max's first and only match to fight as Jackman gets the control for the rest of the movie. And this is very frustrating not that only he controls the robot, but also gets into discussions with Max during the fights. Should he, I don't know, maybe rather focus on the fight? And mainly, who's the main character now? And how come Jackman is suddenly not such a moron anymore? I'm confused.

Then it turns out Jackman have been an actual boxer before and even pretty good one. He just needed a little boy to tell him he should use the same techniques with the robot fighting. Which would have been his first instinct to do when starting with the robot fighting. That's where the whole story logic gets flushed down the toilet.

Then we get the numerous parts where seemingly dead robot is able to fight again after some magical talking to by Max. That's one annoying cliché.

And in the final fight we can see Jackman can actually have some patience and see that Zeus is "tired" though I haven't noticed such clues but I could have if I knew anything about boxing but even then I'd probably think it weird since these are robots which just don't "look tired". Anyway, Jackman's patience is strange since Jackman seems to be rather trigger happy in his decision making at the start of the movie.

What is worst is that it could have been a pretty good underdog movie but it's just confusing.

Page 1 / 3 »