Hello, my name is Michael. I am able to invert a Binary Tree on a whiteboard. I answer code questions on the internet for fun. I love riddles.

This post is in response to this article. Read it and then come back; it’s not too long.

I actually really like Whiteboard interviews. I like taking them, I like helping people prep for them, I like mock giving them. I enjoy the puzzle and the straightforward goal. I find them WAY less intimidating than traditional “tell us about yourself” interviews, which scare me to death and I’m so glad I never have to take. I will always prefer technical interviews over non-technical ones because I’m still not sure what I’m actually supposed to do in a non-technical interview.

Clearly, I’m in the super tiny minority, and I’m trying to understand why. Sometime during years of TA’ing my knowledge of Java passed “useful for a job” into the land of “tiny details that will never matter in any context other than a Whiteboard Interview or JVM development”, so perhaps I’m speaking from an unfair standpoint of having more knowledge of absurdly small details that will never be useful on the job. (Though you never know. Knowing the actual explicit steps Java and similar languages take to initialize an object when you say “new” caught a bug today. Tsvi can vouch).

After reading the actual tweets again, though, I have to wonder if the problem isn’t the format but the questions being asked. I don’t see anything wrong with whiteboard interviews, but asking someone to code up bubble sort is worse than useless. It says nothing about their ability to think critically, made design decisions, or meaningfully choose data structures, but only whether or not they’ve memorized how to write bubble sort. For what it’s worth, I haven’t. (As far as algorithms go, though, I could code Dijkstra’s in my sleep. I taught it too many times to forget it).

The point of a whiteboard interview is two-fold:
First, to get a grasp of how well the person knows the language in which they are interviewing. It would be amazing if we could speak in pure logic and the computer would understand, but we can’t, and I believe a fast and flexible knowledge of at least one language (hopefully more) is a fair prerequisite of any software job. I don’t think there’s any other way of measuring this other than seeing it in person. For every project or class listed on a resume, you have no idea how much was done by the candidate themselves and how much they were helped along by others.
Second, to determine how their mind processes and works through technical problems. On a more general level than the language, did they understand the problem easily? Did they ask intelligent clarifying questions about requirements for a valid solution or the use of well-known public functionality? Were they able to talk out their thought process, and in the case of getting stuck, were they able to explain how and why they were stuck concisely and clearly? All of these qualities, I believe, are exceedingly important for every software position, and again the only real way to tell is to find out yourself.

I think the problem is not the format, but lazy interviewers/question writers. The whiteboard interview succeeds at testing these qualities when it’s testing the candidate’s ability to code, *not* their ability to recall and write a specific algorithm or data structure that could be found in full on such and such a page in such and such a book. Developing truly novel questions is hard, and keeping them novel and not leaked for interview after interview is next to impossible, but compared to Bubble Sort we can hardly do worse. This speaks to the diversity side of the issue brought up at the end of the article as well. If the problem doesn’t require or even reward rote memorization, hopefully the people who “spent as much of [their] scarce time as possible learning to code” won’t be punished for not having memorized quite as many algorithms.

In the pursuit of better whiteboard questions, I’ll leave off with the best whiteboard question I was ever asked (not for Google, but for one of my internships). It requires absolutely no knowledge of any language, only a basic understanding of arithmetic and I suppose Algebra. As such, it can be attempted by anyone even if they’ve never taken a single CS course. Nevertheless, it still accomplishes the whole goal of a whiteboard interview. Here it is:

Consider a new, exceedingly primitive language in which you have only the four following statements/control flows:
1) Initialize and set a variable to 0, such as x = 0.
2) Increment a variable, such as x = x + 1, also written as x++.
3) Loop, which takes a variable, and repeats the following statements in braces a number of times equal to the variable *when the Loop statement is first reached*. Thus:

x = 0
x++
x++
x++
y = 0
z = 0
loop(x) {
y++
z++
}

Would set both y and z to 3, as the loop body would be executed 3 times.

4) Return x, which yields x as the result of your computation. This must be the final line of your code, and cannot be within a loop.

Given only those four statements/control flows, write a function that takes a single argument `A` and returns a variable with value `A-1`.

Advertisements

Beginning’s End – Everyone Should Learn Computer Science (Yes, Everyone)

A few days ago my mom sent me an article from the Daily Progress, Charlottesville’s local paper. The article (here it is in full) states that Computer Science will be added to the SOL [Standards of Learning], Virginia’s standardized testing program. They claim that this will make students more prepared to enter the job market, but from the wording of the article (and without doing further research into the change),  I am somewhat dubious. In particular, the fact that “The new standards do not add additional requirements to the curriculum or replace any subjects” makes me doubt that the new material will be sufficient to accomplish much of anything. That doesn’t really worry me, though. Standardized testing is enough of a complex and touchy topic without talking about what subjects deserve to be tested.

