Fun with UB in C: returning uninitialized floats

The average C/C++ programmer's intuition says that uninitialized variables are fine as long as you don't depend on their values.

A more experienced programmer probably suspects that uninitialized variables are fine as long as you don't access them. That is, computing c=a+b where b is uninitialized is not harmless even if you never use c. That's because the compiler could, say, optimize away the entire block of code surrounding c=a+b under the assumption that c=a+b, where b is proven to be always uninitialized, is always undefined behavior (UB). And if it's UB, the only way for the program to be correct is for this code to be unreachable anyway. And if it's unreachable, why waste instructions translating any of it?

However, the following code looks like it could potentially be OK, doesn't it?

float get(obj* v, bool* ok) {
  float c;
  if(v->valid) {
    *ok = true;
    c = v->a + v->b;
  }
  else {
   *ok = false; //not ok, so don't expect anything from c
  }
  return c;
}

Here you return an uninitialized c, which the caller shouldn't touch because *ok is false. As long as the caller doesn't, all is well, right?

Well, it turns out that even if the caller does nothing at all with the return value – ever, regardless of *ok – the program might bomb. That's because c could be initialized to a singaling NaN, and then say on x86, when the fstp instruction is used to basically just get rid of the return value, you get an exception. In release mode but not in debug mode, some of the time but not all the time. This gives you this warm, fuzzy WTF feeling when you stare at the disassembled code. "Why is there even a float here in the first place?!"

How much uninitialized data is shuffled around by real-world C programs? A lot, I wager – likely closer to 95% than to 5% of programs do this. Otherwise Valgrind would not go to all the trouble to not barf on uninitialized data until the last possible moment (that moment being when a branch is taken based on uninitialized data, or when it's passed to a system call; to not barf then would require some sort of a multiverse simulation approach for which there are not enough computing resources.)

Needless to say, most programs enjoying ("enjoying"?) Valgrind's (or rather memcheck's) conservative approach to error reporting were written neither in assembly which few use, nor in, I dunno, Java, which won't let you do this. They were written in C and C++, and most likely they invoke UB.

(Can you touch uninitialized data in C without triggering UB? I seriously don't know, I'm not a language lawyer. Being able to do this is actually occasionally useful for optimization. Integral types for instance don't have anything like signaling NaNs so at the assembly language level you should be fine. But at the C level the compiler might get needlessly clever if it manages to prove that the data is uninitialized. My own intuition is it can never prove squat about data passed by pointer because of aliasing and so I kinda assume that if I get a buffer pointing to some data and some of it is uninitialized I can do everything to it that I could in assembly. But I'm not sure.)

What a way to make a living.

 

 

Accidentally quadratic: rm -rf??

This is a REALLY bad time. Please please PLEASE tell me I'm not fucked…

I've accidentally created about a million files in a directory. Now ls takes forever, Python's os.listdir is faster but still dog-slow – but! but! there's hope – a C loop program using opendir/readdir is reasonably fast.

Now I want to modify said program so that it removes those files which have a certain substring in their name. (I want the files in that directory and its subdirectories, just not the junk I created due to a typo in my code.)

HOW THE FUCK DO I DO THAT IN O(N)??

O(N^2) is easy enough. The unlink function takes a filename, which means that under the hood it reads ALL THE BLOODY FILE NAMES IN THAT DIRECTORY until it finds the right one and THEN it deletes that file. Repeated a million times, that's a trillion operations – a bit less because shit gets divided by 2 in there, but you get the idea.

Now, readdir gives me the fucking inode number. How the FUCK do I pass it back to this piece of shit operating system from hell, WITHOUT having it search through the whole damned directory AGAIN to find  what it just gave me?

I would have thought that rm -rf for instance would be able to deal with this kind of job efficiently. I'm not sure it can. The excise function in the guts of coreutils for instance seems to be using unlinkat which gets a pathname. All attempts to google for this shit came up with advice to use find -inode -exec rm or some shit like that, which means find converts inode to name, rm gets the name, Unix converts the name back to inode…

So am I correct in that:

  • Neither Unix nor the commercial network filers nor nobody BOTHERS to use a hash table somewhere in their guts to get the inode in O(1) from the name (NOT A VERY HARD TASK DAMMIT), and
  • Unix does not provide a way to remove files given inode numbers, but
  • Unix does unfortunately makes it easy enough (O(1)) to CREATE a new file in a directory which is already full of files, so that a loop creating those bloody files in the first place is NOT quadratic?? So that you can REALLY shoot yourself in the foot, big time?

