views:

1313

answers:

19

All,

I was promptly asked, upon showing up for phase 1 of an interview, to implement an http server in any scripting language I chose (Ruby/Python, etc.). I was not so accomplished in these languages, so I opted for Java. I was told I had 1 hour of time and I was told that the server must do the following:

  1. Reply with a 'hello' response to a successful user connection.
  2. Reply with a directory listing.
  3. Allow the user to tell the web server to navigate to a location within the directory listing.
  4. Allow the user to click on a listing and have the file returned.

    Keep in mind, that it was to be an HTTP server, so it had to reply to browser requests and so would require the parsing of GET requests and replies in HTTP response formats, so setting headers appropriately, etc.

My question to everyone. Is this a fair question for a Senior Software Engineer? If so, can it be done relatively easy in a scripting language such as Python/Ruby?

Thanks in advance.

Humbled

+8  A: 

Seems fairly silly at a senior level. Did you need to write this on paper? If so, that's ridiculous.

Regardless, I don't think it's a great question, and if I was asked it I would explain just how useless I think it is.

Noon Silk
+26  A: 

I wouldn't ask this question.

It presumes a lot of specific knowledge (HTTP protocol) and it encourages sloppy, not-well thought out design and code (1 hour time limit)

I can't imagine someone creating a good solution to this problem in only an hour - a well designed, well-written, secure, quality implementation that fully implements the HTTP protocol. That means for all candidates, it will be difficult to ascertain exactly why they failed and if you should continue the interview. A great candidate may not complete it, but that is because they spent 30 minutes researching the HTTP protocol and trying to come up with a solution that would hit all of the corner cases. Their code may be very sloppy and full of errors, but that was because they were working against the deadline. In both cases, there is no difference between the poor candidate and the good candidate.

Michael
A knowledge of HTTP is probably required, at this level but all your other points are valid.
Noon Silk
I know how HTTP works, can give a good explanation of the basics of the protocol, I implemented a server for my networking class back in college, and so on. I'd still spend a good portion of the hour doing research since I don't know the exact request and response format off the top of my head.
Michael
knowledge of HTTP is not really required. Knowledge of where to find a library that already implements HTTP should be sufficient.That said, I dont think it's a really good test - as stated above, the test will likely result in buggy code with security issues.
atk
I would have walked out the second that question was asked. Not only unfair, but really kinda stupid and pointless. In addition to developing in C# for the past 4 years, I've been writing Python and Objective-C recently, and I've never done that sort of thing. Sounds more like someone wanted an academic, ego-massage than a good employee.
mkelley33
@Oscar - There are a couple good questions in here - How does HTTP work, write code to retrieve a list of files and format them into HTML, etc. By combining them all into one and giving what I would still consider to be a very hard time limit with what appears to be a very "hands-off" style of interview (write code and come back), you lose a lot of information you could obtain from the interview.
Michael
I'm moving this comments to it's own answer :)
OscarRyz
Which version of HTTP?
Joe Philllips
FYI -- it doesn't say anywhere in the question that the applicant was locked alone in a room, or that follow-up conversation wasn't allowed. It's possible that this was an assumption on the part of the applicant.
Sean Reilly
+9  A: 

I think any test question that requires an hour to do is silly to ask at an interview. If you want to get an idea what someone knows then you can ask questions to find out the limits of what they know.

If the interviewer doesn't know enough to do this then I would think twice about that company.

If you are interviewing for a job that requires that you write several servers then this may be useful, but overall it doesn't show much about what you know, as it is testing some fairly specialized knowledge.

I think doing this in PHP or RoR would be interesting though, since you are already running in a webserver. :)

Leverage the framework you have, at that point.

James Black
+5  A: 

One possible reason for asking this type of question would be to see how you handle solving (seemingly) insurmountable problems. It also might show how creative you can be in your problem solving approach. My guess is they really didn't expect you to finish. Just a thought.

Steve Horn
I'd agree. I assume the task was both daunting and stressful so they were able to observe you under such conditions and evaluate your response and ability to function in these conditions.
Stephen Nutt
+1  A: 

I think Michael's hit the nail on the head - the scope of the task is too broad to clearly identify reasons for the inevitable failure that are at all useful for distinguishing between candidates. I find that the more successful technical portions of job interviews are usually broken into a handful of small easily completed tasks, that focus on common software engineering skill sets, rather than large unsupervised ones that require a lot of relatively uncommon domain specific knowledge.

Scott
A: 

If I were asked this question I would have written it assuming an existing framework like rails or tomcat or CGI or something. And if I asked it (which I wouldn't) I'd take a dim view of a candidate that didn't.

That said, it's not that hard to implement (or at least draft) a bare bones HTTP server without doing the full HTTP protocol and just doing the bare minimum to answer the question. It would be possible to tell who was a good or bad candidate just from how they approached that. For example did they leave open a security hole whereby the client could request a file outside the directory. Did they leave comments to the effect 'this isn't finished' and noting what else was needed. etc.

It still seems a pretty poor question, though it may depend on the details of how they asked it. Still, don't forget that the purpose of the interview is not just for them to evaluate you, but also for you to evaluate the company - a stupid question can reveal that you'll be working under people that haven't a clue.

frankodwyer
A: 

It sounds like a test of your API knowledge and knowledge of the HTTP protocol. If the position was for an HTTP server engineer, this question would probably be absolutely appropriate. However, from the tone of the question, I suspect that it's not.

Personally, I dislike any kind of question that requires specific knowledge of APIs in a language. There's RFCs and reference implementations out there if you need a server. Hell, if they asked me a stupid question like this, I'd answer "I'd like a linux and perl environment. How does that sound?" When they answer in the affirmative, I'd write

cpan HTTP::Server::Simple
perl -e "HTTP::Server::Simple->new()->run()"

I'd describe the html pages that you'd need, then ask for my next question. :)

Robert P
Maybe the job requirement will involve those APIs. Why have a completely generic interview? You're obviously filling a role -- not a computer science test.
Joe Philllips
Because knowing APIs are the easy part, especially well known and widely distributed APIs like sockets. I don't ever look for a "X" programmer, because maybe tomorrow we'll be doing something totally new. I look for people who can think about code, any code, and solve problems. If all a person knows is X Y or Z, they become a liablility. I'd rather have someone who's excellent at coding and problem solving in general that doesn't know an API right now, than someone who's excellent at an API but only knows that API.
Robert P
However, if they DO want an API programmer, then they should focus the interview on that API. You should not ask "use your favorite language and then..." It's the equivalent of saying "I want to test you on fishing. Use whatever means you like to go fishing. You will be graded on how many fish you catch." I'll use a deep sea fishing vessel. There's little to no value gained. You're likely talking to someone who doesn't interview well or doesn't know what they want. They probably heard "ask a thought question" once and decided it was a good idea without thinking of a good generic question.
Robert P
+2  A: 

If you use Python, you can cover point 2 to point 4 in 1 minute

python -c "from SimpleHTTPServer import test; test()"

To cover point 1, one needs to do some work to extend the SimpleHttpServer.

It is really a crazy question.

Anthony Kong
Ha! Fantastic, I had no doubt python could do it too. :)
Robert P
Actually there is a simpler version: "python -m SimpleHTTPServer"
Anthony Kong
This response highlights how this just isn't a hard question, it can easily be done by a senior developer who, surely, knows at least one scripting language very well, and isn't under the mistaken assumption that they have to reimplement every darn thing (including, perhaps, the BSD Sockets implementation). Given 1 hour, you're expected to demonstrate knowledge of a chosen language and its functionality.
Arafangion
+7  A: 

Completely stupid for any sort of senior role.
Talking through developing a web server, what you are thinking about, how you approach the problem etc = reasonable.

Just leaving someone in a room for an hour and coming back = useless.
It's almost forgivable as a first pass for an entry position where you have a 100 people and you jsut want to know can they program or are they lying on their CV.

Martin Beckett
+6  A: 

I made an experiment on myself; It took me exactly 32 minutes to write this (bash shell + netcat utility + few other GNU utilities):

#!/bin/bash -x

if [[ -n "$1" ]]
then
    head -1 | cut -f 2 -d" " |\
    (
     read PATH
     if test -d "$PATH"
     then
      echo
      echo
      echo "<h1>Listing for $PATH...</h1><br>"
      /bin/ls -1 "$PATH" | /bin/sed -e 's!^/$!^$!;s!^\(.*\)$!<a href="'"$PATH"'/\1">'"$PATH"'/\1</a><br>!'
     else
      echo
      echo
      /bin/cat "$PATH"
     fi
    )
else
    while true
    do
     nc -l -p 1080 -c "bash -x $0 connected"
    done
fi

It makes directory listings, it shows file contents.

I assumed using existing HTTP server/library would be cheating.

But: I had access to all the manuals (I didn't use internet; I used only information I had earlier in my head). It is not of course secure nor standards compliant; it works with firefox and wget. Interview means also stress. I am not sure if I could do that in an hour in a stressful situation, even having all the documentation handy and an oracle solving the halting problem.

I assume the question was asked to check overall problem solving skills: I needed to use some facts on the HTTP protocol, some HTML bits, some real programming and knowledge of tools. I guess this question is not that difficult... and I guess a senior programmer could know some bits of these.

liori
That works (although there's a bit of a hiccup when at the root directory). Pretty cool!
nobar
A: 

If I were asked something like this in an interview, I guess my question would be: "How much am I getting paid for this hour of work?"

It's one thing to do simple-answer or analysis questions to show your knowledge, or even to code up a few simple functions on the board. It's another thing to be told to sit down and write code for an hour.

If an employer wants to do this to get the best candidate, they should be honest and pay a fair hourly rate for the candidate's time, rather than waste the time of everyone except the single candidate who gets the job.

Kyralessa
I guess there are a few tightwad business owners on this board, but I stand by my answer, and I say that as somebody who's been on the interviewing side a few times. It's not fair to ask someone to come in and work for free. Taking a long test is borderline; sitting and coding for AN HOUR is absurd.
Kyralessa
I actually agree with you, people at SO are such sycophants to business at times. "Must...increase...profit... so that I can get a pat on the back and the CEO can take that 4th vacation to the Azores"
temp2290
I had an interview recently where I had to write code. But it wasn't complex code; it was simply firing up VS, creating a WinForms project, and creating a simple UI, an interface, an implementing class... It was just to weed out people who looked impressive on paper but had no actual knowledge. It was reasonable.
Kyralessa
Whatever code you can write in an hour doesn't have commercial value. -1 for near-paranoiac levels of cynicism, coupled with complete misunderstanding of the function of an interview.
CPerkins
I didn't say it has commercial value. I said it's absurd, in an interview, to ask someone to do that. It's too much time. Get over yourself.
Kyralessa
+3  A: 

Maybe they just needed someone to write a server framework, and you were the next sucker to walk through the door. :)

Next week they'll call you for an 'interview' question about hosting forum pages online.

JPDecker
+14  A: 

The question on its face is pretty unreasonable. No one should have to pound out an HTTP server, on the spot, in one hour, and then be judged on the merits of their code. Most people will either choke, or be so bogged down in the details that they wouldn't finish.

This said, however, I can definitely see some merits of using a question like this to look for certain attributes in a prospective employee.

  1. Can you code? Yes, we all know how to do a recursive Fibonacci series. This question pushes the bounds of what a person can memorize quickly before an interview. If you're a competent programmer, you should at least be able to create a functioning program with some stub-code showing where your knowledge is failing. Note: I wouldn't expect the program to run according to the requirements.
  2. Can you problem-solve? Again, it's not hard to quickly reproduce a simple recursive program; this question forces the interviewee to break a sizeable problem into manageable parts. I would be very interested to know how they worked through the program, and whether or not they can start on their own initiative.
  3. What's your attitude like when asked to accomplish difficult tasks? Yes, this is a pretty unreasonable task (depending on how the results are dealt with). However, there are many unreasonable tasks which are requested in a programming career, and if the prospective employee is going to cop an attitude when asked to do difficult work, it's better to know ahead of time. Frankly, if the interviewee informed me of the stupidity of the task, I'd probably terminate the interview early and chuck their resume. I'd certainly be open to them questioning the merits of such a question, but I'd be analyzing their tone and level of respect.

I think the real question is how the rest of the interview went. Did the employer analyze your attempts and try to illicit any understanding of how you approached the program? Did they take the opportunity to learn about you and how you work? If so, then I think the question is quite fair.

Did they lock you in a room, ask you to code, and then grade the result? If so, I would say the question is unreasonable and you're lucky to know this ahead of time.

bedwyr
A: 

I will check if any ready-made component available before creating anything from scratch. :)

If there is an open-source http server available online, just study the code.

When time is limited, you have to decide which components you need to write your own, which one you need to use / buy, and which feature u need to drop ^_^

janetsmith
why am i getting a negative score for this?
janetsmith
I gave it -1 because I thought it was a really poor answer. Obviously, someone who gives you a programming task in an interview isn't trying to test your ability to grab a ready-made component from somewhere else to do the same task.
mquander
I didn't down vote but for one thing i'm sure - this is not an answer to a question.
Arnis L.
If I were the interviewer, I want to see how the candidate solve the problem in short time, regardless how he do it. The end justifies the means. I want people work smart. I used to attend an interview, which the interviewer leave me a computer with internet access, and as me to build something. I fully utilized the internet facility :D Being able to obtain what we need from internet in short time, is a very important skill, IMO.
janetsmith
+17  A: 

@Michael: I'm totally disagree with you.

You can tell a poor candidate from a good candidate if:

  1. They understand what the requirement is ( the requirement was NOT "fully implement HTTP protocol" ) but just list the file system. Nothing more.

  2. They know how to prioritize ( eg. What' more important in this situation? To have a secure implementation or have the four requirements done? )

    Remember dead lines does exists, if you have only one hour what would you do? Support a HTTPs ( not requested ) or List the filesystem?

  3. A good candidate would do a simple implementation of these four requirements and at the end would tell you:

"This solution still needs this and that other feature, I could have them written in a week"

And then the interviewers may ask:

"From all those 20 features missing how long would it take to implement this one ( let's say security )"

A good candidate should respond how long would it take.

Finally, a good candidate may not necessarily complete the assignment but it would give it a try, and won't give up until it's hour is finished.

I've seen guys that say: "It can't be done" and just walk away" They are not up to the challenge.

But hey finally, it really really DEPENDS ON THE POSITION!!! ( what if the position was "HTTP server programmer for 1 hour limit hot fixes" ) :)

OscarRyz
+1 for "what if the position was "HTTP server programmer for 1 hour limit hot fixes" )" aha
marcgg
i tried to upvote this one twice
akf
A: 

If I were asked to do it in Ruby I'd say:

gem install sinatra

fire up editor to create myapp.rb

require 'rubygems'
require 'sinatra'
require 'erb'

include ERB::Util

get '/' do
  "Hello"
end

get '/dir' do
  Dir.entries('.').map { |i| "<li><a href=\"#{html_escape(i)}\">#{html_escape(i)}</a>"}
end

ruby myapp.rb

And then I'd say, "in the real world, I'd probably need to spend more time thinking about a thread-safe implementation, a reasonable thread pool, the complete HTTP standard, security, etc., but given an hour, this is what I'd start with.

Actually, I'm not sure I'd be that clever in real life, because I only encountered Sinatra earlier this week, and I work in enough programming languages that I'd have to look up how directory manipulation works in ruby again.

I'd say it's a fair question, but not necessarily an useful one. It proves only one of three things: 1) You know shortcuts. 2) You know far more about HTTP, sockets, and threading than most sane people. 3) You panic under pressure.

If I were to ask such an odd question, I would probably care very little about the code that comes out of the exercise and far more about the discussion about all the issues involved in putting together a web server, minimalist or otherwise. If you had sane interviewers, they would probably be the same. If you had insane interviewers, you probably don't want to work there.

A colleague of mine told me that over the course of an interview he sort of gradually built up code that could be used as a locking database server, but it was a collaborative discussion between the interviewer and the candidate. So I'd say there's potential for a really "hard" problem in an interview, but it doesn't make much sense to just slam someone into a whiteboard and watch them sweat.

JasonTrue
+4  A: 

I think that this question is valid.

As @bedwyr noted, this question is all about "can this applicant code"? I'm involved in the hiring process where I work, and when we advertise for senior programming positions, we commonly get resumes from a) junior people, and b) people without enough practical programming skill for the position. If the position being advertised is "Senior Software Engineer", then yes, I would expect the applicant to have strong foo.

It is true that this question does require existing protocol knowledge. That being said, HTTP is a very well known protocol. Depending on the technology the company develops in (say, web application development), it might be fair to say in-depth knowledge of HTTP should be a hard requirement for a senior position.

It's also fair as a first round question. If an applicant isn't a good fit for the position, then the sooner we find out, then the less time (ours and theirs) is wasted. Whatever question weeds out the most inappropriate applicants should go first.

As far as the scope of the question itself, my guess is that they would have been happy with HTTP/1.0 and GET support only as a first try. As it happens, I was actually assigned that very project in my first year of university (in Java, with the added requirement that the server be multi-threaded).

To be brutally honest, the job title does say senior, and the company apparently means it. If you can't nail a first year comp sci project in 1 hour without breaking a sweat, then you don't have any business applying for a senior programming position; at least not where I work. I think you should take a good hard look at your skill set and reconsider if you were really qualified for the position.

Sean Reilly
That being said, I wouldn't personally ask *this* question. There are other questions that can determine much of the same things in less time.
Sean Reilly
Lucky you, having a university that acknowleges the existance of the web. Mine seems hellbent on making us all desktop application programmers, and networking isn't covered until junior-ish level classes.
Xiong Chiamiov
That was in the year 1999, no less. It's nice to have forward thinking profs.
Sean Reilly
A: 

I think coding question in interview is absolutely fine. We have to know coding before we can lay our hand on design and other software aspects. Having said that, i would say time limit for the question was too short. It will definitely take more time than just one hour

Asif
A: 

I think you can do it with netcat with a few lines.

iterationx