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 in Go

45 pointsby gus_leonel7 months ago

6 comments

eska7 months ago
I think shoehorning fp onto go just results in people having a wrong first impression of fp, damaging them for years or forever. fp is so much more than map, filter and reduce.
评论 #42089399 未加载
评论 #42089277 未加载
评论 #42089373 未加载
SleekoNiko7 months ago
I&#x27;ve tried going down this route myself by using libraries like fp-go[1]. I think this particular project has done a great job, but I ultimately opted not to pursue functional programming in Go for a few reasons:<p>- Ergonomics weren&#x27;t the greatest when working with monads such as options and results. I think pattern matching is needed here, but concepts like those go against Go&#x27;s core design philosophy.<p>- I suspect there are several cases where runtime performance is an issue, but admittedly did not investigate this.<p>- Perhaps most importantly, it deviates from the way most people read and write Go, and less importantly, LLMs struggle too.<p>Because of these reasons, I came to the conclusion that the advantages were not worth the trade-offs.<p>Perhaps somebody will create a garbage-collected Rust-like language in the future and bridge the gap between the two languages.<p>[1] - <a href="https:&#x2F;&#x2F;github.com&#x2F;IBM&#x2F;fp-go">https:&#x2F;&#x2F;github.com&#x2F;IBM&#x2F;fp-go</a>
评论 #42089198 未加载
评论 #42089100 未加载
freitzzz7 months ago
Function operations are possible in Go like it’s possible in any language that define function in the syntax. But functional programming goes beyond functions, and Go was not designed to support it.<p>I’m a fan of Go and FP and would love to see someone bridge other FP aspects like monads, in a way that feels natural in Go.
评论 #42088826 未加载
librasteve7 months ago
I think there is a genuine tension between languages that can do functional and languages that are functional. Sometimes having functional there as one of the tools, but not the only tool, is best.<p>For example raku (and perl before it) has very good support with map&#x2F;grep&#x2F;closures, etc.<p><a href="https:&#x2F;&#x2F;rakujourney.wordpress.com&#x2F;2024&#x2F;10&#x2F;12&#x2F;raku-burritos&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rakujourney.wordpress.com&#x2F;2024&#x2F;10&#x2F;12&#x2F;raku-burritos&#x2F;</a><p>Says…<p>And let’s end with a quote (sadly I did not record the originator)…<p>I think i just expressed my thought in a wrong way, haha. I am a functional freak, and the first thing i did was check out Raku’s functional patterns. I was amazed. Raku can be extremely functional, but in my opinion language can be called functional when there’s no other way other than functional for the most part. Raku has great functional support, but the language doesn’t force you into anything, you can do basically anything! A sandbox language, and i am loving it.<p>anon
ojhughes7 months ago
Take a look at the Ginkgo testing framework to see the horrors of shoe horning FP into Go<p><a href="https:&#x2F;&#x2F;onsi.github.io&#x2F;ginkgo&#x2F;#writing-specs" rel="nofollow">https:&#x2F;&#x2F;onsi.github.io&#x2F;ginkgo&#x2F;#writing-specs</a>
评论 #42090869 未加载
评论 #42093902 未加载
Insanity7 months ago
Hey, I wrote a book with that exact same title as the blog post.. :) not sure if HN frowns upon this kind of self-advertising in comments, but well.. you can find it on Amazon &#x2F; Packt, if you are interested lol