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.

Functional programming isn't the answer

8 pointsby buffyodaover 11 years ago

6 comments

Chatteredover 11 years ago
I call code in Haskell&#x27;s IO <i>imperative</i>. If you are tempted to call it pure functional, read this:<p><a href="http://conal.net/blog/posts/the-c-language-is-purely-functional" rel="nofollow">http:&#x2F;&#x2F;conal.net&#x2F;blog&#x2F;posts&#x2F;the-c-language-is-purely-functio...</a>
fexlover 11 years ago
I&#x27;m pretty sick of all high-level languages actually. I even wrote my own functional programming language &quot;Fexl&quot;, and I&#x27;m sick of it too. Here&#x27;s a totally general purpose quicksort:<p><pre><code> # (sort keep compare xs) sorts the list xs using the three-way comparison # function. It keeps duplicates if the keep flag is true, otherwise it # discards them and returns only the unique entries. \sort = (@\sort\keep\compare\xs xs [] \x\xs \lo = (filter (\y compare y x T F F) xs) \hi = (filter (\y compare y x F keep T) xs) \sort = (sort keep compare) append (sort lo) [x; sort hi] ) </code></pre> I&#x27;m tired of all of it. The language I really like is plain old C.<p>To handle arbitrary strings reliably, I can just use this code:<p><a href="https://github.com/chkoreff/Fexl/blob/master/src/str.h" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chkoreff&#x2F;Fexl&#x2F;blob&#x2F;master&#x2F;src&#x2F;str.h</a><p><a href="https://github.com/chkoreff/Fexl/blob/master/src/str.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chkoreff&#x2F;Fexl&#x2F;blob&#x2F;master&#x2F;src&#x2F;str.c</a><p>To deal with dynamic allocation, detecting any memory leaks upon program exit, I use this:<p><a href="https://github.com/chkoreff/Fexl/blob/master/src/memory.h" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chkoreff&#x2F;Fexl&#x2F;blob&#x2F;master&#x2F;src&#x2F;memory.h</a><p><a href="https://github.com/chkoreff/Fexl/blob/master/src/memory.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chkoreff&#x2F;Fexl&#x2F;blob&#x2F;master&#x2F;src&#x2F;memory.c</a><p>For high-speed buffering of data, one character at a time, I can use this:<p><a href="https://github.com/chkoreff/Fexl/blob/master/src/buf.h" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chkoreff&#x2F;Fexl&#x2F;blob&#x2F;master&#x2F;src&#x2F;buf.h</a><p><a href="https://github.com/chkoreff/Fexl/blob/master/src/buf.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chkoreff&#x2F;Fexl&#x2F;blob&#x2F;master&#x2F;src&#x2F;buf.c</a>
na85over 11 years ago
Functional programming is in vogue right now, just as object-oriented was a few decades ago. The hype will fade, and just like any other programming paradigm (including object-oriented) there will be use cases where it is and is not the most appropriate.<p>I wish we could all ignore these hype trains.
评论 #7018461 未加载
mattfenwickover 11 years ago
The article appears to be flamebait.<p>The main point is trivial because it applies to nearly every single technique&#x2F;tool&#x2F;language&#x2F;framework: &quot;X is not perfect. X can&#x2F;should not be applied in all situations. X must be augmented by Y. X is a means to an end, not an end unto itself.&quot; etc.<p>It mixes the trivial, obviously true (&quot;Every technique has to be measured on its own, independent of weather or not it’s &#x27;functional&#x27;&quot;) with that sure to offend (&quot;The Religion of FP&quot;).<p>I don&#x27;t see any real insight. What does it have to say that we didn&#x27;t already know?
corditeover 11 years ago
I don&#x27;t think this trivial algorithmic example even does a good job at being the straw man in this argument.<p>Yeh, he&#x27;s right in that its another means to an end, but where&#x27;s the comparison to other means? This just seems like a bash on FP, rather than an intelligent discussion on what can give us a better answer.
CmonDevover 11 years ago
The real benefit is immutability, the rest is syntax sugar.