Good Things About FizzBuzz

Over a year ago, I mentioned FizzBuzz as a basic competence screen during interviews. At the time, I said: “My only real quarrel with FizzBuzz is that, at this point, any developer worth their salt is familiar with it.” I seem to have been wrong, becuase I keep running into coders who definitely are competent, and who haven’t encountered it yet.

That’s fine, because FizzBuzz does have a few nice qualities as a test.

It’s Language-Agnostic

It makes sense for someone to code a FizzBuzz in anything from JavaScript to Haskell to C++ to Ruby to Python to assembler (pick your instruction set). The same cannot be said of various other standards, like “Reverse a string in-place” (which takes a bit of thought and care in C, and so makes a good test — but is utterly trivial in languages like Perl or PHP that have built-in string-reversal functions) or “connect to a webpage, count the frequency of words in it, and output them sorted in descending order” (which makes sense in scripting languages with well-known HTTP or cURL packages, but is far too big to make a decent whiteboard question in ones like C or C++).

It Doesn’t Require Memorization

There are some questions that require that the applicant knows a particular library call or special function. In the previous paragraph, I mentioned Perl’s reverse() and PHP’s strrev() — those aren’t what I mean, because those are pretty core functions. Those are the sort of thing anyone who does any text manipulation will have memorized, because they use it every day. But what about some of the more obscure ones, like PHP’s strncmp()? If you ask a question that requires it, you’re basically asking your applicant, “Have you heard of this really obscure function?” (In the case of languages like PHP, with its over-3,000 core-level functions, this is particularly evil, but the same results can be obtained by using a little-known CPAN package, C++ stdlib function, or Java Class Library function.)

FizzBuzz doesn’t require any weird functions to solve. It’s nothing but math, plus a for loop and an if/else. The most obscure thing in it is modulo arithmetic. And sure, maybe the applicant might have forgotten what the modulo operator is, because it’s not the sort of thing most people use every day.

But you can still solve it without the mod operator. Read More »

A Cute Motto Can’t Make Up For Evil Actions

I recognize that Google’s motto is not (the oft-misquoted) “Do no evil”. It’s the much easier-to-achieve mandate of “Don’t be evil”. But even that very low bar is one Google doesn’t seem to be hitting any more, and they don’t seem interested in trying to.

The latest “Google being evil” story, where it turns out they’ve been tricking Safari browsers into allowing tracking that they’re supposed to block, is by no means the only recent example. It’s just the one that’s gotten the most press — and a great place to start.

Part of the commotion is that the particular way that Google circumvented Safari’s privacy settings wound up completely undoing Safari’s privacy where Doubleclick was concerned. That’s the part Google didn’t really intend to do. But what they did intend to do was explicitly bypass Safari’s privacy settings, at least where their own +1 button was concerned. They wrote special-case code, served only to Safari browsers, which was designed to trick the browser into believing that the user was interacting with the +1 button — even though the user was doing no such thing.

This isn’t just something corporations do. Humans are complicit in it. Somewhere along the way, there was a Google engineer who was asked to write this code. He or she should have said, “Hey, doesn’t this sound kind of… well, evil?” Somewhere along the way, there was a Google product manager who was asked — or who independently decided — that tricking the browser and violating its privacy settings would be a good thing. Again, he or she should have said: “Wait a second, this is evil. We shouldn’t be doing this.

But this is not the only evil thing Google’s done in the past few months.

There’s also the way they helped sponsor this year’s CPAC, which gave prominent slots to white-power advocates and hate groups. And then there’s the recent privacy change, and their ridiculous cop-out on #NymWars, which disproportionately affects people whose voices are already too marginalized… and all that is on top of the stuff I posted about a year and a half ago, giving a litany of pretty evil things Google had done.

Around the same time, I posted a blog entry asking why Apple was still considered a “good guy” by geeks. At this point, I feel that question is much more appropriately directed at Google.

Google is no longer the happy, friendly company it once was. It is not a company I can support any more. I’m deleting my Google+ account, and looking for alternatives to Google Contacts and Calendar (which I’m really mostly using because of my Android smartphone). If you’re a geek who works for Google? Leave. Stop being a party to their evil. I know it takes a few months to find a job in Bay Area tech circles, but with Google on your résumé, you can surely find something.