Please tell me I'm wrong about the first 2 points, especially the second… Please please please… I kinda need those files in there…

(And I mean NOTHING, nothing at all works in such a directory at a reasonable speed because every time you need to touch a file the entire directory is traversed underneath… FUUUUUCK… I guess I could traverse it in linear time and copy aside somehow though… maybe that's what I'd do…)

Anyway, a great entry for the Accidentally Quadratic blog I guess…

Update: gitk fires up really damn quickly in that repository, showing all the changes. Hooray! Not the new files though. git citool is kinda… sluggish. I hope there were no new files there…

Updates:

  • `find fucked-dir -maxdepth 1 -name "fuckers-name*" -delete` nuked the bastards; I didn't measure the time it took, but I ran it in the evening, didn't see it finish in the half an hour I had to watch it, and then the files were gone in the morning. Better than I feared it would be.
  • As several commenters pointed out, many modern filesystems do provide O(1) or O(log(N)) access to files given a name, so they asked what my file system was. Answer: fucked if I know, it's an NFS server by a big-name vendor.
  • Commenters also pointed out how deleting a file given an inode is hard because you'd need a back-link to all the directories with a hard link to the file. I guess it makes sense in some sort of a warped way. (What happens to a file when you delete it by name and there are multiple hard links to it from other directories?.. I never bothered to learn the semantics under the assumption that hard links are, um, not a very sensible feature.)

"Information asymmetry" cuts both ways

They pretend to pay us, and we pretend to work.

 – A Soviet-era political joke according to Wikipedia, though I've only seen it in an English text describing the C++ object model

Having been born in the USSR, #talkpay – people disclosing their compensation on May 1 - put a series of smiles on my face, expressing emotions that I myself don't quite understand.

The numbers certainly left me pleased with the state of the oppressed proletariat (web designers, computer programmers, etc.) in the rotting capitalist society. I do hope that the $125K/year proletarian will not feel resentment towards the $128K/year guy in the next cubicle. I hope as well that the second guy's manager won't deny him a promotion so as to avoid further offending the first guy.

"Hope", yes; "count on" – no, which is why I won't be tweeting about my compensation. Because my numbers are almost certainly either lower or higher than yours, and why needlessly strain our excellent relationship – am I right, dear reader? (The other reason is having no Twitter account.)

So, yeah, a series of smiles and a range of emotions. But today I want to focus on one particular bit – the one mentioned by Patrick McKenzie:

Compensation negotiations are presently like a stock exchange where only your counterparty can see the ticker and order book. You’d never send an order to that exchange — it would be an invitation to be fleeced. “I happen to have a share of Google and want to sell it. What’s it go for?” “Oh, $200 or so.” “Really? That feels low.” “Alright, $205 then, but don’t be greedy.”

The spot price of Google when I write this is $535. Someone offering $205 for GOOG would shock the conscience. …folks have received and accepted employment offers much worse than that, relative to reasonably achievable market rates.

All very true, except that with a share of Google, they're all the same and you arguably know what you're buying, and with an employee's services, they aren't and you don't.

There seems to have been a string of Nobel Prize-winning economists who founded "X economics" – such as "behavioral economics" or "information economics." The common thing between "X economists" is, they all (correctly) tell me that I'm irrational and misinformed. But then they conclude that it's them and not me who should manage my money. I believe the latter does not follow from the former. But I'll save that discussion for another day.

In particular, Stiglitz, the information economics guy, opened his Nobel Prize lecture with an explanation of his superiority over other economists. This state of things arose, according to him, due to having grown up in a small town in Indiana, where things didn't work as predicted by standard economic models. Specifically, the proletariat got shafted, prompting Stiglitz to come up with formulas predicting how badly one can be swindled due to his ignorance of the market conditions.

Which is probably very true and relevant, but it cuts both ways. A guy paying me to work on a conveyor belt could measure my productivity perfectly, and probably knew the market for my labor better than I did – clearly he had an advantage. A guy paying me to program, however, might know more about wages than I do. But he certainly doesn't have the foggiest idea what I'm doing in return for his money, even if he's a better programmer than I am.

Basically the "knowledge worker's" contract is something like this:

