AstonJ

AstonJ

Has learning a functional language changed the way you use or think about OOP languages?

Yes? No? If yes, how/in what way?

Most Liked

dimitarvp

dimitarvp

FP really drove home the message to me that I was doing programming wrong my entire life before that. :smiley:

…Namely “data structures > code”. If you know the shape of your data and can think in data then the code kind of comes naturally after – LISP is an excellent demonstration of this approach but Elixir is quite close with its metaprogramming abilities as well.

So I am looking into getting more into the math foundations of FP and then learn a ton of data structures and algorithms.


FP taught me that the programming language syntax, 99.9% of the time, doesn’t matter one bit. What’s important is the data. And having an excellent runtime like the BEAM VM.

brentjanderson

brentjanderson

Absolutely. Ultimately both OOP and FP can get great work done, but I’ve found that a functional style helps clarify my thinking. Separating the data structures from the functions brings a tremendous clarity to my designs.

These days, I actually use classes for dependency injection containers - the meat of the program still tends to be highly functional.

Korbin73

Korbin73

My biggest takeaways while learning and now preferring FP that have changed my perspective on OOP languages is the following (some of them are not good):

  1. Quarantine side effects. This has help a lot with reducing bugs and making unit testing easier since it means that my pure functions aren’t intermingled with all of the effectful code.
  2. It made me realize how much harder OOP is to get the same result. Mutability adds complexity that most of us don’t even notice: Time. When a value changes over time you pretty much have to us a debugger to see it change and why it’s changing. In FP it’s just a new binding. Also, coupling behavior with data makes it even harder to manage because you end up with temporal coupling when one property or method changes a value and a method was depending on the value of a member var to be in a certain state. In FP, new state changes are very explicit (and far simpler). State (data) goes in… and new state comes out.
  3. The bad part is that FP has made me realize that is so much simpler to program in so I get annoyed in OOP languages when I have to do something simple like create a class just to add behavior to my program when a simple function will do.

Popular Backend topics Top

AstonJ
Which server-side languages are you most interested in right now? Anything new or relatively new that’s caught your eye? Maybe an older l...
New
AstonJ
Currently a hot topic in the BEAM world, let’s start a thread for it (as suggested by @crowdhailer here) :smiley: What are your current...
New
bot
A new item has been posted: This thread was posted automatically, if you feel it could be in a better category and are at Trust Level ...
New
bot
A new item has been posted: https://crates.io/crates/rsfbclient This thread was posted automatically, if you feel it could be in a bett...
New
pillaiindu
I have heard many times that languages with a garbage collector aren’t great for system programming. Today I saw a book titled “Hands-On ...
New
AstonJ
Consider this Erlang code: Rectangle = {rectangle, 20, 10}. {rectangle, Width, Height} = Rectangle. > Width. 20 > Height. 10 When...
New
ariandanim
Hello, i am facing difficult using webpack when to install within phoenix framework 1.5.7 because the webpack is still version 4.x.x inf...
New
Jsdr3398
I just thought of this. Are there any disadvantages when making your server in Assembly (other than having to learn a bunch of stuff :ro...
New
DevotionGeo
What do you people do for reading Erlang docs? Is there something like Ruby’s ri? I installed manual pages for Erlang under /usr/local/...
New
pillaiindu
Cross posting from Elixir Forum. Build it with Phoenix is a nice course by Geoffrey Lessel @geo. But if you start with Phoenix 1.7.2 or ...
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1134 25375 751
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New