But do it now. The way Google is burning out its reputation capital, in a few years having Google on your résumé may start to look like Microsoft did ten years ago… and then like having SCO on your résumé.

Beware of Optional Curly Braces — They Will Bite You

I was looking through some PHP code from a third-party vendor recently, and saw something that made my jaw drop. It’s pretty innocent-looking, at first. Here’s a somewhat anonymized and genericized version of the code, but the thing that bothered me is still intact. It’s not really a bug, per se; the code will function as intended. But…

$currentRow = 0;
$itemId = "";
$index = 0;
while ($row = mysql_fetch_object($result)) {
     if ($currentRow == 10) {
          renderHeaderRow();
          $currentRow = 0;
     }
     // takes an itemId and displays relevant columns
     renderSummaryRow($row->itemId);
     $currentRow++;

     if ($index > 0)
          $itemId .= ","; # interpolate a comma
     $itemId .= $row->itemId;
     $index++;
}

See the problem? Really, there are a few ways this can go wrong. To a quick glance, the only clue that line 14 (“interpolate a comma”) is part of a conditional is its indentation. The indentation is important to a human reader — but absolutely irrelevant to the PHP interpreter, which simply treats the next line after the conditional as the conditional’s block. Regardless of how it’s indented, and regardless of what else is around.

The way it looks to a human is not the way it looks to the machine.

What happens if someone wants to add some logging? What if they add it after the comma line?

if ($index > 0)
     $itemId .= ","; # interpolate a comma
     writeLog("Added a comma");
$itemId .= $row->itemId;
$index++;

Now the log claims the code has added a comma, even when it hasn’t. But still, it could be worse! What if you decided to add your logging before the other line?

if ($index > 0)
     writeLog("Adding a comma to itemId...");
     $itemId .= ","; # interpolate a comma
$itemId .= $row->itemId;
$index++;

Now it adds a comma no matter what — even the first time through the loop, when the string is empty. So instead of a string like '123,124,125', $itemId will now have a leading comma: ',123,124,125'. Since this value is getting stitched into a SQL query later on, it means your app will blow up with a SQL syntax error.

This is why Python makes whitespace significant to program flow. The way the indentation makes it look like the logical structure is, is how the structure actually is.

And this is also why Perl — of all languages, one that normally errs on the side of letting you leave out anything that can be inferred from context — Perl insists in its syntax documentation that in cases like this, “the curly brackets are required — no dangling statements allowed.” (It then says, in typically Perlish fashion: “If you want to write conditionals without curly brackets there are several other ways to do it.”)

If you’re working in one of those languages that lets you omit curly braces around a single-statement conditional — DON’T DO IT! The potential maintenance and debugging problems are not worth the fun of saving two keystrokes (or just one, if you work in an editor that auto-closes your braces for you).

A Single Context for All Social Interaction: Merely Quixotic, or Dangerously Misguided?

I recently read a blog post by Leo Widrich, the co-founder of Buffer, entitled “Why do we have so many lives?” In it, Mr. Widrich says:

We have a private life, a public life. We have a work life, a school life, a party life, a love life and I am sure you can name lots of others. I never understood why.… I always felt that it is hard enough to focus on getting one life right. Why create so many? (emphasis added)

This guy is a startup founder. I expect he may well be typical of the genus. And so, he makes a great example of why so many startups* seem to be promoting the “single identity” model. It’s nice that this guy feels he can have just one life — though even he admits it’s hard! But the rest of us don’t really want to deal with everyone on the same single channel.

Mr. Widrich claims that: “I can walk into a club and speak the same thoughts I have in my head to a girl, as I can to my family. And again I can speak with the same mindset to my co-founder, give an interview or play football.” Personally, I can’t help but wonder if that’s really working out for him. The pitch you use to woo an investor is quite seriously different from the kind you use to woo a woman. The way you talk to your girlfriend is very different from the way you talk to your mother or sister (I sincerely hope!).

In fact, I can’t help but wonder if this is a manifestation of Asperger’s Syndrome, or some other failure (or refusal) to understand social interaction. Regardless, it seems like a very clear example of a geek-specific sort of fallacy that — I’m starting to think — may underlie the various new systems that try to enforce single identities:

Figuring out the rules for social interaction is hard. One of the hardest parts is figuring out which rules apply in what contexts. Wouldn’t it be great to just have one context for everything?

No. No, it would not.

Most of us react with some consternation when our contexts collide unexpectedly — for example, meeting a co-worker (or boss!) at the supermarket (or worse, nightclub or bar!). Most of us don’t want our boss to see us drunk, or trying to pick people up. We don’t even really want to introduce our boss to our friends and have to try to integrate them into the conversation. Of course, being a startup founder, Mr. Widrich (like guys like Mark Zuckerberg and Larry Page) doesn’t have a boss, and so doesn’t have to worry about this.

The combination of “boss privilege” and “desire of poorly-socialized people to not have to deal with so many social contexts” makes a powerful one-two punch, and it may go a long way toward explaining the recent spate of apps that try to enforce single identities. In the meantime, I’m happily using Seesmic as my mobile phone’s Twitter client, because it has excellent support for multiple accounts.

* I include Google and Facebook in this category. They still think they’re startups, they still think like startups, and they still have the startup culture and mindset, even if they’ve grown into ginormous corporations. ^back

An Addendum: If you think the desire for multiple identities and contexts is just “an old people issue”, as LinkedIn CEO Reid Hoffman recently described “privacy” in Davos, then ask any teenager: Would you like to hang out with your parents, in the same way you hang out with your friends? How about your teachers?

If you have any doubt what their reaction would be, you don’t know teenagers very well.

By the way, a word to Mr. Hoffman: Apparently the new common wisdom is that LinkedIn is also “for old people”, so you might want to rethink your company’s stance on privacy. And quit pissing off your own target market.

A Failed Goal

Near the beginning of this year, I published a piece called “Ada Lovelace Day Is Not Enough“. In it, I noted that only 8.69% of my 2010 posts had been marked with the “gender” tag, and it would be nice to increase that percentage. (But it was still an improvement over 2009’s 4.76%.) I said:

So I may be improving… but I’ve still got a way to go. If you’re another man in tech reading this, I tell you what: I’ll work on improving myself, and the tech field as a whole, if you’ll do the same.

It’s now the end of 2011. Looking back over my blog activity this year, I see 24 posts, with only two tagged “gender”. That marks a slight drop to 8.33%. What happened?

I’ve had one in the works for months now. (Maybe more than one; there’s more than enough material.) I started it back in the summer, when I heard about the death threats against Naomi Dunford. In quick succession, before I could marshal my thoughts and words enough, there was the incident where the atheist/skeptic community blew up over SkepChick’s very polite advice on not acting like a scary creep (including Richard Dawkins blatantly showing his ass in a way that also showed off his monumental privilege and the ignorance it’s brought him), followed by the call for a stop to misogynist trolling and the associated #MenCallMeThings hashtag on Twitter. (Yes, it’s still going, and yes, it’s still worth reading if you want to see what women put up with online.) Read More »

Are We Always New At Everything?

The trend in Microsoft’s products for the past 15 years or more has been toward making things easy for the people who have never used the software before. Of course, as time goes on, there are fewer and fewer of those people.

The Ribbon is introduced in the Help file thus:

And if you’ve used previous versions of Word, you’ll wonder where the menus and toolbars have gone. That’s the beauty of the Ribbon. No longer do you have to wander through the maze of menus, submenus, and toolbars searching for what you want.

No, instead we now have to wander through a bewildering array of Ribbon tabs and drop-down menus. It’s as if the Office 2007 design team didn’t realize that everyone who’s been using Word for more than a year or two already knows their way around Word’s menu structure. It’s as if someone re-arranged my local neighborhood so that I “no longer have to wander through” the streets I already know. Indeed, SecretGeek finds the Ribbon so hard to find things in, he suggests that the Ribbon should include its own search feature so people can find features that are hidden among all those tabs!