The part that really worries and upsets me, however, is a direct quote from Virginia’s governor. At a ceremony announcing the change, Governor McAuliffe said that, “We will be sending a clear message…to all the businesses around the globe that we’re very serious about this, computer science, and what we need to do to build those skill sets of the future…” On the surface, McAuliffe shows a refreshing practicality for a government official – the economy seems to be moving towards tech, so why not give our students a head start? The problem is that he is pushing for computer science because those skills will be valuable in the job market. It’s not just McAuliffe making this small but fatal mistake of motivation – even President Obama’s pushes for coding and computer science always have an employability and national status underpinning to them.

This heavily implies that the only reason we value computer science so heavily right now is that the economy demands more coders. Were the economy to shift back away from programming, it means we would drop computer science from the national curriculum like leftover food left out all night. It restricts computer science to a skill, coding, useful only for the function it provides. Contrast this with the way (and the reason that) we teach history. Every high school student learns at least two, usually three or four years of history. Yet we do not demand that more of those students become historians or enter other related disciplines. Rather, we require our students to work though multiple years of history because we as a society believe that they become better people by that work. That the true value of an education in history is not the direct skills or knowledge that it grants you, but the increased ability to understand and interact with life as it continues to flow as a continuation of that same history. No matter the fluctuations of the economy, learning history will always be valuable towards our current understanding of an educated person.

Coding is the vital skill at the center of computer science, but computer science has so much more to offer, such that the difference between someone who simply knows how to code and someone with a full computer science education is akin to the difference between a historian and someone who has read some history textbooks. Perhaps it is possible that they know the same facts, at least on the surface. The way that they would go about solving problems, however, is entirely different.

The true value of computer science is the resilience and humility it requires. Never have I been told that I’m wrong so often and so quickly as when I am coding. Nearly every time you run a program you are in the process of writing, it will end in angry red text spit back at you through the console. You don’t get to argue your point, as in English or History. You don’t even get to argue over which interpretation of objective truth is correct, as in Math or Chem. If the computer says you’re wrong, you’re wrong. Every single time. Here’s a conversation I’ve had more times than I can count with students who come into my office hours:

Them: It’s giving me a null pointer exception!

Me: Ok. So at some point you are trying to call a method or reference a field on an object that isn’t actually there. It’s like trying to shuffle the deck that’s inside of an empty box.

Them: But that’s not possible. None of my references are null.

Me: Well, you’re wrong. It must be possible, because it’s currently happening.

Repeat the above and modify slightly for: concurrent modification exception, class cast exception, arithmetic exception, stack overflow error, etc etc etc…

While the failures are delivered in a safe and private environment (i.e. your computer), this is nonetheless a really tough pill for some introductory computer science students to swallow. It’s hard to learn that something you were so sure of is actually incorrect, especially in such a blunt and unforgiving manner. It’s one of the reasons that computer science has a problem with retention, especially among women and certain minorities. When you get told that you’re wrong so often, it’s only natural to wonder if you aren’t cut out for the subject. What’s wrong, however, is thinking that everyone else is getting it right on the first try while you’re up at three AM debugging the same stupid error. Everyone in a class (literally, everyone) hits roughly the same number of snags in completing a given project. This should be intuitive – everyone received the same project to begin with, and everyone has roughly the same knowledge base going into it. Of course everyone will get tripped up in essentially the same spots along the way.

The difference between those who struggle through computer science and those who seem like wizards, then, is how long each of those errors take to fix. The better students don’t avoid failure, they get better at failing. They learn to have no problem admitting that something is wrong, because that is the first absolutely necessary step towards fixing it. They learn that one failure or even a multitude of failures does not reflect on them negatively, neither as a coder nor as a person, as long as they acknowledge that something is wrong and retain the desire to improve. They learn that it is not the multitude of your failures, but the magnitude of your successes, that truly matter. Computer science forces you to fail so often that you become immune to the mental damage it would cause. Rather than dwelling on your failure by getting angry or giving up, it forces you to move past it by searching for understanding, because that is the only way you will ever succeed.

Being a computer scientist, therefore, is much more than knowing how to code. It’s the long nights of futile search for the single remaining bug, and wanting to throw your computer out the window. It’s the sleep-deprived haze under which you finally stumble upon and correct the unbelievably stupid mistake you made three months ago. It’s the utter elation you get when the damn thing finally runs. Finally, it’s the warm glow you feel when a friend complains about an error subtly similar to yours, which you find and fix in five minutes instead of three weeks. It is all this and more, because in that moment your friend is not silently judging you, that it took three weeks to find this silly, simple bug. They know all too well what that frustrating search feels like, and you, you wonderful human being, were able to save them that effort. In that moment, you are not defined by your weeks of inadequacy, but by your perseverance, your empathy, and your humility.

That is a lesson everyone, regardless of age, gender, race or profession, needs to learn. It’s nice that the economy is tilting towards coding right now, and that computer science is in the public spotlight. Even if that were not the case, I truly believe that we all would be more resilient, more humble, more empathetic people if we all spent a few years learning computer science.