Hacker News new | ask | show | jobs
by wyager 4280 days ago
It's also easy to teach programming with BASIC. That doesn't mean it's particularly good for the students.

Setting up a web server with e.g. Python's SimpleHTTPServer is absolutely trivial, and teaches them a lot more about what a web server actually does (routing requests and building responses), and also prepares the students to use whatever hip python stuff people are doing servers in these days.

2 comments

The advantage for typical PHP here is that the webserver runs the programs somewhat transparently rather than the other way around with your program creating the webserver and then managing requests. PHP/Apache provides a very simple routing model that correlates 1:1 with the filesystem.
>PHP/Apache provides a very simple routing model that correlates 1:1 with the filesystem.

Might that give students a false impression of what a webserver does and is capable of doing? The students can implement the same thing themselves in a few lines of python, rather than offload most of the functionality to a monolithic and unapproachable black box like apache or nginx.

It's useful to black box some of the things when you are first learning. The specifics of serving a request are probably not the first thing you want to teach, especially when it requires some notional understanding of threading/blocking which Apache can take care of automatically. Also mod_rewrite and .htaccess provide powerful methods of adjusting behaviour of routing and the like.
Writing web apps or servers are two different things. well, mostly ... almost, at least if you teach for productive use. especially for anyone who just started coding, a few lines of python can be a lot, so KISS.
Routing is done by a router, not a server. a server serves. Does that really need to be said?

Edit: to clarify, I read about "routing" in "web-apps" now and then. I have problems figuring out, although it seems to be clear to anyone. And then you come and mess up terms even more, while routing is absolutely not essential to a web-server. Also, if your idea of routing is anywhere near apache's rewrite-rules, I don't wanna know it. If on the other hand routing is essential to an ftp server, I'd be curious.

"Routing" in this context means resolving URLs to their correct handler.
Well, that's the main feature of a web server, besides the obvious sending of responses? The usual notion is of requests and responses, routing seems to be an avant-garde term, in this domain.