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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Can functional programming be liberated from the von Neumann paradigm? (2010)

92 点作者 bkirwi超过 10 年前

5 条评论

tenfingers超过 10 年前
It&#x27;s worth nothing that functional programming is hard not because of the functional paradigm, but due to the constraints you have while solving a problem (memory, for one).<p>This requires changing the simple, composable functions that you could reuse forever, to complex ones that have to split the work into multiple stages.<p>Another source of inherent complexity which has nothing to do with the solution of the problem itself, is the handling of the input or runtime issues. Input cannot be guaranteed to be always coherent, and runtime issues may arise while running (user interrupt). At this point, interrupting the computation is easy, but as an user I want maybe:<p>* know why the function stopped, with a meaning answer (not just a stack trace)<p>* know the location of the error in the input data<p>* the possibility to resume the computation<p>If you&#x27;ve ever programmed functionally, you know how hard is to do something as simple as give meaningful error messages buried into a series of fold&#x2F;map calls.<p>Keeping state is a simple (and I would say equally elegant) solution to this recurrent problem. Please consider that I&#x27;m saying this from a functional programming perspective (as in: objects as localized state containers not necessarily breaking the purity assumption).<p>Another issue is that we, as humans, are based on a stateful world. Stateful user interfaces are sometimes more efficient due to the way _we_ work. This can be seen in something as simple as &quot;now select a file&quot;, which brings up a dedicated section of stateful code to navigate a tree. As such, you are constantly faced with the problem of keeping state.
评论 #8823020 未加载
评论 #8822991 未加载
jdiaz5513超过 10 年前
We do have a functional language that&#x27;s free from imperative constraints - it&#x27;s called mathematics; everything runs on it.<p>We just don&#x27;t have the source code.
hellbanner超过 10 年前
Can someone please explain: &quot; An FP system cannot compute a program since function expressions are not objects. Nor can one define new functional forms within an FP system. (Both of these limitations are removed in formal functional programming (FFP) systems in which objects &quot;represent&quot; functions.) Thus no FP system can have a function, apply, such that apply: &lt;x,y&gt; = x :y because, on the left, x is an object, and, on the right, x is a function. (Note that we have been careful to keep the set of function symbols and the set of objects distinct: thus 1 is a function symbol, and 1 is an object.)&quot;<p>I understand what it says. I don&#x27;t understand why<p>apply:&lt;x,y&gt; === x:y<p>doesn&#x27;t work in the construct of functional programming?
jacquesm超过 10 年前
This page doesn&#x27;t load for me, which is a pity.<p>Why limit the question just to functional programming?<p>This applies just as much if not more to imperative programming, at least in functional programming you have the option to execute any pure function in parallel on some independent chunk of hardware.<p>Whether imperative programming can be &#x27;liberated&#x27; from the von Neumann bottle-neck is a much harder problem.<p>In the end both will still have to deal with Amdahl&#x27;s Law, so even if you could get rid of the &#x27;looking at memory through a keyhole&#x27; issue you&#x27;re going to have to come to terms with not being able to solve your problem faster than the sequential execution of all the non-parallizable chunks.
评论 #8822587 未加载
评论 #8822580 未加载
评论 #8823885 未加载
评论 #8823418 未加载
评论 #8822592 未加载
michaelochurch超过 10 年前
This is a really interesting article (and a blog I want to come back to). Thanks, OP.<p>What Haskell seems to achieve, and I&#x27;m not an expert on it yet, is an incentive system that encourages small functions <i>especially</i> when you&#x27;re &quot;in&quot; a monad, because of the &quot;any side effects makes the whole function &#x27;impure&#x27;&quot; dynamic as seen in the type system (also known as &quot;you can&#x27;t get out of the monad&quot;). Of course, it&#x27;s sometimes a pain in the ass to thread your RNG state or other parameters (that remain implicit in imperative programming) through the function, and that&#x27;s where you get into the rabbit hole of specialized monads (State, Reader, Writer, RWS, Cont) and, for more fun yet, monad transformers.<p>I think that the imperative approach to programming has such a hold because, at small scale, it&#x27;s far more intuitive. At 20 lines, <i>defining functions</i> feels dry and mathematical and we&#x27;re much more attracted to the notion of <i>doing</i> things (or, making the computer do things). And, contrary to what we think in functional programming, imperative programming <i>is</i> more intuitive and simpler at small scale (even if more verbose). It&#x27;s in composition and at scale (even moderate scale, like 100 LoC) that imperative programming starts to reach that high-entropy state where it&#x27;s hard to reason about the code.
评论 #8823702 未加载
评论 #8832510 未加载
评论 #8823554 未加载