TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

We need functional programming because a large subset of us are average or below

14 pointsby wfalerover 10 years ago

2 comments

wereHamsterover 10 years ago
I&#x27;m not buying it. Having worked at a company which did all their software in a purely functional language, I haven&#x27;t seen any evidence which would support his points.<p>&gt; You do not have to build a mental model of the whole system and its libraries to reason about it.<p>You have to build a mental model of the part which you are looking at if you want to reason about it. If you&#x27;re looking at a single function, you need to build yourself a mental model of that one function. If you want to reason about the whole app, well, then you have to build a mental model of it all. The language you use doens&#x27;t change that.<p>&gt; Corollary, you can reason about any subset of the system, however small, without having to even understand what the whole system does.<p>That is true in any programing language.<p>In practice however this doesn&#x27;t hold. You very often can&#x27;t reason about the correctness of a single function without also knowing it&#x27;s immediate surrounding code. or in which context it is used.<p>&gt; You don’t have to rely on your memory of something you did possibly years ago to deal with new requirements, changes or to track down bugs.<p>Neither do you in any other language. Just follow the code. And: badly structured FP code is harder to follow than clean procedural code. FP alone doesn&#x27;t buy you anything.<p>&gt; For the managers out there: key-person dependencies (“the guy who knows everything about the system”) become less of an issue.<p>It is exactly the same issue as if you were writing the code in any other language. Having a single person who knows about a certain part of your application is bad. Functional language doesn&#x27;t protect you from it.<p>The measure should be how long it takes a new person to get familiar with the code. Well-structured code written in any language should be equally easy to understand and follow. I&#x27;ve seen some really bad code written in a functional language. Here again, FP doesn&#x27;t protect you from bad code or its consequences.<p>&gt; New people can become productive much faster, no longer having to spend the time building a mental model of everything.<p>Any reasonably complex app will require programers to know about many aspects of the app. You can&#x27;t make changes to one part without knowing what consequences it will have to other parts. This is especially true for logic-heavy apps.<p>A new programmer you just hired may have the impression that changing that one little knob in a small function there fixes the bug. But it may have to him unknown consequences because he doesn&#x27;t know where and how that function is used, what pre&#x2F;post-conditions the callers are expecting etc.
mcxover 10 years ago
For the first example used:<p><pre><code> public void addBar(Foo foo){ Bar bar = new Bar(&quot;baz&quot;); foo.setBar(bar); dao.update(foo); dao.save(bar); } </code></pre> What would the functional version look like?
评论 #8350019 未加载