3 ms·
I think it was the GoF Design Patterns book that also spoke into this. They said that every level of language would have its own patterns, and that lower level
by koenigdavidmj 10y ago
I think it was the GoF Design Patterns book that also spoke into this. They said that every level of language would have its own patterns, and that lower level languages' patterns might be language features with first class support in higher languages. Examples:
* In assembly language, the design pattern might be the function (a published interface for a common block of code, and a well-defined protocol for getting data into and out of it).
* In C, it might be the basics of C++'s object-oriented programming features: single inheritance at first (have your parent class be the first member of the structure, then cast to whatever level you need), followed by vtables.
* In C++, it might be 'interpreter' or 'visitor'. Lisp macros make building DSLs a lot easier (see something like LOOP for a basic example), and CLOS' multiple dispatch nearly obviates the visitor pattern.
I'll agree with the article, though, that most languages are settling on the same norms, mostly borrowed from the functional world. Swift, Rust, C++, and Java are all gaining most of these: making it easy to avoid nulls safely, pattern matching, parameterized types, method chaining over explicit loops, and a non-dogmatic preference for immutability over in-place modification.
- hythloday 10y agoI would suggest that pattern matching over ADTs is what has subsumed the visitor pattern.