DEV Community

Discussion on: The two universes of programming! OOP and FP!

Collapse
 
sjf3 profile image
Sam Fleeman

You should look at golang. It's a different kind of OOP. No classes. You get class like behavior from having struct or struct pointer function receivers. No inheritance either. You have struct embedding and implicit interface fulfilment to accomplish similar things. Go also has first class functions so while not being optimized for tail recursion you can do some functional things. Look up Dave Cheney's functional options blog post/talk for an example of first class functions providing OOP like data encapsulation. My point is java style OOP is not the only way to OOP and not forcing you into making everything an object is actually less verbose. Sometimes you just need a utility function it's not an object it's not even related to an object. GetTerraformPluginDir( ) for example. It's different on windows or mac/Linux. The function has to determine the OS and build a string I don't need a class for this and I might want to reuse this logic across multiple "classes"

Collapse
 
adnanbabakan profile image
Adnan Babakan (he/him)

Hi
Thanks for your comment
Yes, I know there are other approaches to OOP. And I've also written an article about Go which you can check it out here: