
Ask HN: Learning HTTP - writing a web server in which language? - trippplezz
I've been on a hiatus to study and prepare for web development jobs since I've decided to switch half an year ago. I have appr. 8 years of prior programming experience with mainly C/C++ doing CAD-related and video games programming.<p>In the past 6 months, I've read numerous books and wrote I would say a lot of toy-ish and not so toy-ish code using plain vanilla PHP, Smarty templates, Zend frameworks apps, WordPress plugins, that sort of things. Recently, I've started implementing some mini projects using Twitter API and the real-time protocols over HTTP (SUP, PubSubHubbub) and I felt the need to know HTTP a lot more. So, after a little research I found (maybe) the perfect book: "Illustrated Guide to HTTP" by Paul Hethmon. It's about learning the details of HTTP by writing a minimalistic web server in C.<p>Since I don't program in C anymore and thought that I will not benefit fully if I wrote the server by the book in a language that I'm quite familiar, I was wondering which programming language to choose to implement the server in?
I think in my position it boils down to:<p>* PHP: I'm comfortable programming in it, it can expand my knowledge by the usage of the standard libraries.<p>* server-side JavaScript using Node.js: I think I can comfortable write server-like code in JS, but I only know about Node.js for instance, not programmed in it. I guess it will not be too hard with the Node.js/JS code-test-debug cycle on Windows, will it?<p>Thanks
======
pwg
Consider a look at Tcl. Tcl's socket support makes creating a webserver almost
trivial:

<http://wiki.tcl.tk/11017>

<http://wiki.tcl.tk/3899>

<http://pietersz.co.uk/software/dandelion-server>

<http://wiki.tcl.tk/4333>

<http://wiki.tcl.tk/14413>

<http://wiki.tcl.tk/28412>

<http://wiki.tcl.tk/15244>

That last one (15244) has a stated measurement of request rates of 1162 and
1127 per second (scroll down the page a bit).

The advantage you'd have with Tcl is that since it abstracts away so much of
the low level details of sockets and handling connections, you get to
concentrate on (and learn) the http protocol instead of the low level socket
handling details.

As an example, here is the webserver from '28412 above, titled: "The Smallest
Tcl Web Server"

    
    
       proc webServer {chan addr port} {
            while {[gets $chan] ne ""} {}
            puts $chan "HTTP/1.1 200 OK\nConnection: close\nContent-Type: text/plain\n"
            puts $chan "Hello World!"
            close $chan
        }
    
        socket -server webServer 2068
        vwait forever