It’s not just Microsoft. Check out Qwiki, “the information experience”. It is very clearly optimized to look cool in a demo. A demo, of course, is the ultimate in “aimed at new users” — it’s aimed at people who aren’t even users yet, but might become users. And user interface guru Bruce Tognazzini has been decrying the OS X Dock for years, partly on the basis that “It makes for a great demo, but not a great product.”

Interestingly, while I was prepping this post for publication, I became aware of Paul Miller’s article, “The Condescending UI”. It excoriates many of the very same problems in Apple’s and Microsoft’s recent OSes, saying that “these new tricks are horrible and offensive. They’re not only condescending and overwrought, they’re actually counter-functional.”

It’s as if usability tests and design reviews are all conducted with people who have never used the software in question before… and those who already have some domain knowledge are left out in the cold, forced to discard their knowledge every few years.

Are we really always newbies at everything? Or do developers even believe that we are? Or, heck, do marketers and product managers actually believe that we’re all still newbies? Or that there’s some vast, untapped market of prospective new users out there, just waiting for an even more dumbed-down interface before they’ll buy their first computer?

Just in case anyone out there believes any of those things, please, let me be the one to disabuse you of the notion. Anyone who doesn’t already use a computer is not ever going to. The only exception here is people under about 10 years old, and they’re not scared of unfamiliar UIs — to them, every UI is new, and they’re eager to learn new things. Stop dumbing things down, and stop sacrificing your long-time users’ skills in the name of changing things just for the hell of it.

Can You Strike it Rich in a Startup?

Startups are known for being places where people work really hard, often at unsustainable paces. “Work hard, play hard,” is the oft-invoked slogan, and there are usually foosball tables, game consoles, and other signifiers of fun lying around the office. (How often they get used is another story; the reality can easily be more like “work hard, then crash” or “work, eat, sleep”.) But there’s a logic behind it:

The idea is that you work really hard for a few years, but then there’s a big payout when your company goes public. In those few years, you can make enough money to live in comfort for quite a while. Or so the story goes. Does it actually happen that way?

Let’s try a quick experiment: Think of all the people you know, or have known, who have worked at startups. If you’re like me, working as a web developer in the Bay Area, this means “think of all your past and present co-workers”, and maybe a fair number of your friends who have worked for startups… just not the same ones as you.

Okay, total that up. Got a general ballpark number, at least? Great.

Now, how many of those people have actually gotten the kind of “big payout” that lets them live in comfort? Even for just a few years? Read More »

When Your Computer Catches Fire

Occasionally, I amuse myself by reading Not Always Right. I really shouldn’t, as it’s always bad for my opinion of humanity, but sometimes I just can’t look away. And occasionally, it clues me in to a teachable moment. Like this one, which recently appeared there:

Caller: “My computer is a fire risk.”

Me: “What makes you say that?”

Caller: “It gets hot. There are papers near it.”

Me: “If you’re worried about it, you can move the papers away.”

Caller: “I am moving the papers, but you must send someone to look at it.”

[More back-and-forth, in which caller reiterates that her computer is “a fire risk” and says the situation is urgent. A technician is dispatched, who eventually reports back:]

Technician: “You know that computer that was a fire risk?”

Me: “Yes?”

Technician: “She meant it was on fire.”

This isn’t the first time I’ve heard about such mistakes, either. Rinkworks’ “Computer Stupidities” sub-site has an entire page devoted to instances of computers smoking or catching fire (or people being worried that they might). One in particular involves a tech telling a college student over the phone, “Unplug the computer right now. Your paper is lost. Your floppy drive is lost. If you’re lucky the Mac will be OK. Unplug it now.” The student doggedly insists, “But I don’t want to lose my paper!” Then the tech hears someone in the background (presumably the student’s roommate) scream. Then the dorm fire alarm goes off.

For those who need to be told, I am willing to state, as a computer professional with 15 years of experience in hardware, software, system administration, troubleshooting, and repair:

If your computer or computing device ever emits smoke, sparks, or flame: Unplug it immediately. Do not bother with “proper shutdown procedure”; simply assume all data on it is completely hosed and start emergency fire-prevention procedures. Unplug its power. If it’s a laptop, also yank out its battery. If signs of combustion continue, use a fire extinguisher or water, as appropriate.

