Blog
This is my infrequently-updated pseudo-blog containing whatever random text I felt like writing. Send constructive comments to and flames to /dev/null.
2009-05-01: Dating questionnaire
I got turned down again. So instead of going for a bike ride along the river with the young lady in question, I got bummed out and wrote this:
You've been given this questionnaire because of your recent failed dating experience with. In order to assist in better serving future potential partners, please check all boxes that apply and return this questionnaire to . [ ] I have a boyfriend, and he's going to kick your ass! [ ] I'm gay. [ ] I'm looking for a knight in shining armor. Literally. [ ] You didn't bring flowers. [ ] You smell funny. [ ] I'm not into guys. (Please specify: ____________________.) [ ] I always put out on the first date, but I was in the middle of my period. [ ] You call that a date!? [ ] You're too cheap. [ ] You're just too white n' nerdy. [ ] Hey! I'm up here! [ ] It's not you; it's me. [ ] Wait, who are you again? [ ] I've taken a vow of chastity. [ ] I've seen more emotional robots. [ ] My daddy doesn't let me date. [ ] I'm not interested in a relationship at this time. [ ] Everything was going great, but then you ________________________________. (Please fill in the blank.) [ ] Get lost, you creep. [ ] I would have LOVED to have gone out with you, but I had to, um, water my house plants. [ ] You're too submissive, and I like dominant guys. [ ] You're too dominant, and I like submissive guys. [ ] On second thoughts, how about next Tuesday? [ ] Before dating me, you must serenade me with sonnets from outside my window under a full moon, then climb up to my window with a dozen long-stem roses held between your teeth. [ ] I'm actually a man. Didn't you know? [ ] You're not in love with me; you're lusting after an illusion. [ ] I killed my last five boyfriends, but I like you too much to eat. [ ] I wasn't sure before, but now that I've seen this questionnaire, I'm happy with my decision. [ ] You're not rich enough to fund the lifestyle that I want. [ ] You're ugly. [ ] I misinterpreted your ill-advised attempt at humour as a deliberate insult and will now hate you forever. [ ] Let's just be friends. [ ] Other: __________________________________________________________________. Thank you for your honesty.
Feel free to download and distribute that. Now, I'll try to return to carefree bachelorhood before I turn all emo.
2008-12-22: Christmas odyssey
I was supposed to be at my parents' place yesterday morning, but I'm back in Redmond. My flight to Calgary was supposed to leave at 21:25 on the 20th; that was cancelled due to snow and high winds. I then spent 3.5 hours in line at the customer service desk, at which point it closed and we were told that we were basically all screwed: the airline didn't have any more seats available until after Christmas. Oh, unless we happened to be headed to Canada, in which case we should get in line when the desk re-opened at 05:00. So I ate airport fast food for dinner, slept four hours (not very well due to lights, constant movement, floor polishers, periodic announcements, etc.) on a bench and got back in line at 05:00. There was already an extensive line at that point, and it didn't start moving until 06:00. At 07:30, I got a boarding pass to a plane that was supposed to leave at 10:20. That was delayed, delayed, delayed, delayed, delayed, and finally cancelled at 14:00. So I got back in line. After another two hours (making a total of over 8 hours in that pestilential line, I got a ticket for a flight on the 23rd -- to Edmonton. (They couldn't put me in Calgary until the afternoon of the 24th.) I'll arrive too late in the evening for me to be able to catch the Greyhound, so my options are to buy another plane ticket to Calgary (assuming that one is available) at a minimum of $150, or rent a car and drive it to Calgary (also at a minimum of $150 + fuel). But if I can make it to Edmonton, I can get to Calgary one way or another; they don't shut down roads or airports in Alberta unless the weather is much worse than this, and if that flight is cancelled, I might still have another chance to get out of here before Christmas. I took the bus home after 26 hours in that airport and am now back in my apartment in Redmond with practically nothing in the fridge.
I did get to witness some ethanol-impregnated gentleman who became belligerent over the issue of his cancelled flights; the cops eventually Taserred him.
The weather today was slightly below freezing and periodically snowing lightly. In other words, a beautiful winter day by the standards of most of Canada and much of the northern US. But Seattle doesn't know how to deal with snow; it's strategy appears to be "Wait until it melts". The rumour around the airport was that not only their two shovels and half a snowplow couldn't keep up with the snow fall, but that they also ran out of de-icer. Apparently, their reserve supply is on the other side of the mountains, which doesn't help much when the passes are closed. We currently have something like 20 cm of (dense, wet) snow on the ground, which I've heard described as the heaviest snow fall since at least 1996 or 1991.
On the plus side, this doesn't suck nearly as much as losing a job right after buying a house, as recently happened to a friend of mine.
2008-10-17: Microsoftese 101
The following are terms and expressions that are regularly used at work whose meanings were not immediately clear to me:
- enlist: (verb, transitive, origin unknown) To check out sources for a project from the local revision control system. "You need to enlist in wordmetrocnv to build the Word converters."
- enlistment: (noun, origin unknown) A source tree and build environment. "Do you have an Office 11 enlistment?"
- raid: (verb, transitive, from "RAID", an old bug tracking system) To enter a bug in the bug tracking system. "Go raid a bug for that."
- punt: (verb, transitive, from gridiron football terminology). To resolve a bug without fixing it. "It's not worth the effort to fix that bug. Punt it."
2007-05-28: Linus Torvalds is WRONG!
On 2002/11/04, in a LKML posting titled "Filesystem Capabilities in 2.6?", Linus Torvalds made the following claim:
In other words, "execve(/proc/self/fd/xxx)" does work and is exactly the same as fexecve().
He's wrong. If a root-owned process opens a file, calls setuid()
to drop privileges, and then tries to emulate a proper fexecve() implementation by calling execve("/proc/self/fd/xxx")
as above, it will fail, because the process no longer has read access to /proc/self/fd
.
Come to think of it, ownership of files under /proc/self
should probably change when setuid()
is called. This might actually be a bug in procfs.
IMHO, if Linus wants to limit the number of system calls in Linux, he'd be better off implementing fexecve()
in the kernel and moving execve()
to userspace. It's a very common, and inherently unsafe, design pattern to call stat()
or something on a file before calling execve()
; making fexecve()
the primary interface and emulating execve()
might encourage people to do things the safe way.
For that matter, the same argument holds for stat()
and fstat()
. How often does a program check the properties of a file without doing anything else to it, anyway? It's not possible to design a system that's both useful and cannot be misused, but with a little thought, a system can be designed to encourage correct and safe usage.
2006-08-31: Unix idiocies
In general, UNIX and its derivatives are great systems. However, you really have to wonder what some of its designers were thinking when they came up with some of these gems:
- The "error" syslog level is abbreviated as LOG_ERR, but the "warning" level is not abbreviated; it's spelled out as LOG_WARNING. Some of the other levels are abbreviated, but even those abbreviations are often just as long as "error" spelled out.
- In the BSD socket API, the send() family of calls all take an unsigned integer as a parameter indicating how many bytes to send. The value returned is the number of bytes actually sent - but this is a signed integer. Thus, the API will accept requests for which it cannot report success. Granted, I'm not aware that any system that actually exists can send more than 231-1 bytes in a single call, but sooner or later, someone will try to build one.
- There are at least six library functions for creating temporary files:
mkstemp()
,mktemp
,tmpfile()
,tmpnam()
,tmpnam_r()
, andtempnam()
. All of these are required for compliance with a variety of standards, including SVID, 4.3BSD, POSIX, ISO 9899, and SUSv2. Unfortunately, onlymkstemp()
is safe to use - and that's only if the file name that it returns is never used. The rest are vulnerable to race conditions and should never be used.
2006-08-23: Things that I'd change in C, if I could
I'm primarily a C programmer. It's not the best language for everything, but it is the best (or at least good enough) for most of the stuff that I do. That said, however, there are a number of things about C that I'd love to change:
- Make type declarations of pointers work like everything else. If I say
int* a, b;
, then botha
andb
should be pointers; currently,a
would be a pointer toint
andb
would be anint
. Similarly, I'd makeconst int const* a
aconst
pointer to aconst int
, rather than the current syntax ofconst int* const a
. - Provide functions for "safe integers", where an integer overflow results in an error flag being set somewhere. It's not too hard to manually check for integer overflows, but it is a pain in the astrae, so a standardized mechanism would be nice. Actually, a hardware exception (similar to a floating-point "divide-by-zero" exception) for integer overflows that can be enabled if desired would be even better, but this requires changes to more than just C.
- Disallow programmers from assigning arbitrary integer values to enumeration variables. Most other languages that support something resembling
enum
types get this right, but since an enumeration variable in C doesn't necessarily have a valid value for the type, you have to add error-checking code. Because of this, there's really no difference betweenenum
types andint
s with lists of constants defined using#define
. (I realize that there's no good way to fix this issue, short of adding something like run-time exceptions to the language.) - Get rid of
struct
tags and related constructs. (Or, if you prefer, get rid of typedefs for structs, enums, etc.) Right now, I can define a struct astypedef struct foobar {int a;} foobar_t;
and refer to the type as eitherstruct foobar
or asfoobar_t
. This duplication is pointless; I should be able to simply define the type asstruct foobar_t {int a;};
and refer to the type asfoobar_t
. C++ and most other languages derived from C got this one right. - Add a namespace system.
#include
and command-line linker parameters work, but are a nightmare for portability. They're also prone to namespace collisions. I'd like to see something similar to Java's namespace system added to C, to prevent namespace collisions and provide a platform-independent way to locate global declarations and libraries. - Get rid of some of the obsolete, dangerous cruft in the standard library. The C library still supports stuff like
gets()
that should never be used under any circumstances, plus a lot of stuff likestrcpy()
whose use is dubious at best. Sure, the documentation says to never use them, but as long as they're there, someone will.
2004-03-15: Beefs with Java
While Java is useful for certain tasks, it has some serious design issues that make it awkward for general-purpose use:
- There is no linker; trivial classes are still required to have their own source and object files. Even anonymous inner classes get dumped to their own separate object (.class) files. It gets really annoying having to keep track of dozens of files each containing trivial 10-line classes (exceptions, etc.).
- You can't explicitly destroy an object, and can't guarantee when or even if finalize() methods get called. This effectively prevents anything useful from being done in finalize() methods. This means that if you need something to happen (other than memory deallocation) when you're done with an object, you have to make an explicit method call, but still have to put up with the overhead of the garbage collector. In C++, you can simply put code in the destructor and do both at once.
- Some conceptually similar classes have subtly different interfaces (ArrayList and Vector, for example).
- There is no unsigned integer type. Array indices can't be negative, but Java supplies no non-negative type to use.
- javac uses shell meta-characters in the names it generates for anonymous inner classes (ie, an inner class in Display.java might get named Display$1.java). This is hell for scripting. javac offers no option to output a jar file, so scripting is necessary for building a non-trivial program into a jar file.