5 ms·
That was the point of the article. A design pattern is a sign that your programming language lacks an abstraction that makes it impossible not to repeat yourse
by randomwalker 17y ago
That was the point of the article. A design pattern is a sign that your programming language lacks an abstraction that makes it impossible not to repeat yourself.
- wwalker3 17y agoCould you give me a concrete example? Say, a pattern that can't be abstracted away in assembly language, but can be abstracted away in C++? Serious question, not a troll -- I've always felt like I'm missing some key point here.
- jules 17y agoFor example the "there aren't enough registers so I put some data on the stack"-pattern. You just don't have that in C++. Or getting the result of an expression into another expression, like (a+b)*c You have to write that as x = a+b y = x*c In C# people regularly play the human compiler when defining getters&setters (or maybe their IDE does it, but you still have the noise code on your screen). Or when mentioning types everywhere when the compiler could infer it (although it's better now with the var keyword).
- eworoshow 17y agoA minor point, but C# will generate simple getters and setters for you automatically with syntax like "type Property { get; private set; }". As soon as you want to do anything interesting when get or set, however, you're back to playing human compiler.
- rbanffy 17y agoDuring college I designed a processor that could do that. It would read like this (assuming A, B and C were constants representing memory addresses pointing to integers): $300: $(A) $(B) ADD $(C) MUL And the result would be at the top of the stack. Not all assembly languages are created equal. ;-)
- klipt 17y agoThat has more in common with Forth than most assembly languages though.
- rbanffy 17y agoThat's what I liked about the machine. When I realised that, if I designed a microcoded stack machine, I could make it run something very close to Forth in the 4 months I had to finish it, I knew I had to do it that way instead of a more conventional design (I took some implementation ideas and the assembly syntax from the 6502). In the end, I wrote an incomplete Forth compiler for it, but I don't know where the floppies I wrote them to ended up.
- deleted 17y ago[deleted]
- deleted 17y ago[deleted]
- jmillikin 17y agoAssembly to C: procedures, loops, switch-case, expanded numeric constants (e.g. seconds in a week as 606024*7 rather than 6048000). C to C++: virtual methods, scope-delimited allocation, dynamic typing.
- wwalker3 17y agoI think that's the key to my confusion here -- I wasn't thinking of language constructs like functions or loops as patterns, I was only including things like "factory objects" or "visitors". Of course, if a function definition is a pattern, does that mean that Lisp (chock-full of function definitions) is a lower-level language than Prolog (which doesn't need functions at all and therefore abstracts away that whole idea)?
- anc2020 17y agoAn example of patterns gone insane http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/RequestProcessorFactoryFactory.html?rel=html http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server...
- Daishiman 17y agoWTF, I cannot believe that's not a joke.
- Tichy 17y agoAren't all modern programming languages Turing complete?
- Hexstream 17y agoTuring completeness is actually 1. easy to achieve (even accidentally) and 2. undesirable in many circumstances (it makes code hard to analyse and process by machines and the semantics, what you really meant, get lost in the noise). There's a reason there's no way to express loops and varibles in HTML, for example. That's the principle (or rule) of least power at work: http://www.w3.org/2001/tag/doc/leastPower.html http://www.w3.org/2001/tag/doc/leastPower.html Also see: http://en.wikipedia.org/wiki/Turing_tarpit http://en.wikipedia.org/wiki/Turing_tarpit
- gruseom 17y agoTuring machines are Turing complete.
- gwern 17y agoYes. But that's irrelevant. You need to think carefully about how a UTM runs other TM's programs, about interpreters/compilers, and what one is doing when one writes out by hand design patterns instead of your language handling them.