突然想到Functional Programming

95 篇文章 0 订阅
55 篇文章 9 订阅
Philip Wadler 在ACM SIGPLAN Notices, Aug 1998上的文章 
"Why no one uses functional languages" 讨论了FP的障碍,主要不是技术上的, 
而是商业上的和政治上(politics in its general meaning)。比如很多程序员都 
只受过Imperaive Programming的训练,还没有人投资去搞出足够成熟的库和开发 
环境(特别是debugger和profiler),和已有的语言的接口支持不够等。 
但通过调查长期使用functinal language和imperative language的人发现, 
FP的开发周期,不管是coding, debugging, 还是maintainance,都更加容易。 
从理论上将,如果一个程序员不用担心side effects, misordered updates,  
和dangling or uninitialized references, 而且能从小到大逐步地构造复杂的 
数据结构(FL的长项的说),那他的开发速度能大大加快。Philip Wadler 
在ACM SIGPLAN Notices, Feb 1998的"An Angry half-dozen"里有具体的调查数据和 
讨论。不知道微是不是也是出于相同的考虑,决定开发F#,来弥补FP商业开发环境的不足 
。 
 
呵呵,顺便说说Logic Programming,也有人说LP的理念更加引人,因为程序员只需制订 
对未知量的逻辑规则,使得编成大大简化,而且使人们可以把编程和Specification及 
Formal Specification Verification相对容易地连接起来,保证了大型项目从一开始就 
是正确的(项目大了,保证Specification consistency很难的说, 所以很多人都在搞 
什么auto verifier)。确实也有大型商业系统用LP开发,据说效果不错(很久前读的文 
章,reference忘了)。但偶个人的经验是,LP用起来不爽。Horn Clause不能实现所有 
的First Order Predicate Calculus,比如A=>P1|P2|P3,相同语意的否定(不是Prolog 
里那个"not"的说)等。所以偶用Prolog时总得用Prolog特有的方式思考,而不是用熟知的 
那套逻辑思考,有束手束脚的感觉。还有就是如果不相当熟悉各种所谓的Execution  
Order的话,写出的代码会非常非常慢(还有多少人能玩儿转cut, fail, repeat, 
 retract什么的? :-D)当然也可以说偶的LP学得不好,哪位老大指点一二? 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Explore functional programming and discover new ways of thinking about code. You know you need to master functional programming, but learning one functional language is only the start. In this book, through articles drawn from PragPub magazine and articles written specifically for this book, you'll explore functional thinking and functional style and idioms across languages. Led by expert guides, you'll discover the distinct strengths and approaches of Clojure, Elixir, Haskell, Scala, and Swift and learn which best suits your needs. Contributing authors: Rich Hickey, Stuart Halloway, Aaron Bedra, Michael Bevilacqua-Linn, Venkat Subramaniam, Paul Callaghan, Jose Valim, Dave Thomas, Natasha Murashev, Tony Hillerson, Josh Chisholm, and Bruce Tate. Functional programming is on the rise because it lets you write simpler, cleaner code, and its emphasis on immutability makes it ideal for maximizing the benefits of multiple cores and distributed solutions. So far nobody's invented the perfect functional language - each has its unique strengths. In Functional Programming: A PragPub Anthology, you'll investigate the philosophies, tools, and idioms of five different functional programming languages. See how Swift, the development language for iOS, encourages you to build highly scalable apps using functional techniques like map and reduce. Discover how Scala allows you to transition gently but deeply into functional programming without losing the benefits of the JVM, while with Lisp-based Clojure, you can plunge fully into the functional style. Learn about advanced functional concepts in Haskell, a pure functional language making powerful use of the type system with type inference and type classes. And see how functional programming is becoming more elegant and friendly with Elixir, a new functional language built on the powerful Erlang base.The industry has been embracing functional programming more and more, driven by the need for concurrency and parallelism. This collection of articles will lead you to mastering the functional approach to problem solving. So put on your explorer's hat and prepare to be surprised. The goal of exploration is always discovery. What You Need: Familiarity with one or more programming languages.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值