Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design pattern as (missing) language feature

Sometimes people refer to design patterns as missing programming language features. To avoid the debate about what is a design pattern, let's say we only consider the original GoF patterns. For instance, the singleton pattern vanishes in Scala which supports singleton objects using the keyword object.

There are few resources around about this, notably Are Design Patterns Missing Language Features from the C2 wiki, or Are design patterns really language weaknesses? from SO. But I couldn't find an non-opinionated, objective and comprehensive coverage of this question.

Ideally, I would like a matrix with the GoF design patterns (row) and some mainstream programming languages (columns), where each cell would refer to a discussion about the pattern in the specific programming language.

To avoid the debate about what PL to consider, we can also fix this and pick: Java (as an statically typed OO representative), Smalltalk (as a dynamically typed representative), Haskell (as a functional representative), Scala (as a hybrid oo/functional representative), Lisp (as a meta-programming representative), JavaScript (as a prototype-based representative). And leave other PL for side notes or comments. I know we can argue about this choice, but that would already but really interesting to have that for these languages.

This will anyway always be an open question, but I feel like asked as it is, this is focused enough to have one best answer.

Maybe this matrix already exists somewhere? Or somebody has enough knowledge to craft it? Or somebody is keen enough to start and make it a wiki answer so that other can continue?

like image 891
ewernli Avatar asked Oct 27 '10 01:10

ewernli


1 Answers

The patterns in Design Patterns are a subset of the ever-growing set of patterns people use when programming in different languages. The authors are very clear that those patterns only apply to OOP languages, so many of them won't make sense outside of that context.

At the same time, there are plenty of patterns in other languages that aren't needed in an OOP language. Consider that objects themselves are a pattern when implemented in C or Scheme. In assembly, a call stack is a pattern.

like image 59
munificent Avatar answered Sep 23 '22 01:09

munificent