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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Intrinsically Functional

27 点作者 D_Guidi超过 7 年前

1 comment

yehohanan7超过 7 年前
Functional programming is probably the most misunderstood idea by programmers today, There are 2 types of people<p>1. Purist functional programmers: These are the ones who try hard to separate the side effects in your code from the pure functions and make sure every line of code they write is pure, they avoid using variables, avoid assignments at any cost. there&#x27;s nothing wrong in being a purist, but sometimes, people also try to write a lot of concise code with a lot of magic underneath which has it&#x27;s drawbacks.<p>2. Pragmatists: the one&#x27;s who believe you can do functional programming in any language, be it C, C++, Java, Haskell, Lisp, Go etc if you focus only on the benefits of functional programming, you can get it without really being pure in &quot;every line of code you write&quot; - for instance, if i have to write a function that takes a list and gives the length back, i could either use the fancy map&#x2F;reduce etc or have a &quot;local&quot; variable declared inside a function and increment it for each element in the list and return the final result.<p>Well, you might say mutating a variable is not functional programming - but i don&#x27;t care, my function is still pure and it is referentially transparent and i don&#x27;t have to think a lot about the various choices that i may have to do the same thing (map, reduce, etc etc). if you have read the book called &quot;paradox of choice&quot;, it clearly explains how having multiple choices hinders your happiness and scala always reminds me of that problem, having 100 ways to do a simple thing slows you down and hinders your productivity. That&#x27;s one of the reason why language like Go made the spec so simple and there&#x27;s always only one way to do anything syntactically.<p>I think functional programming should be looked at in a more pragmatic way - how do i achieve all the advantages of functional programming like doing a bottom up design, immutability, testability, readablity etc without really using a specific functional language&#x2F;syntax which i agree makes it a bit easy for you syntactically, but hey &quot;concise is not always clear&quot; and your end goals are more important than the syntaxes
评论 #15807548 未加载
评论 #15807481 未加载
评论 #15810066 未加载