We'll give you a precisely defined salary and a benefits package. In return, we request that you handle some problems that we're told we're having. We hope that you'll solve them well enough to prevent us from having to know what they were in the first place. Please help us maintain the feeling that we own an asset similar to land or gold or something. Please keep the realization that we're more like the operator of a flying circus than a landowner from disturbing us. And certainly, never, ever ask us what to do with any of the moving pieces of this flying circus, because we seriously have no idea.

Of course, most people have a direct manager overseeing their work in the flying circus who knows more about it than the owner. But, ya know… "…then for the next 45 minutes I just space out", as the quote from Office Space goes. Seriously, it's bloody hard to tell if you're only working at half your ability – the only guy who knows is you. And this information asymmetry seems to me kind of symmetrical with that other asymmetry – employers being better at tracking the labor market, negotiating, etc. So, see the "Soviet" joke at the top of the page…

(Of course it's much better with an actual market for labor – I'm just saying that it's still far from perfect, and it'll get increasingly farther from "perfect" as the knowledge becomes more widely dispersed and you basically just have to trust experts at every step. An economy of dishonest experts – now that's a bloody nightmare. And by the way I actually think we now have enough newfangled technology together with ages-old fallibility to get there. AAA-rated MBSs is just the beginning.)

For a closing remark, I think it's fitting to mention all those bozos saying how "higher compensation does not increase motivation." (A management consultant saying something else might not get his management consulting gig, so I understand where they're coming from.)

To that I say: for me, at least, higher compensation leads to higher awareness of "spacing out" and such – call it "guilt" if you like. Pay me enough and I will think things like, "I'd really like to ignore this here shit, and it's SO ugly, and nobody will ever know. But, sheesh, they paid me all this money, just like they promised. And I sorta promised that I'll take care of the flying circus in return. And so it's seriously not OK to leave this here shit unattended. I better tell someone, and what's more, this here patch is definitely mine to clean, so here goes."

One danger in underpaying someone is it might prevent those thoughts from entering their minds. So, employers – caveat emptor. 'Cause goodness knows that the easiest way to raise one's compensation in the knowledge economy is to simply space out more while getting paid the same.

#talkpay…

A "WTF is that sound" widget

A core function of an OS is dividing resources between apps: multiple windows per screen, files per disk, sockets per Internet connection, etc.

The machine's goddamned SPEAKER is one of those resources.

Now let's say you're working at your desktop. Your boss walks in for a chat. And now, midway through the conversation, your computer's goddamned speaker emits something like: "Major breakthrough reached at the G-20 meeting!", or "I came in like a wrecking ball!", or "Aaaah… ah! yeah, right there… AAAGH!!"

Your computer might have said it because you're watching news, or that other stuff, instead of working. Alternatively, perhaps some uninvited pop-up popped up an hour earlier - and then decided to self-activate at the worst possible moment.

Either way, it'd be nice to be able to shut the thing off quickly – say, right after "Hi, I'm Wendy" and before it gets to "yeah, right there." And not only that, but you might want to kill the app without giving focus to its window, because who knows what Wendy's up to in that window.

Now, closing a window or deleting a file is easy, because you have a visible handle to click on. Not so with sound, unfor-tu-nate-ly. Big mistake on behalf of OS designers, says I… BIG MISTAKE.

And that, folks, is the perfect use case for a "WTF is that sound" widget. I haven't figured it out down to an actual mockup or anything, but, ya know, it'd be a list of who the FUCK is using the GODDAMNED SPEAKER. "Who the fuck" might be a list of window titles – or maybe not, because you might not want a title like "Erm erm Wendy erm ahem". So it might be a list of app names without the window titles. Most importantly, if just ONE app is using the goddamned speaker, then there'd be just one red button that you press to KILL the fucking thing.

I'm hereby placing the idea in the public domain. Now go ahead and make {the world a better place, billions, an abandoned GitHub project implementing this dumb idea}.

P.S. I'm fine, thank you, but yes, the inspiration comes from real life, and no, it was neither Miley Cyrus nor Wendy, but a weird tune without words that ended as mysteriously as it commenced, and I still don't know what played it.

Update: no, it's not like a mute button. If we're seriously being serious about it, then pressing a mute button is like turning off the screen. When the boss walks in and there's a noise and you mute everything including the ambient music it's off, just like pressing the screen's off button would be off. More seriously, if you have umpteen apps and tabs and shit and something starts to emit sound and you don't know what that is, then a mute button doesn't help you, not if you want to listen to anything else at the same time which you might want to. So you need a "sound manager" just like you need a window manager. (Imagine having to guess which of the umpteen [x] buttons to close to make a particular window disappear. Sucks, right? Exactly the situation with sound, which, if it doesn't happen to be synced to video playing in some window, comes from fuck knows where – and even if it's synced to video, you must sift through windows to find that video! Why can't the window/tab/whatever at least have an indication of "sound is being emitted by the sucker who opened me"? Seriously, it's just dumb.)

A Sokoban levels design programming contest

I hate puzzles with a passion; I think of them as Gordian knots best untied with a sword, a machine gun or whatever else you can bring to bear on the problem.

The world of computer programmers, however – the world which I entered with the sole purpose of working for the highest bidder – is a world full of people who sincerely love puzzles. And if you visit this blog, perhaps you're one of these people.

If so, you might be pleased to learn about the recently launched Sokoban levels design contest, operated by gild – a great hacker, my long-time co-worker, an IOCCC winner, and a participant in Al Zimmerman's programming contests which he cites as inspiration for his own new contest.

The rules are precisely defined here; the general idea is to design Sokoban levels falling into different problem classes. Submitted levels are scored based on the length of the shortest solution (longer is better), and normalized s.t. the level taking the most steps to solve right now gets the score of 1. With 50 problem classes, the maximal overall score is 50. But with all the other cunning contestants submitting their own levels, your levels' score might be dropping every day or hour!

