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
Another BEAM language… The Hamler Programming Language Hamler is a strongly-typed language with compile-time typechecking and built-in...
New
PragmaticBookshelf
Get ready for 30 teasers that will hone your Python skills and challenge your brain.. Miki Tebeka @tebeka edited by Margaret Eldridg...
New
bot
Kotlin v1.4.0 has been released. Link: Release Kotlin 1.4.0 · JetBrains/kotlin · GitHub
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
CinderellaMan
Create a cryptocurrency trading bot in Elixir (YouTube videos, ebook pay what you want) <span class="hashtag-icon-placeholder"></span>eli...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
Jsdr3398
I really need developers to help create my messaging platform but I’m not sure how much they want etc. I’ve never hired anyone before :s...
New
mafinar
Hello folks! We had a pretty fun thread here around the same time last year - talking about Advent of Code problems. That also happened t...
New
Fl4m3Ph03n1x
Background I am trying to encode a structure into json format using the Jason library. However, this is not working as expected. Code L...
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
Or looking forward to? :nerd_face:
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New