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.

Where Next?

Popular Backend topics Top

AstonJ
Thought this video was interesting: What are your thoughts? Any areas you agree/disagree? Which web-dev tech do you think is worth ado...
New
New
New
New
First poster: bot
This Python script mimics Babbage’s Difference Engine. In Use this Python script to simulate Babbage’s Difference Engine, Python offered...
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
mafinar
We always have fun in this forum around this time of the year, discussing the days’ (or yesterdays’) challenges and talking through solut...
New
KnowledgeIsPower
MongoDB, Cassandra, DynamoDB and etc. Also, do you use VM or container to run it?
New
apoorv-2204
Hi everyone, I’m considering pursuing the Elixir/Erlang certification exam offered by Erlang Solutions and wanted to check in with the c...
New
apoorv-2204
I’m experimenting with Hexagonal / Clean Architecture in Elixir. The classic Behaviour + Impl split works great for mocking and isolating...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New