Hacker News new | past | comments | ask | show | jobs | submit login

Can't the SOLID principles apply equally well to functional programming by just replacing "class" with function, object, or type (depending on the principle)?

Single Responsibility is achieved by composition

Open/Closed is probably the one that fits least with FP, but it seems like FP achieves the same result by replacing both extension and modification with composition.

Liskov Substitution can be replaced by a subtyping or duck typing.

Interface Segregation seems like its more about design than programming. However, to the degree that it applies to programming, composition seems like it actually better meets this principle than inheritance.

In terms of Dependency Inversion: If anything, it seems like one of the biggest problems with FP is that it makes it easy to take this principle too far by making things too abstract (e.g. the category theory aspects of languages like Haskel seem like they could easily be abused).

I'm not super experienced with OO so am I maybe misinterpreting these principles?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: