TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Disadvantages of purely functional programming

90 点作者 YAFZ将近 9 年前

8 条评论

Roboprog将近 9 年前
It seems to me that yes, you need an &quot;escape hatch&quot; in an FP language to make your updates.<p>It would be nice if the language required such functions, and the modules in which they reside, to be flagged. (I don&#x27;t know if Haskell does something like this with mutation, or not)<p>It also seems that an &quot;actor model&quot; would be a good way to encapsulate the updates in an otherwise FP program by having a loop&#x2F;reduce&#x2F;fold wrapped around the mutable data responding to request-events and generating responses. This allows the other pure&#x2F;immutable&#x2F;idempotent type of code to remain isolated from it.
评论 #11842315 未加载
efnx将近 9 年前
Harrop is known in the Haskell community for being a hater. Most of his remarks here are opinion, which is fine. Lots of people don&#x27;t like Haskell - that&#x27;s also fine, but pieces like these hurt the community because it will both push away newcomers and make industrial use more difficult.<p>Also, I&#x27;ve never needed an unsorted dictionary, and parallelism is actually great in Haskell. <a href="http:&#x2F;&#x2F;chimera.labs.oreilly.com&#x2F;books&#x2F;1230000000929&#x2F;index.html" rel="nofollow">http:&#x2F;&#x2F;chimera.labs.oreilly.com&#x2F;books&#x2F;1230000000929&#x2F;index.ht...</a>
评论 #11841702 未加载
评论 #11841862 未加载
LionessLover将近 9 年前
I found another article linked from the one linked here more interesting, but it&#x27;s not about &quot;FP&quot; but only about Haskell:<p>&quot;Why is Haskell used so little in the industry?&quot; - <a href="http:&#x2F;&#x2F;flyingfrogblog.blogspot.de&#x2F;2010&#x2F;05&#x2F;why-is-haskell-used-so-little-in.html" rel="nofollow">http:&#x2F;&#x2F;flyingfrogblog.blogspot.de&#x2F;2010&#x2F;05&#x2F;why-is-haskell-use...</a><p>Go and grab some popcorn before you move on to the comment section...<p>It&#x27;s from 2010, I&#x27;d be interested in an update, just out of mild curiosity.
评论 #11841697 未加载
评论 #11842014 未加载
GreaterFool将近 9 年前
Sadly, the author&#x27;s chosen style is a rant and it is counterproductive.<p>There&#x27;s plenty of words and claims are made but benchmarks or code are nowhere to be seen. Why should anyone take these claims at face value?<p>&gt; Furthermore, most functional programming languages (OCaml, Haskell, Scala) are incapable of expressing a fast generic mutable hash table because they lack the killer combo of: reified generics, value types and a fast GC write barrier.<p>Sounds plausible? Maybe. Incapable is a strong word. I&#x27;m not an expert on mutable hash-tables so I don&#x27;t know for sure. If I was making a claim that you can&#x27;t implement mutable hash table without 2 square feet of badger fur and a pound of whale fat would you believe me? I would like to see a citation.<p>I have written a lot of Haskell and there was never a situation when I said to myself &quot;if only Data.HashMap (unordered-containers) was faster&quot;. Just make sure you&#x27;re using the right tool for the job (which might not be Haskell).<p>The author doesn&#x27;t seem to write any code himself but instead links to code that other people have written and then makes claims about F# being better (I can&#x27;t find the F# solution to parallel quicksort from one of the linked posts). I see very little value in that.
评论 #11841943 未加载
评论 #11842050 未加载
评论 #11842016 未加载
danharaj将近 9 年前
This post lists 9 points, but the first 7 are all variations of &quot;mutable data structures suck in a pure language!&quot; and the other 2 are &quot;look at all these fucking idiots who talk about purely functional programming!&quot;<p>So the first 7 points are true because pure functional programming, <i>by definition</i> does not support mutable data structures very well. It is what it says on the tin.<p>If you go on stack overflow you&#x27;ll find no shortage of ill-informed, unhelpful input about imperative programming languages. I think it&#x27;s very strange to call a social phenomenon that is universal in software that affects every language community is a disadvantage of something as broad as &quot;purely functional programming&quot;. If you want good discussion, go on the mailing lists or the IRC channels. #haskell is a very good channel with a lot of active professionals who love answering questions.<p>I am a professional Haskell programmer, AMA.
评论 #11841773 未加载
chubot将近 9 年前
Good points, although I agree that a lot of them boil down to similar statements.<p>I have settled on a style of doing &quot;functional-like&quot; programming in Python and C++. It&#x27;s more about the high level architecture than low level coding details.<p>It means being very paranoid and rigorous about state -- but still having great tools to express it! For example: Using ZERO mutable globals, and passing state in as a parameter to functions. Using immutable&#x2F;persistent data structures. These techniques are done very naturally and effectively in Python and C++. You just have to be disciplined.<p>To me there&#x27;s no real advantage to expressing something like &quot;split a string by a delimiter&quot; in a purely functional style. Either way, you have a trivial referentially transparent function you can reuse without causing complexity in your program. You might as well do the obvious imperative thing.<p>However there IS a benefit to threading state explicitly throughout the application, and encapsulating it in OBJECTS (yes objects).<p>For me, the thing that sealed the deal against functional languages for &quot;real work&quot; was trying to write a production quality sh parser.<p>I went down a long path of trying to do this first in OCaml and then in Lisp. The VERY first thing that hits you over the head -- lexing -- is heavily and inherently stateful. ocamllex and ocamlyacc to me are evidence of this paucity and poverty of purely functional solutions. They&#x27;re just transliterating solutions from C. Well I might as well use C then.<p>Actually, I decided to use C++, which was like my 5th choice as language. Aside from headers and compile times, it&#x27;s a good choice. I use &quot;functions and data&quot; (a la Rich Hickey).<p>Except my functions and data are both CLASSES. Data objects are basically structs, except they can do things like print themselves and answer simple queries based on their values, which helps readability (e.g. 1 liners, like word.AsFuncName() ).<p>Function objects are simply classes with configuration passed to constructors. That usually have a single method, but multiple methods are also often useful. Calling this method is basically equivalent to calling a curried function. But this is supremely useful for both compilers and servers, because often you have config&#x2F;params that is constant once you reach main(), and then you have params that vary per request or per file processed. Many functions depend on both, and it&#x27;s cleaner to separate the two kinds of params.<p>So both &quot;functions and data&quot; are effectively and usefully implemented as classes. The key is to make some classes like functions, and some classes like data. And have more of a bipartite dependency graph, where functions depend on data, and data depends on functions.<p>When all your classes are an equal mix of data and behavior, that&#x27;s when they start getting &quot;hard-coded&quot; weird-shaped dependencies, and your program turns into fragile spaghetti. Functions and data are a useful architectural technique, and to me it doesn&#x27;t have that much to do with Clojure or Lisp, although Hickey is certainly a great advocate.
评论 #11842161 未加载
评论 #11841987 未加载
评论 #11842085 未加载
评论 #11842175 未加载
tome将近 9 年前
Luckily Haskell supports impure functional programming too ...
xyzzy4将近 9 年前
I don&#x27;t get why people would use functional programming for anything. It&#x27;s both more difficult and slower.
评论 #11841649 未加载
评论 #11842029 未加载
评论 #11841917 未加载
评论 #11841624 未加载
评论 #11841613 未加载
评论 #11841679 未加载
评论 #11841598 未加载
评论 #11841784 未加载