4 ms·
"This trick is well known to old-style functional programmers, they waffle on about Y combinators and eat this stuff for breakfast, but it’s the kind of stuff t
by urbit 13y ago
"This trick is well known to old-style functional programmers, they waffle on about Y combinators and eat this stuff for breakfast, but it’s the kind of stuff that gives functional programming a bad name. Try explaining this to first year students who had a heavy night out at the pub the evening before."
Priceless (and completely true). I really think this attitude is why Erlang is such a success.
- thirsteh 13y agoI think there's definitely a rule against dismissing Y combinators on news.ycombinator.com.
- derefr 13y agoThey're important in CS theory, sure, but you sure don't want to encounter one in raw form lurking in a regular codebase. (Just like you wouldn't want to encounter monadic IO in raw >>= form.)
- maxiepoo 13y agoUsing the y combinator outside of some ridiculously abstract code would be irritating. Using (>>=) makes sense sometimes though. For instance if you just wanted to echo something you could do do stuff <- getLine putStrLn stuff but the stuff variable is then unnecessarily introduced. You could instead just write getLine >>= putStrLn or the flipped version if you want it to read more like function application putStrLn =<< getLine
- deleted 13y ago[deleted]
- logicallee 13y agohow do neither of you get the obvious joke OP is making with "I think there's definitely a rule against dismissing Y combinators on news.ycombinator.com". (he's making a joke out of the fact that YCombinator is named after the construct.)
- Sssnake 13y ago>Just like you wouldn't want to encounter monadic IO in raw >>= form Yes I would. I would much rather see "getLine >>= putStrLn" than a 2 line do block.
- deleted 13y ago[deleted]
- tel 13y agoMeh, the Y combinator is a funny hack. A lot of people waffle on about it because they're blown away by how crazy untyped lambda calculus is. There are all kinds of ways to introduce recursion into a language, though. It's simply interesting that you might get it on accident in a language will as little restriction as UTLC.
- colanderman 13y agoOh don't worry, you can make a Y combinator in a typed lambda calculus too, it's just a little more involved: http://en.wikipedia.org/wiki/Fixed-point_combinator#Type_for_the_Y_combinator http://en.wikipedia.org/wiki/Fixed-point_combinator#Type_for...
- tel 13y agoDepends on the type theory. You need recursive types. Or you can just posit fix.
- dschiptsov 13y agoThere are two side notes. 1. Should we really be constrained by frequent pub visitors when teaching CS? Adapting to stupidity (OK, mediocrity) caused Java and switch from Scheme to Python for intro courses at MIT (with great help of mr. Guttag, I suppose). 2. Should we ever hire a person who couldn't get what Y Combinator is or not being able to write one in Scheme? Update: Python is heavily used in Biology and related research (so they said) and transition at MIT seemed like reasonable, but I still believe that Scheme shall be the language for serious introductory courses, like classic Berkeley CS61a was. Now PLT/Racket folks are doing great job of introducing proper concepts and developing "good habits" to students.