<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flier&#039;s Sky &#187; training</title>
	<atom:link href="http://blog.flier.lu/tag/training/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flier.lu</link>
	<description>Just for Fun :P</description>
	<lastBuildDate>Sat, 18 Aug 2012 06:00:08 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.21</generator>
	<atom:link rel='hub' href='http://blog.flier.lu/?pushpress=hub'/>
	<item>
		<title>函数式编程入门培训PPT</title>
		<link>http://blog.flier.lu/2010/02/functional_programming_intro_ppt/?source=rss</link>
		<comments>http://blog.flier.lu/2010/02/functional_programming_intro_ppt/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 10:18:23 +0000</pubDate>
		<dc:creator><![CDATA[Flier Lu]]></dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[ppt]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://blog.flier.lu/?p=72</guid>
		<description><![CDATA[上周给公司同事做了一个函数式编程 (Functional Programming) 的介绍，原以为可以随便到网 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>上周给公司同事做了一个<a href="http://en.wikipedia.org/wiki/Functional_programming">函数式编程</a> (Functional Programming) 的介绍，原以为可以随便到网上找一个ppt讲讲，结果发现居然没有合适的可以直接用，只好根据 wiki 结合 python 示例自己整理了一个<a href="http://blog.flier.lu/files/函数式编程入门.pdf?source=rss">培训PPT</a>。大概涵盖了FP的发展历史、基本概念和一些简单例子，回头有空再把它细化一下，看看是否有必要继续深入讲。</p>
<p><iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fblog.flier.lu%2Ffiles%2F%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B%E5%85%A5%E9%97%A8.pdf&#038;embedded=true" width="100%" height="440" style="border: none;"></iframe></p>
<p>说起来<a href="http://en.wikipedia.org/wiki/Functional_programming">函数式编程</a> (Functional programming) 这个话题基本是个无底洞，属于在常青藤高校也能开几年课挂掉无数人的领域。如何在短短一个多小时的时间内，让听众有一些直观印象，进而有兴趣继续深入学习下去，这是让我最为头疼的事情。因此我基本放弃了对那些较为复杂概念的介绍，甚至连 <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">Closure</a> 都只敢简单提及，跟别提什么 <a href="http://en.wikipedia.org/wiki/Monad_(functional_programming)">Monad</a> 这种我自己都挠头的概念。</p>
<p>开讲前在几十个听众中做了个简单调查，果然是听说过和使用过 FP 的人基本都是个位数。这基本上可以说是天朝 CS/EE 教育失败的体现，要知道欧美大学第一年就会讲 <a href="http://book.douban.com/subject/1451622/">Structure and Interpretation of Computer Programs</a> 这种被 Joel 视为是否适合就读 CS 专业过滤器的 BT 课程 (<a href="http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/">在线课程</a>)。</p>
<p><a href="http://book.douban.com/subject/1451622/"><img class="alignnone" title="Structure and Interpretation of Computer Programs" src="http://img2.douban.com/mpic/s1463770.jpg" alt="" width="101" height="146" /></a></p>
<p>因此在一开始的时间里，基本上都是集中在对 FP 的鼓吹上，基本集中在 (1) 应对复杂性，(2) 降低维护成本和 (3) 增强自信心三个角度。前面两个基本上是洗脑用套话，个人最赞同也最想灌输的是第三点。</p>
<p>如果实际参与开发过代码量上百万行，代码维护历史在5-7年以上，先后参与人数几十上百的产品，最直观的感受是应该就是对其自身复杂性的本能恐惧。因为对绝大多数技术人员来说，我们更倾向于参与具有确定性的工作，也就是说我们潜意识里认为，我们做的事情应该是有可预测结果的。但一旦代码复杂到了一定程度，解耦没有到位过过于到位，我们就会发现所有的修改，都有可能引发不确定的影响。为了缓解这种影响，我们搞出了各种各样的最佳实践，TDD、CI、peer review，blabla；但归根结底我们只是试图用这些尝试来确保，我们有胆量继续修改那些我们自己也逐渐无法控制的代码，就好象在黑夜中无助的抓住一个火把，却又大声喊叫说自己不怕黑暗。</p>
<p>FP 在这方面可以说具有天然的优势，在去除 <a href="http://en.wikipedia.org/wiki/Side_effect_(computer_science)">side effect</a> 和复杂控制逻辑后，我们通过 <a href="http://en.wikipedia.org/wiki/Purely_functional">Pure functions</a> 和 <a href="http://en.wikipedia.org/wiki/Recursion_(computer_science)">Recursion</a> 表达的是我们真正的计算目的，而非达成目标的方法。这也是声明式语言 (<a href="http://en.wikipedia.org/wiki/Declarative_programming">Declarative programming</a>) 与命令式语言 (<a href="http://en.wikipedia.org/wiki/Imperative_programming">Imperative programming</a>) 最大的差别所在。这也是为啥我在开发 <a href="http://code.google.com/p/rabbitmq-memcached/">rabbitmq-memcached</a> 时，真正能把大部分时间用在编写代码上的原因，实际上线调试反而只是简单而且直接的结果而非过程。</p>
<p><a href="http://www.info.ucl.ac.be/~pvr/paradigmsDIAGRAMeng101.jpg"><img class="alignnone" title="The principal programming paradigms" src="http://www.info.ucl.ac.be/~pvr/paradigmsDIAGRAMeng101.jpg" alt="" width="100%"  /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flier.lu/2010/02/functional_programming_intro_ppt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
