The Apache documentation is nicely organized and overwhelming. If documentation is a project concurrent with the code, we cannot expect the former to match the latter simultaneously: you can only work on one thing or the other at a time. When the codebase stabilizes and the community adopts, then documentation can catch up with the latter. Somehow I lumped quality and documentation together when this is an unfair expectation: early docs are requirements specs; the sole user is the developer, the relationship between coder and code is like a marriage.
The Apache httpd (HTTP daemon, or service, or server) is all about modularity. Even the core features are grouped into a “core” component. Configuration is handled with plaintext files. You enter a pact with the server by referencing variable names, called directives. Think of them as environment variables that won’t pollute the system namespace, generalizations from hardcoded early.
When you push a variable up, you abstract.
ConsoleWrite("Hello world!" & @CRLF)
ConsoleWrite("Hello " & $target & "!" & @CRLF)
One more abstraction, even though it seems like we’re just replicating ConsoleWrite() – we’re using a library function for our own purposes:
ConsoleWrite($msg & @CRLF)
Now we can start a greeting card company:
PrintMsg("Happy 15th birthday, Sarah!")
Func BirthdayGreeting($name, $age)
; TODO handle ages 1-3
; TODO $age = 0
PrintMsg("Happy " & $age & " th birthday, " & $name & "!")
Have you ever watched a drawstream? It’s where an artist draws something from scratch. You watch him throw down guidelines and gray curves, roughing out a final shape. Sometimes it’s hard to tell that we’re seeing a face or a body. By the end, our eyes collapse the whole into a symbol: we see it. Just as in code, all we see is the functionality.
Let’s copy Apache:
If FileExists($gHTTPDConfigPath) = 0
ConsoleWriteError("Warning: httpd config not there!" & @CRLF)
Return 1 ; err
Dim $fileHdl = FileOpen($gHTTPDConfigPath)
Dim $line = FileReadLine($fileHdl)
If @error = -1 Then ExitLoop
Dim $aSplit = StringSplit($line, " ")
Dim $directive = $aSplit
; or opening tag, etc.
Case $directive = "ServerRoot"
$gServerRoot = $aSplit ; ignore further indices
Anyway, after the config file is parsed, we have a system specified to our needs. A general-purpose HTTP server conforms to our requirements. This would have been harder if we had to re-compile Apache every time we wanted to change something.