Hacker News new | past | comments | ask | show | jobs | submit login

Having so clear a vision of how your architecture should behave that you human-compile it into idiosyncratic code that looks generated seems to be a very good definition of beautiful code, no? Maybe he hasn't had time to write a book about the "code patterns" which he's using, but that's hardly something to hold a grudge about.



Especially if you're a security person, I think it's uncontroversial to say that the design is beautiful. It's not only an elegant design, but it is the first major piece of systems code to take that design approach. To put it differently: most of major systems programs that have been proven secure in the last 10 years owe their design to qmail.

But that has nothing to do with the code, which is not only epsilon from assembly (Bernstein fully embraces the notion of writing code in high-level assembly), but also clever and concise almost to a fault.

As someone who ran qmail since it was originally released in beta, I also remember vividly Bernstein's original idea about configuration, which is that "configuring" your mail server with C code was more reasonable than learning another programming language (Sendmail "cf"). Which implies that a lot of the code in the interesting parts of qmail are less about design, and more about encoding mail routing policy as C code.


In fairness, C is a much nicer configuration language than sendmail.cf. For that matter, so is INTERCAL.


Are there are any well-written overviews of the aspects of qmail's design that you're referring to?


I don't specifically know of any overviews, but the main principles are fairly simple:

- Split the system into small components that do one thing and do them well. - Give each part of the system the minimal set of privileges needed (if necessary by running as different users and set filesystem privileges accordingly). I.e. qmail has separate binaries for inbound smtp, pop3, managing the queue, local delivery, remote delivery and more. - Make each part of the system communicate only via well defined interfaces (using pipes in qmail) where it is explicitly assumed that you can't really trust the sender. - Don't ever use library functions that don't length check things. Then again he uses his own stdio replacement, and his own string functions.


qmail has a good design, but most of this is implementation of an existing well known concept, Principle of Least Privilege. Similar apps like Postfix owe more to whoever came up with that theory than they do to DJB IMHO.


If you write code that looks like it was generated with e.g. yacc, then you probably would have been better off writing it in yacc and bundling that as the source. There's nothing glamorous in being a human compiler. Other people will have to touch the code at some point.

I haven't read the qmail source (just some design docs about how the whole system fits together, which I found rather impressive), so I'm not talking specifically about that.

NB: Qmail's license wasn't public domain until 2007. (Also, damn, tptacek, you're fast! I deleted that part, since I'm talking about auto-generated code in general.)


Which he doesn't; qmail is public domain.

(I'm in 100% full-on maximum overdrive procrastination mode today, since what I need to get done is to script and record a screencast of my app, and I'm frozen up about where to start with it. Sorry for being so fast to respond).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: