3 ms·
Design patterns aren't data structure though, I agree with the rest of your statement. OO Design patterns are usually about implementing functional concepts in
by throw_m239339 6y ago
Design patterns aren't data structure though, I agree with the rest of your statement.
OO Design patterns are usually about implementing functional concepts into rigid OOP languages such as C++ or Java (though both languages have gotten better).
With first class functions, there is no need for factories or strategies, or commands or a lot of stuff that imply single method classes.
With pattern matching, there is no need for chains or responsibility and so on and so forth...
- ncmncm 6y agoA design pattern is anything you see hand-coded in multiple programs. We don't often see data-structure patterns nowadays just because such patterns were recognized early as in need of core language features to capture them into libraries. Hash tables were a tough nut, so the core features that are needed to capture them in libraries, or even direct core-language implementations, didn't make it into some of the languages that are still in common use. The set of patterns that can be captured into a library is a moving target for a language that is still evolving rapidly, and for the landscape of new and upcoming languages; but a fixed target for a mature language like C. In C, X can, Y can't, and that will probably always be true of C. As time goes on, the set of patterns that can be captured into libraries of new and evolving languages grows, and with it our expectations of new languages. A language, new or old, that fails to capture what other languages are seen to do (for reasons) is rightly seen as less powerful. There is a place for less powerful languages, for use in limited domains, that are therefore quicker to learn and maybe safer to use, for less experienced or more distracted users. But we should always be clear about why the language is being made or kept less powerful, and what is lost by it. When starting a new project with open-ended goals, we don't know what challenges the project will face and whether a deliberately limited language will be enough for the job. By the time we learn, it is generally far too late to change horses. Thus, aging OS kernels and databases we use are often still coded in C largely because that was all that was practically available when they started out. Go is a recent deliberately-limited language that, because it was chosen to implement projects with open-ended goals, is getting painful extensions, and getting harder to learn. Rust was deliberately limited to reduce the burden of implementing its toolchain and to make it easier to pick up, but is rapidly expanding (according to plan) to satisfy the growing needs of its increasingly sophisticated user base.
- throw_m239339 6y ago> A design pattern is anything you see hand-coded in multiple programs. It's like claiming an algorithm is a design pattern. No. In the context of GoF as talked in the linked article, a design pattern isn't anything you see hand-coded in multiple programs.
- ncmncm 6y agoWe have been trying to make our languages able to put algorithms in libraries for a long, long time. So, usually they are.
- throw_m239339 6y ago> We have been trying to make our languages able to put algorithms in libraries for a long, long time. So, usually they are. No they are not, not in the context of the GoF design patterns which is what the thread is about, nothing else.
- ncmncm 6y agoRestricting pattern awareness to the sort favored in GoF has become a pointless exercise. Most of the originals are no longer relevant at all. An expanded awareness of unavoidably repeated constructs remains useful.
- throw_m239339 6y ago> An expanded awareness of unavoidably repeated constructs remains useful. yet it's irrelevant to the topic at hand. You can't just make up your own definition to suit your argument when the related article talks about something completely different, it's dishonest.
- thrower123 6y agoClaiming that you couldn't pass first-class functions in C/C++ is a weird claim that I see an awful lot, that is completely wrong. You can pass function pointers around all you want, it's just fucking difficult to get right without practice and the syntax is abhorrent.