And I really mean every day or hour – even now at the very beginning there are several submissions per day. Judging by the rankings page, people spread around the globe are busy improving their Sokoban level-designing software and resubmitting better solutions. (Or they might be doing it in their heads; you don't need to submit any code, just the levels. I hear that occasionally a contestant using no software at all gets a rather good result in an Al Zimmerman's contest… What happens inside the heads of such people I don't know.)

There's also a discussion group, and if you're among the cunningest, most tenacious puzzle lovers who'll get to the top, you'll get – guess what? – a puzzle! Specifically, a gift card which you can use to buy, say, this Rubik's cube – or rather a Rubik's fuck-knows-what. I guess cubes are for sissies:

I personally think it's a bloody cool community/subculture to be in; a pity that I don't quite have the brains for it. (Could I hold my own if I really liked it? Or maybe I would really like it if I could hold my own? These are the types of questions it all brings to my mind.)

Anyway – if you're that sort of guy, it looks like a great thing for your brain to chew on. Good luck!

We're hiring

On behalf of easily the hottest computer company in Israel right now (self-driving cars, big noisy IPO, etc. etc.), I'm looking for people in the two areas I'm involved with:

  • software infrastructure / host tools
  • chips / hardware-software co-design

If you're a strong programmer, especially one who's also interested in math/vision/learning or low-level/hardware/optimization or both, you'll probably find enjoyable stuff to do. It looks like there's still plenty of room for growth, which usually means a lot of work to choose from. On the other hand, there's no risk of "wasting" your effort on a product which might never ship.

If you aren't a programmer but a hardware hacker (experienced in ASIC/FPGA or just straight out of school), we're hiring for these positions as well – I'll forward your CV to the relevant people.

People who work autonomously are a great fit, and they tend to like us - we gladly dial the extent of management down to near-zero levels when appropriate.

Also, I'd love to find people who tend to be at the center of things working with others – though there's always something in stock for people who'd rather spend time alone with a worthy problem.

Relevant experience – might be a plus of course, but not a must.

Send email to Yossi.Kreinin@gmail.com, and tell your friends. Seriously, one never knows and it's kinda awkward to sell vaguely described positions at a personal blog, but I think it can be a really nice opportunity.

Update: I should mention that we're in Jerusalem and while working from another location is not impossible, it's an extremely rare arrangement. So if you don't plan to relocate and send your resume nonetheless, I might have nothing to offer even though you sent a perfectly good one.

(It so happens that most resumes come from abroad. Blogging in Hebrew would make posts about open positions more effective, I guess; it turns out that people tend to mostly read in their mother tongue. I find it rather weird – I mean when it comes to computing where the terminology and even the code is in English, so writing about it in another language is invariably awkward. The fact remains, however, that most of my readers are from the US and the UK… Had the British Empire conquered four quarters of the world instead of just one, certainly language-wise life would have been simpler for us all.)

Capital vs labor: who risks more?

AFAIK, in the developed world, the income tax rate is often higher than the capital gains tax. In particular, income is taxed "progressively", meaning that higher income results in a higher rate – which doesn't always happen with capital gains. (It looks like it does happen in the US, but income appears to be taxed "more progressively".)

One justification for this is that investors risk losing much or all of their capital. Workers, on the other hand, are guaranteed their wages. To some extent, the difference in the tax rates compensates for the difference in the risks.

To me this is sensible at first glance but completely harebrained on second thought:

  • The worker's big risk is choosing the profession. Higher-income professions often require a more expensive education. If the demand for the skills drops in the future, the income might fail to cover the worker's investment into acquiring these skills. Assuming that learning ability drops with age, the risk increases proportionately.
  • Moreover, this risk is not diversified. Even a small-time investor can spread his risk using some sort of index fund, betting on many stocks at a time. For a worker, on the other hand, there's no conceivable way to be 25% lawyer, 25% carpenter, 25% programmer and 25% neurosurgeon.

The latter point may not interest utilitarian economists focused on GDP "the greatest good for the greatest number" – for society as a whole, risk is always diversified, even if Joe Shmoe is stuck with the crummiest profession that looked really promising when he chose it. Moreover, an efficient market would provide a way to insure against the risk of poorly choosing your occupation. (I don't think real-life markets did provide such a thing, though I might be mistaken.)

But the first point – that the risk exists, and that it's more likely than not to be proportionate to the projected income – by itself kinda erodes the ground underneath an income tax higher than the capital gains tax, not? I mean, regardless of the motivation, it seems internally inconsistent. Unless the risks are all quantified and it all magically cancels out.

It's not that I'm complaining – unlike most professionals, we programmers get stock options. (Speaking of which - central bankers of the world, The Programmers' Guild says thanks a bunch for QE and ZIRP! Remind us to send some flowers.) I just honestly don't get it.

Econ-savvy readers: what do I miss?

(Please don't accuse me of failing to use the Google. Maybe I did so badly, but I did try using the Google. The Google told me, for instance, that the optimal capital gains tax is zero, because "you can't transfer from capitalists to workers", because the transfer depletes the capital pool or something. But I didn't understand how it accounts for the case where the workers are also capitalists because they invest their savings; and what if there's a progressive tax on capital gains? Is it, or is it not possible to "transfer from capitalists to workers" the flesh and blood people, as opposed to abstract categories, regardless of whether you'd want to? Or if that's all nonsense – then is the optimal income tax also zero, because, hey, you're actually taxing human capital gains? Bringing us back a couple hundred years ago where we just have a sales tax? And again, not that I'd complain, I just don't quite follow the logic.)

(Also from the Google there's the claim that since nominal capital gains are taxed, the tax rate is actually higher than it looks because of inflation. But then the solution would be to tax inflation-adjusted gains, not to lower the rate arbitrarily, not? Also, wages are AFAIK the last set of prices to rise upon inflation – the "stickiest" – so workers' investment in their skills is continuously nibbled at by inflation as well. And the point made about "discouraging savings" – well, a high income tax discourages costly education and the subsequent ongoing investment in one's skills, which is a form of investment/savings/call it what you like. Same diff.)

I think it's pretty obvious that workers risk much more than investors. Whether this should lower their taxes I don't know, but it sort of makes sense to me.

Do company names actually matter?

This is a bit of a trite thought, but: Can it be that company names actually matter? Consider some examples:

  • Microsoft:  stands for "microprocessor software". Still the dominant software vendor for descendants of the original microprocessor. Never made commercially successful hardware.
  • Intel: stands for "integrated electronics" (chips.) Upon commoditization of DRAM, successfully pivoted to microprocessors – a harder-to-design, easier-to-differentiate kind of chip. Growth slowed when less "vertically integrated" competitors emerged, with both chip manufacturing (fabs) and circuit design/"IP" (CPUs, GPUs etc.) getting commoditized (TSMC + ARM is cheaper than Intel.) Had/has a consumer product division which was never successful.
  • Google: "a very large number", does "things that scale". After its original service, web search, had success with webmail and a smartphone OS. Not known for particularly attentive customer support (support doesn't scale.)
  • Amazon: "plenty", does "things that scale". Originally an online retail company, had success with e-book readers and "cloud infrastructure". Does everything it can so you never have to talk to support, which doesn't scale.
  • Samsung: "three stars", the world "three" representing "big, numerous and powerful". Indeed they are, in a wide variety of areas.
  • Facebook: a one-product company. Buys up other messaging, sharing and social networking companies so people can't flock elsewhere. Facebook phone tanked.
  • Twitter: another one-product company.
  • Apple: name stands for sweet stuff (say loyal users to befuddled me.) Used to be called "Apple Computer", renamed to plain "Apple" in 2007. Successfully incorporated device and chip design, server- and client-side software and retail into its business.
  • IBM: international business machines. A long-time near-monopoly in business computing, still going relatively strong in data storage systems, job schedulers and other corporate IT stuff. No considerable success in any consumer market despite the IBM PC being the first wildly successful computer for consumers (PC division eventually sold to Lenovo.)
  • The Walt Disney company: vigorously lobbies for copyright protection for characters created during Walt's days. Few characters created after Walt's death are nearly as successful; arguably the most successful ones came from acquiring Pixar, Marvel and Lucasfilm. Money spent on buying Pixar probably could have been saved if the company didn't fire John Lasseter but instead let him develop his ideas about computer animation. Would Walt have failed to see the potential?
  • Toyota: originally "Toyoda", a family name. Today's CEO is a founder's descendant. The founder's first name is not in the company's name. The company does not seem weakened by the founder's demise.

Some of my Google/Wikipedia-based "research" might be off. And I doubt that founding a company called "Huge Profits" would necessarily net me huge profits. However:

  1. The company name often reflects founders' vision.
  2. Such a vision doesn't change easily, especially if a company is successful – because success is convincing/addictive, and because an organization was by now built around that vision.
  3. Once the founders are gone, the vision becomes even harder to change because nobody has the authority and confidence. (Indeed one way in which organizations die, IMO, is through the continuous departure of people with authority that are not succeeded by anyone with comparable authority. Gradually, in more and more areas, things operate by inertia without adapting to changes.) Steve Jobs had to come back to Apple Computer to rename it to just "Apple".

So if you're the rare person capable of starting a successful company, and you insist on it being a huge success and not just a big one, make the vision as unconstrained as you can imagine.

P.S. For investment advice taking company names into account, I recommend Ian Lance Taylor's excellent essay titled Stock Prices.

A better future (a programmer's first animated post)

Whatever else happens, you made a movie… Nobody can take that away. A hundred years from now, when we're all dead and gone, people will be watching this fucking thing.

Tony Soprano to his nephew (whom he murders over this movie in a few episodes)

So I made a 90-second animated, um, I guess it's a blog post. I don't know about a hundred years from now, but I proudly invite you to watch the fucking thing right now:

I hear that it's considered classy for animators, filmmakers and such to let their work stand on its own, either refraining from commentary or making it vague. However, anxious to secure my spot in eternity, I decided to rush my immortal masterpiece out the door, so I cut everything I could.

I then realized that I left out a delicate point which, despite my embarrassment, I must mention. Luckily, typing is much easier than animating, so the following afterthought was quick to put down [1]. Here goes.

The short isn't exactly a documentary, but real-life me did switch to a part-time job to free some time for animating, drawing, etc. I figured this mundane little step was a good topic for a starting filmmaker because it turned out to be surprisingly controversial. Here are some of the reactions I received:

  • "So you finally got fed up with the job?"
  • "Part-time? But everyone here needs you!"
  • "Wow, I'm jealous! I want to work less, too. They pay you the same, right?" No, they pay less, I said. "Oh. Ha-ha. Work less, get less. Interesting!"
  • "You should really work more, not less, while you're young. Futurists predict a huge global pension crisis, so save for your retirement!"
  • "I doubt this will fly with the big deadline coming. Who's gonna do all the work? Not me!" (This guy works part-time himself – very productively.)
  • "Doesn't your wife object?" (Actually, my light table is Rachel's gift. I don't know when/if I'd ever get one on my own.)

These comments suggest that many people want to work less, but something is keeping them from doing it. I can certainly relate to that. It took me 10 years to decide to work part-time – and then 5 more years to actually do it.

Why is it so hard?

My own reasons mostly revolve around money. Where I live, money is much easier to make programming than animating (good luck even finding a half-stable job working on animated features.)

Hence "I went into programming for the money", as I said in the short – as I always say. And initially I figured I'd work all I can and retire early – the opposite of working part-time and animating in my spare time ("settling for a fraction of the dream"). And you've just seen how I changed my mind.

But there's another thing, which I usually don't say and which I must reluctantly admit. You see, I came for the money, and then I started liking the getting paid part.

What's the difference between money and getting paid? There's a world of difference!

Winning a lottery is a way to obtain money without getting paid for a service. And spending your wage on designer clothes is a way to get paid without having any money left. The difference is this:

  • Money lets you buy things – food, living space, spare time, etc. It's about options.
  • Getting paid tells you the value of your service to whoever paid you. It's about achievement.

I like getting paid, I must admit despite the embarrassment.

Note that I'm not ashamed in the slightest to like money (options) and to have chosen a profession with the sole purpose of maximizing income.

Some people believe that you can't be happy doing something you don't love – and that you can't be any good at it, hence you won't make that much money, either. I disagree.

I'll tell you who my role model is, as a computer programmer. It's neither Bill Gates nor Richard Stallman. My role model is Alec Guinness, whom you probably remember as Obi-Wan Kenobi from Star Wars. Wikipedia says:

In letters to his friends, Guinness described the film as "fairy tale rubbish" <…>

He was one of the few cast members who believed that the film would be a box office hit;  he negotiated a deal for 2% of the gross royalties <…>

Lucas and fellow cast members … have spoken highly of his courtesy and professionalism, both on and off the set. Lucas <said> that Guinness contributed significantly to achieving completion of the filming.

Here's a man working on something he disliked because it paid – and delighting his target audience and colleagues alike. To me it shows that "extrinsic motivation" – money – is a perfectly good primary motivation, contrary to some researchers' conclusions.

I'm in it for the money – hence, I'll never get bored and lose interest, as long as there's money to be made. I'll dutifully work on the unpleasant parts necessary to get things actually done (and get paid). Not liking programming that much, I try to keep my programs short and easy to maintain and extend – so I can program less.

These are all desirable traits – and not everyone genuinely loving programming has them. Think about it. Who's the better henchman – the psychopath murdering for the thrill, or the coldblooded killer who's in it for an early retirement? Same thing here.

I'm your perfect henchman. Pay me, give me some time alone with your computers, and when you come back, you'll find them doing your bidding. Of this I am not ashamed.

Recently, however, I noticed that I'm no longer the coldblooded henchman I used to be, that I started to enjoy the thrill of the kill for its own sake. And this I cannot admit without blushing.

That's what getting paid does to the weak-minded. It warped my value system. The phases of my transition – or should I say my moral decay – went something like this:

  1. I program because they pay me.
  2. Programming is good because they pay me.
  3. Programming is good.
  4. Programming is good! I think I'll go program right now. Or read about it. Or write something about it. All in my spare time.

And there you have it. "Achievement" has been redefined to mean "that thing you get paid for".

This is how I ended up with a website dedicated largely to programming. Then a programming blog on the site and a similar blog elsewhere. Then came the ultimate downfall: open-source programs on GitHub, written during evenings and weekends.

And I don't regret the writing. Keeping readers' attention on my very dry programming-related subjects is a worthy challenge for any starting storyteller.

But programming for free? Me? If you're good at something, never do it for free! Oh, how the weak-minded have fallen.

Sometimes you need to hit rock bottom to begin rising. So it was with me. Realizing that I've just programmed for free for several weekends in a row made me think. Hard.

"I can't believe you," I said to myself. "All this money-chasing at least made some sense. But programming for free? Why not draw in your spare time instead? What's wrong with you?"

"Not so fast," said self. "For free or not, at least here you are doing something you're good at. You know you're good – you get paid for it! Would they pay you for drawing? Not so soon. Maybe never. Even if you're any good. In fact you'll never know if you're any good. Not if you're never paid. Nor if you're paid badly, which happens all the time in those arty parts of the world, even to the best. Why not stick to things you're good at – that you know you're good at?"

Could you believe this guy? Well, I wouldn't have any of that.

"You shameless, hypocritical, baiting-and-switching COWARD," I screamed at self at the top of my lungs. "You always said programming was for the money – to buy time, to buy that bloody creative freedom you kept chattering about! And now you say I should keep programming because I got good at it? But of course I got good – I've been doing it all this time! I could have gotten just as good at drawing – I still can – if I have the time!"

"And you say that now when I can afford some spare time," I went on, "I should regardless stick to what I'm good at, which by now is programming? Are you hinting that I won't ever draw very well? Is that why you suggested a career in programming in the first place – because you didn't believe I could draw? Was that chanting about needing money one big lie all along? Tell me, you lying bastard! I'm gonna -"

"OK, OK, chill, man, CHILL!" Self looked scared and unsettled. He clearly didn't see it coming. Now he was looking for some way to appease me. "You know," said self, "maybe you're right. Remember how you're always proud of taking a long-term view? Of how you care today about things 5, even 10 years ahead?"

I smiled smugly. Indeed I was proud of my long-term-centered, strategic thinking. Bob Colwell – the legendary computer architect – once said that it's the architect's duty to think about the long term, because nobody else will. I so identified with that. (Colwell and I are both computer architects, you see – just, um, of different calibers.)

"Well," said self, "you should be proud. Too many lose sight of the future because of today's small but pressing worries!"

"Yeah, yeah, yeah." I was losing my patience. "Thanks but no thanks for your brown-nosing. Listen, are you playing bait and switch on me again? What does this have to do with drawing?"

"But that's the point – it's the same thing," self exclaimed, "it's about long-term thinking! Sure, in the short term, maybe you're better at programming than drawing. But keep practicing and yes, of course you'll get good at drawing! Use your favorite superpower – your ability to imagine the future vividly, to practically live there – to overcome the temptation to stick to your comfort zone! Secure a better future today! Be the shrewd guy investing in a little unknown startup – yourself the would-be animator – to reap great benefits down the road! Be -"

"I get it. That's what I said though, isn't it? Let's practice – let's draw in the spare time."

"Sure. Sure! You're right," said self submissively. "I'm actually helping you, see? I'm telling you how to use your strengths to take the plunge!"

"Thaaaanks. You know what? We'll work 20% less hours every week to get some more spare time."

"What?! But, the money -"

"SHUT UP. Shut up for your own good. I made you enough money."

"How much is enough?" asked self.

Now he really got me worked up.

"How much is enough, he dares to ask?! How come you never told me? I was toiling for you year after year. When did you plan to give me some rest?"

"Well…" mumbled self. Obviously he had no answer. I should have known all along!

"Nothing is ever enough for you, isn't it?.. Well, listen up. We'll work 20% less hours every week. And every time you whine about the money, which you will, I'll say – sure, that spare time was an expensive present. Indeed we shouldn't waste it idly surfing the net. Let's draw! See? I'll use your bitching and complaining about the money to get myself to draw!" – I shrieked and cackled evilly.

"That's it," self whispered, "he lost his marbles. Talking to himself, too. Oh my oh my oh -"

"Shut your lying mouth. I'm not done. You'll find us a weekly drawing class. Also we're going to the zoo every week. I'll draw animals, and if you say nasty things about my drawings, we'll keep going anyway. Don't count on my tendency to follow inspiration rather than routine. I know how you can keep killing inspiration for months on end with your snarky remarks. Guess what – I'll still go. And -"

"OK, OK. OK! We'll go, we'll spend 20% of your salary so you can draw those bloody animals. Just calm down already. Sheesh!"

And thus my self unconditionally capitulated, and we lived happily ever after. Thus ends my treatment of that delicate point – the difference between wanting money and wanting to get paid.

Is the spare time – the most expensive gift I ever got myself – worth its price? You bet!

[1] When I say this was "quick to put down", I mean that it took hours, and pages upon pages of words written to be thrown away. (I accidentally published a draft showing all that wasted effort.) It's still way quicker than animating…

Sorry for having published a draft

I've just unpublished it.

Yikes. You know what's a good metaphor for a draft? Someone's undressed self who in a less than fully awake state makes uncertain steps towards the toilet. That's a first draft of that person's publicly presentable self.

And publishing a draft? It's a bit like being photographed in this state. I mean, we all pass through that state every morning. Nothing to be ashamed of, then. And yet.

I think a lot of RSS aggregators never delete a published post, even if it then disappears from the up-to-date RSS stream of the original site. Bastards. Someone should spread their naked morning photos all over the internet and see how they like it.

Anyway, sorry, and the finished thing (10 times shorter without all the written-then-thrown-away bits) is coming up soon.