4 ms·
In general, macros, templates, and patterns are an "almost" discovery that a user needs a language (task, whatever) to have another level of abstraction or fact
by reeses 13y ago
In general, macros, templates, and patterns are an "almost" discovery that a user needs a language (task, whatever) to have another level of abstraction or factorization for the activity at hand.
For example, the visitor pattern is easily eliminated by dispatching on multiple arguments or with a monad.
The template provides that common, low-level, way of communicating to other developers in that the resulting code is consistently formatted and is native java/c/etc.. It's a pain in the ass to deal with constructs such as conventional iterative loops, exception handling boilerplate, braces/whitespace/etc., or massively redundant structures such as XML, as a regular programmer.
My favorite example of a level of 'retardation' in a language is pattern matching.
I can either write a painful if/then/else/else/else/else/else/default/end tree or I can write something like the following.
f(0) → 0.
f(1) → 1.
f(<binary:01001001010101011101010><x as binary>) → x as number.
f(x > 10) → 1.
Of course, this can be expressed in a number of ways. Table? Spreadsheet? Domain mapping with pretty lines?
I think we're losing information on a lot of the footpaths we should be paving by not having feedback into the use of various macros, templates, and patterns in the world.
- andybak 13y agoObligitory link to c2: http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatu... and the seminal Peter Norvig essay: http://norvig.com/design-patterns/ http://norvig.com/design-patterns/
- reeses 13y agoHah, I was caught out repeating myself. :) I remember kvetching on that c2 page early this century.