4 ms·
Really? I like C but I'm not sure it's beautiful, compared to a LISP or some sort of ML. And my limited experience says that C programs involve a ton of boilerp
by MichaelGG 11y ago
Really? I like C but I'm not sure it's beautiful, compared to a LISP or some sort of ML. And my limited experience says that C programs involve a ton of boilerplate code dealing with copying bytes around. Every time I see a loop doing a series of if/elseifs to parse command line options, I think this is very much not beautiful.
- vezzy-fnord 11y agoLisp and ML represent quite different models of computation. For a register machine, C can be pretty beautiful. It's funny you talk about parsing command line options. Plan 9 solved that problem well with the arg(2) macros. [1] In fact, Plan 9 in general is a premier example of really clean and elegant ANSI C-compatible code. [2] [1] http://man.cat-v.org/plan_9/2/arg http://man.cat-v.org/plan_9/2/arg [2] e.g. https://github.com/0intro/plan9/blob/master/sys/src/libndb/ndbhash.c https://github.com/0intro/plan9/blob/master/sys/src/libndb/n...
- kabdib 11y agoRead the V6 Unix sources. They are seriously pretty. A file system in maybe a thousand lines of code. A scheduler and swap manager, a TTY layer, and device drivers with nearly no waste. You can read the code in an afternoon and understand it and make changes to it. Even in crusty pre-ANSI C, it's very elegant stuff. (Then I look at the Bourne shell sources and weep. It's like the author of that was in denial of everything that made C a decent language and wanted desperately to be doing something else)
- comex 11y agoFor reference: https://github.com/swetland/xv6/blob/master/kernel/fs.c https://github.com/swetland/xv6/blob/master/kernel/fs.c https://github.com/weiss/original-bsd/blob/master/old/sh/cmd.c https://github.com/weiss/original-bsd/blob/master/old/sh/cmd...
- rdc12 11y agoHow would XV6 compare to V6 for code elegance? XV6 being a reimplementation, of V6 Unix with ANSI C and targeting X86 instead. But was done by different people as far as I know.
- coldtea 11y ago>Really? I like C but I'm not sure it's beautiful, compared to a LISP or some sort of ML. It's another sense of beauty, the one of talking almost directy to the machine, with few abstractions, and few wastage.