Unplugging it means there’s no more electrical power going to it. Many times, that’s enough to kill the combustion right there — if you were quick about it, the fire may go out on its own at this point. If it doesn’t, it is at least no longer an electrical fire. That means if you haven’t got an ABC fire extinguisher handy, you can still just throw water on the thing, without risking electrocution.

Once it’s been smoking or sparking, the device is ruined anyway. Understand that all your data is gone. (This is why it’s important to have complete, current backups.) The important thing to do is to make sure the fire doesn’t spread. Don’t panic, and don’t waste any time trying to shut down carefully or in the usual manner — that will just prolong the fire.

Remember, where computing devices are concerned, if it smokes, it is toast. Or it is fried; pick whichever image works better for you. If you let it keep running once it’s on fire, all you’re doing is putting yourself at risk. Don’t do it.

Say It Short

Remember when the movie 2010: Odyssey Two came out? There was a simple, easy way to say it: We all called it “Twenty-Ten”. And for a few decades, folks like Terence McKenna have been warning about what might happen in the year 2012, and we all thought of it as “twenty-twelve”. These things are short, quick, and easy to say.

And then we hit the Aughts, and for nine long years, we had to start all our year-names with “two thousand…”. By 2006, we were pretty well habituated to it, and I started hearing people project that format onto later years: “two thousand fifty-five” and whatnot.

But starting at the beginning of last year, none of this was necessary any more. We can drop the laborious excess of “two thousand” in favor of just “twenty”. Really, nobody will have any trouble understanding you when you say this is “twenty-eleven”.

(I know, this is not exactly a pressing issue. But it bugs me. Like many geeks, seeing excess effort expended is a pet peeve, even when I’m not the one expending it.)

While we’re at it, there are a couple of TLAs in the tech world that really can and should be said as acronyms, without having to be spelled out every time.

FAQ is “fack”. It rhymes with Iraq. If someone asks you lots of them in a rapid-fire manner, it’s a FAQ attack. If you’re into goth fashion, you may like the Dye It Black FAQ — doesn’t work so well if you spell out the last word, does it?

And why does anyone pronounce APIs as “ay pee eyes” when they could just say “appies”? Honestly, I always thought it was pronounced “appies”, until a co-worker got confused by it. I was surprised to hear that most techies actually take the excess time to spell out “ay pee eye” — nobody ever bothers to spell out “en ay ess ay” or “ay jay ay ecks”, why should the just-as-pronounceable API be any different?

Her Name is Skud

Skud has been involved in Open Source, and in activism and advocacy, for years and years. She does a little of everything, having coded, written docs, managed developers, and spoken out on important topics.

She has been, or is currently, a contributor to projects ranging from Eureka to Perl to Xen to HTML::Mason.

Way back in 2007, I saw that a company named Metaweb was looking for coders for a project called Freebase. Tim O’Reilly said the Metaweb people were “building new synapses for the global brain” and the project looked cool as hell. I looked at their hiring criteria, and was scared off by the problem that involved writing some code to populate a directed graph without allowing closed cycles to form. I wish I’d at least tried; maybe I might have gotten hired.

In which case, I could have met Skud when she started working there, later in 2007. And now maybe I’d have an “I know Skud” button. Regardless, I was totally unsurprised to learn, recently, that Skud had worked at Metaweb. She’s got the kind of talent and skill that I expect would make her a natural there. (And I confess to a certain bit of envy, that she got to work on such a cool project.)

But that’s not all. She also founded the Geek Feminism wiki and built it up into the self-sustaining thing it is now. That wiki has been an invaluable resource in various things I’ve needed to write, and the Who is harmed by a “Real Names” policy? page was a superlative argument in the NymWars discussion on Google+ — back when I was still there.

Of course, Skud herself was also a major player in NymWars. Aside from writing about her experience, and noting when Google started gagging its own employees, she also performed an informal survey of people suspended from Google+, thus providing some solid data to add to the discussion.

And now she’s moving into music, which may take her outside the Ada Lovelace Day’s “women in STEM” boundaries… but when I think of women in tech, Skud is still one of the biggest names that comes to my mind.