LispCast http://www.lispcast.com/ A blog about the simple joys of functional programming. en Object-Oriented Dispatch is the Dual of Functional Dispatch http://www.lispcast.com/object-function-duals-dispatch http://www.lispcast.com/object-function-duals-dispatch Wed 11 Mar 2015 02:56:53 PM CDT Object-oriented dispatch is contrasted with functional dispatch, but they are shown to be two one-dimensional projections of the same two-dimensional data. Clojure does not provide the two-dimensional representation, but does interesting things to transcend the one-dimensional views. <p><center><a href="http://www.lispcast.com/object-function-duals-dispatch">Read full post</a></center></p> Object-Oriented Programming is the Dual of Functional Programming http://www.lispcast.com/object-oriented-vs-functional-duals http://www.lispcast.com/object-oriented-vs-functional-duals Sun 08 Feb 2015 11:22:31 AM CST Object-Oriented Programming is often shown in contrast to Functional Programming. But they are so exactly opposite that they are duals, and so equivalent in important ways. Which one to use should be left up to the programmer, as is done in Clojure and Javascript. <p><center><a href="http://www.lispcast.com/object-oriented-vs-functional-duals">Read full post</a></center></p> The Paper Metaphor http://www.lispcast.com/paper-metaphor http://www.lispcast.com/paper-metaphor Fri 27 Feb 2015 12:57:38 PM CST Functional programs follow a simple rule: never write on the same paper twice. Imperative programs are free to define their own rules. Both have interesting consequences. <p><center><a href="http://www.lispcast.com/paper-metaphor">Read full post</a></center></p> The Content of Your Code http://www.lispcast.com/the-content-of-your-code http://www.lispcast.com/the-content-of-your-code Mon 06 Oct 2014 02:25:46 PM CDT Code style is important, but way less important than content. Yet everyone talks about style because it's easier. Let's talk about content. <p><center><a href="http://www.lispcast.com/the-content-of-your-code">Read full post</a></center></p> What is Functional Programming? http://www.lispcast.com/what-is-functional-programming http://www.lispcast.com/what-is-functional-programming Tue 01 Jul 2014 10:47:20 AM CDT I prefer to define Functional Programming as making a distinction between pure and impure code. With this definition, you can program functionally in any language. What differentiates the functional languages is how much help they give you to make the distinction. <p><center><a href="http://www.lispcast.com/what-is-functional-programming">Read full post</a></center></p> Deconstructing Functional Programming http://www.lispcast.com/deconstructing-functional-programming http://www.infoq.com/presentations/functional-pros-cons Sun 22 Dec 2013 04:33:32 PM CST <blockquote> <p>Because if you think about it, the stack itself is just an optimization. Right? There are these frames which contain information about each invocation. Each stack frame. Each activation record. And that's what they are--they're activation records. They're sort of objects. If you really have objects on the brain, like I do, then you realize that they're all just objects.</p> </blockquote> <blockquote> <p>And they should be treated uniformly. You can even build a language that works this way--as I have. If that's the case, this is really a garbage collection problem. Right? Your stack traces might go away if you don't need them. You do need them when it's not a tail call because you need to go back there and use that information. But if it's a tail call, you don't need them, you don't need a tail call back to that frame. You need a pointer back to the last frame that wasn't a tail call. And they might get collected.</p> </blockquote> <blockquote> <p>Which doesn't mean you actually have to implement it that way. Erlang sort of does. And there are many implementations that do that. They are not noted for their speed. If you can have real stacks, what happens when you run out of space? If you don't run out of space, it didn't really matter if you optimized the tail calls or not.</p> </blockquote> <blockquote> <p>When you run out of space, you should GC the damned stack. You shouldn't just throw up your hands and say you're dead. And for all the normal programs that people write where it didn't matter, they won't care. And for your tail recursive programs, well, they might be a bit slower, but they will work. And then it's a matter of flags to the garbage collector if in production you don't want to debug it if you're sure it's all going to be fine--then go ahead and tell it to don't bother and just slam it and overwrite those frames directly.</p> </blockquote> <p>Why is this so hard for implementers to do? Optimization is an optimization and should be optional.</p> <blockquote> <p>It's a cool algorithm, but there's nothing nice that I'm prepared to say about Hindley-Milner.</p> </blockquote> <p>He nails a lot of things I didn't like about Haskell.</p> <p>All in all, this talk gets a lot of things right.</p> <h3 id="you-might-also-like">You might also like</h3> <ul> <li><a href="http://www.lispcast.com/object-function-duals-dispatch">Object-Oriented Dispatch is the Dual of Functional Dispatch</a></li> <li><a href="http://www.lispcast.com/object-oriented-vs-functional-duals">Object-Oriented Programming is the Dual of Functional Programming</a></li> <li><a href="http://www.lispcast.com/paper-metaphor">The Paper Metaphor</a></li> <li><a href="http://www.lispcast.com/the-content-of-your-code">The Content of Your Code</a></li> </ul> <p><center><a href="http://www.lispcast.com/deconstructing-functional-programming">Read full post</a></center></p>