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.

Ask HN: Why and how functional programming?

4 pointsby djangovmover 6 years ago
Lots of questions in this rant. Please bear with me<p>Coming from OOP paradigm, I am struggling to understand how a FP paradigm can be effectively leveraged in larger systems (should I even try?), especially in ERP systems found in most companies. Such systems have too many external dependencies (libraries and external services), umpteen variations of usecases, and many more coming every day. Often, Java (hugely) or other JVM languages (like scala) are used in such companies. Fitting FP on JVM languages has their own issues. Dependencies cannot be expected to be pure as far as FP is concerned, and this leaks in writing in FP style in multi-paradigm jvm languages. For example, mutation of structures become imminent if we want to optimize code (since JVM compiler doesn&#x27;t help, or does it?).<p>I found this talk [1] informative (Functional core&#x2F;Imperative Shell) for a mixed ecosystem. But maintaining a tight boundary as to what goes in an FP core, and what remains in the imperative shell is difficult to attain.<p>Problems are compounded by<p>1. Developer knowledge (not everyone in the team understands FP), and associated steep learning curve.<p>2. Managing dependencies (a.k.a. Dependency Injection) does not seem to go away in large systems. I have not yet found a clean way to manage these dependencies in a FP paradigm. Have you? (I read about reader monads&#x2F;kleisli being one way to do so, but seems too much work as compared Dagger, for eg.)<p>3. Best practices around large FP system, and more so around an FP core within an imperative ecosystem, seem to be still evolving. Are there good resources that I am unaware of?<p>FYI, I have read Mostly Adequate Guide.<p>Am I the only one struggling with these issues? If yes, what am I missing, and what can I read&#x2F;watch to get a clear thought process around these? If not, how do you guys manage such systems if you want to move towards FP?<p>[1] https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;talks&#x2F;boundaries

1 comment

felixschlover 6 years ago
1. If you managed to learn a paradigm as arbitrary and unprincipled as OOP, learning pure FP should be a walk in the park. I find it an odd argument to put in the way of progress. Anecdotally, I have not heard of anyone regretting to learn FP, let alone going back to OOP. I would love to hear from people learning FP first, how did you find learning OOP as a second paradigm?<p>2. I&#x27;ve never found a need for (automated&#x2F;annotated) dependency injection in FP. In languages that support it you can use type-classes for the most part or just add another function argument &#x2F; close over state, or user a `ReaderT`, or most likely a combination of the above.<p>I&#x27;d say the only way to understand how useful and applicable FP is, is to go learn and use it for a while to solve actual problems. I found most things you think you&#x27;ll miss you won&#x27;t ever end up missing, because you actually never needed them in the first place.