View Single Post
Old 05-01-2012, 04:38 PM   #1

8IronBob's Avatar
John Carmack on Functional Programming in C++
This looked like an interesting read. For those of you who are big in C++ game development, or any C++ development in general, it seems like Carmack let the dog loose with his thoughts on it, and it should be quite inspiring:

Originally Posted by Gamasutra - News - In-depth: Functional programming in C++
Probably everyone reading this has heard "functional programming" put forth as something that is supposed to bring benefits to software development, or even heard it touted as a silver bullet. However, a trip to Wikipedia for some more information can be initially off-putting, with early references to lambda calculus and formal systems. It isn't immediately clear what that has to do with writing better software.

My pragmatic summary: A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. In a multithreaded environment, the lack of understanding and the resulting problems are greatly amplified, almost to the point of panic if you are paying attention. Programming in a functional style makes the state presented to your code explicit, which makes it much easier to reason about, and, in a completely pure system, makes thread race conditions impossible.

I do believe that there is real value in pursuing functional programming, but it would be irresponsible to exhort everyone to abandon their C++ compilers and start coding in Lisp, Haskell, or, to be blunt, any other fringe language.
PC Specs (a.k.a. "Galacticus Prime"):
8IronBob is offline