Discussion

Ask HN: OOP in Functional Programming Language

I find that my ruby code more and more resembles functional programming:

Instance variables are always set in the constructor, and almost never mutated.

The thing I like about OOP is really just that the methods of an object don't have to take a bunch of parameters, but that it instead can rely on the instance variables. I guess in functional programming, this would be something like having a (constructor) function that returns a hash of methods that have been given what in OOP would be instance variables as their first parameters, and then only need non-instance variables through currying. My question is, is there a functional programming language that not only supports, but `encourages` this OOP style programming?

3 points mollerhoj 4 years ago 9 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton