4 ms·
The code I come back to when I want to see an elegant combination of advanced concepts and exhilaratingly simple code is Peter Norvig's "Paradigms of Artificial
by larve 10y ago
The code I come back to when I want to see an elegant combination of advanced concepts and exhilaratingly simple code is Peter Norvig's "Paradigms of Artificial Intelligence Programming". While it is common lisp, most of the code stays far away from the more abstract parts of the language (CLOS), and uses macros judiciously.
I think you can get most of the way there by using simple concepts of your programming language (functions, classes), but I feel that concise and simple to understand things are more easily implemented by one or two well chosen macros.
I so often long to have 2 or 3 nice macros to do really tedious stuff in my day job (C++), like:
- dispatching states in a state machine, with logging and safety checking. While I can do most of the logging and a fair amount of sanity checking in C++ with a few ugly macros converting symbols to strings, I can't easily do coverage checking at compile time, which would be very easy to do if i had a "defstate" and a "defevent" macro
- parsing and validating json by pretty much just describing the resulting struct, and letting the compiler do the rest. again, I have a literal army of JSON_STRICT_DECODE_DOUBLE etc... methods, but none of that allows me to generate a protocol documentation at compile time.
Honestly 50% of the boilerplate in the application comes from these two problems (I do embedded programming), but it's a pattern that I have when I was doing web development too. Adding decent logging and error checking is really hard to do save for adding language constructs, and in the kind of down-to-earth programming I do, it's about 80% of what I do as a programmer.