4 ms·
He started a business, and now his business is starting other businesses. Recursive...
by rjbond3rd 15y ago
He started a business, and now his business is starting other businesses. Recursive...
- guelo 15y agoY Combinator is not simply recursion, and a function that creates other functions isn't necessarily recursive anyway. He should have called it Factory Pattern.
- btilly 15y agoPaul Graham isn't a Java hacker, and isn't a fan of complex OO design patterns. Naming it Factory Pattern would therefore be unlikely to appeal to him. See http://www.paulgraham.com/noop.html http://www.paulgraham.com/noop.html for evidence that he isn't a big fan of OO.
- guelo 15y agoI guess the computer science-y name would be Higher-order Function.
- Sandman 15y agoJust a small remark: Factory pattern is anything but complex. Y combinator actually seems much more complex to me (though, I'm not proficient in functional programming, so that might be why I find it complicated).
- alnayyir 15y ago> (though, I'm not proficient in functional programming, so that might be why I find it complicated). Hint.
- fexl 15y agoThanks for posting that ... I'm happy to see I'm not the only one who eschews OOP and sticks to plain old routines. I've been programming for over 30 years, and I went through an OOP phase, but I got over it.
- Daniel_Newby 15y agoDo you really stick to plain old routines? If you have a data structure, and a module full of functions that manipulate it, that is an object. Just with a polluted global namespace and extra typing.
- djm 15y agoYou don't even need the data structure since you can simulate that with functions too in order to make a basic object system. Consider a simple example like this: (define (init-counter) (local ((define counter 0) (define (inc) (set! counter (add1 counter))) (define (dec) (set! counter (sub1 counter))) (define (current-count) counter)) (values inc dec current-count))) Then you can just import this code into wherever you want to use it and do something like: (define-values (counter++ counter-- current-count) (init-counter)) Plenty of people have said data structures are a poor mans functions. I think it's in that famous list of programmer quotes collected by alan perlis that everyone inevitably comes across at some point. In many cases where you want object orientation something like this will be sufficient. No need to go the whole way with inheritance and whatnot.
- fexl 15y agoYou know, even when I did use OOP, I avoided inheritance altogether and stuck with containment instead. The semantics seemed clearer to me, and I later read some essays from excellent programmers who shared my sentiments. Nice trick with your little module-in-a-box there. I think it's roughly analogous to the technique I used in my "handy_module" example here: http://news.ycombinator.com/item?id=2580717 http://news.ycombinator.com/item?id=2580717 .
- djm 15y agoThat's right, we are both using the same technique. It's interesting to note though that the difference between this and a data structure is not that great. I haven't looked into it but I'm certain I've read somewhere that data structures as implemented in racket (which is what my example is written in) actually desugar into something like my example code. I still like to use this technique here and there, especially when there will only be one copy of the structure in use in my program. This is because it's simply more convenient to write something like (counter++) rather than declaring a global COUNTER and typing in (set! COUNTER (add1 COUNTER)) etc.
- yters 15y agoI see it more as being a generative nucleus that makes all computation possible.