OrphanWilde comments on Course recommendations for Friendliness researchers - Less Wrong

62 Post author: Louie 09 January 2013 02:33PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (113)

You are viewing a single comment's thread. Show more comments above.

Comment author: OrphanWilde 09 January 2013 06:00:51PM *  -1 points [-]

Functional-style programming doesn't make it any more natural, it just forbids you from doing things any other way. I spend most of my time when dealing with functional-style programming (primarily in XSLT) trying to figure out ways around the constraints imposed by the language rather than actually solving the problem I'm working on.

In XSLT I once copied a chunk of code 8 times, replacing its recursive function calls with its own code, because it was blowing up the stack; and it's not like I could use mutable variables and skip the recursion, it was literally the only implementation possible. And it had to call itself in multiple places of its own code; it couldn't be phrased in a tail-recursion friendly fashion. Meaning that for that code, no functional language could have resolved the stack explosion issue. -That's- functional programming to me; dysfunctional.

[ETA: Apparently there is a pattern which would overcome the tail stack issue, and compilers exist which can take advantage of it, so my statement that "No functional language could have resolved the stack explosion issue" was false.]

Comment author: gwern 09 January 2013 06:11:53PM *  0 points [-]

In XSLT...That's functional programming to me; dysfunctional.

I think I see the problem here.

Perlis comes to mind:

Beware of the Turing tar-pit in which everything is possible but nothing of interest is easy.

Comment author: JGWeissman 09 January 2013 06:23:05PM 1 point [-]

no functional language could have resolved the stack explosion issue

A functional language could compile to code that uses references to continuations (functions to call, with parameters) instead of the physical stack. See continuation passing style. (The language wouldn't need to use continuation passing style itself, the conversion would straightforward for the compiler to do.)

Comment author: OrphanWilde 09 January 2013 06:56:47PM -2 points [-]

That, to me, falls under "Trying to figure out ways around the constraints imposed by the language."

I suspect it would have made for even messier code, as well, provided it would have even worked for that particular problem. I was parsing a deliberately and ingeniously obfuscated document, and I was updating particular pieces of information based on information obtained in recursive references which, needless to say, were obfuscated, including false flag references which would get me incorrect information if followed; the falsity couldn't be determined locally, either, and required complex conditional comparisons to information contained in parent references. Some of the references were cyclical, to boot.

Comment author: JGWeissman 09 January 2013 07:11:01PM 4 points [-]

That, to me, falls under "Trying to figure out ways around the constraints imposed by the language."

Functional languages do not have inherent stack limits. A stack limit is imposed by a particular implementation of the language, and what I described is how a different implementation of the language could have a much larger stack limit, (constrained by total memory rather than memory initially allocated to the physical stack), with no difference in the source code because the compiler can make the transformation to continuation passing style for you.

The point is that this problem you had with XSLT does not generalize to all possible functional languages the way you think it does.

Comment author: OrphanWilde 09 January 2013 07:19:50PM 0 points [-]

Hm. Granted.

In fairness, I think it does generalize to most implementations.