Re:How recursion got into Algol 60: a comedy of errors
by anindyabd on Thursday August 27, 2015 @07:47PM
(#10132866)
I wouldn't call recursion boring. Quicksort in Haskell is probably my favorite two lines of code:
quicksort [] = []
quicksort (x:rest) = quicksort [y | y <- rest, y <= x] ++ [x] ++ quicksort [y | y <- rest, y > x]
Re:How recursion got into Algol 60: a comedy of errors
by nemesisrobot on Thursday August 27, 2015 @10:19PM
(#10133412)
It's been discussed before, but that's not really quicksort though (since it's not in-place)[0]
Re:How recursion got into Algol 60: a comedy of errors
by emmelaich on Friday August 28, 2015 @07:27AM
(#10134809)
Do we know that for sure?
I mean - could a sufficiently smart compiler actually create machine code which _did_ do it in-place?
Re:How recursion got into Algol 60: a comedy of errors
by jmount on Thursday August 27, 2015 @10:51PM
(#10133505)
This variant (with the <= comparison) takes c N^2 on lists of length N that a repeated constant ( http://www.win-vector.com/blog/2008/04/sorting-in-anger/ ).
Re:How recursion got into Algol 60: a comedy of errors
by copperx on Thursday August 27, 2015 @09:35PM
(#10133264)
> On the other, boy can a compiler that eschews recursion produce small and fast code.
Are you really implying that if recursion was turned off in a modern compiler it could create better code?
Re:How recursion got into Algol 60: a comedy of errors
by Gibbon1 on Friday August 28, 2015 @01:22AM
(#10133867)
That would be hard to turn off. My experience is with a old 8051 compiler. Notable feature was it never pushed anything on the stack other than return addresses. Used the call tree to fold parameters and local variables into a small amount of common memory. I think modern compilers deal with this situation by in-lining. But that can cause the code size to swell vs calling a subroutine that accesses globals.
Just saying, you add a feature to a language, you will pay something for it.
Offhand years ago I used a dialect of C that had no recursion so I can see both sides of this argument. On the one hand, there is a pain point when you don't have access to recursion. On the other, boy can a compiler that eschews recursion produce small and fast code. (Because without recursion the call graph is acyclic)