How to avoid bugs by thinking functionally

2008年12月5日
http://channel9.msdn.com/shows/Going+Deep/Erik-Meijer-Functional-Programming/#Page=1

 
As functional programming really avoids bugs in a very good way, how can we avoid bugs when using a traditional programming language?  My suggestion is: wrap logic into functions, and think of a function as having an input and an output, and try to make sure the function processes the input correctly and gives a correct output.  The input and output can be an environment, such as the file system with before and after states, or can be a data object with before and after states, or can be two objects which are disconnected with each other.  Hope this explains how to think more functionally.  BTW, for parallelism, functional programming languages have an advantage, that is, the compiler knows a function and can do optimization on it; this is what conventional languages can’t easily do (hard to do).

留下您的评论