Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Actually there is better and worse.

Verbs/functions are easier to compose and recompose; they're easier to reason about (there is no "state" in verbs; verbs are declarative.)

Nouns (assume: with behavior; not just data -- otherwise you are in FP-land again) are harder to compose and recompose, harder to reason about (state transitions).

Consider calculating age. Assume general FP and general OOP ways of solving the problem. Then:

ageOf(p)... ...ageOf() can potentially be applied (or modified to apply) to different value types. ...self-evidently does not mutate p or cause a state transition (assuming FP).

p.ageOf() ...can only be applied to value types/classes that support that operation. ...may or may not mutate p/cause a state transition of p.

One is much easier to reason about and reapply when the world changes.



For a start when we're talking about closures versus objects, we're not necessarily talking about true functional programming. Closures can have and manipulate internal state. Pretending that they don't ignores real world usage where they do.

However let's limit ourselves to functional techniques. Whenever someone talks about something in the very abstract and says "easier to reason about" I mentally insert "for you". Certainly it isn't true for everyone or every situation.

A basic principle in programming is that starting at the hardware level we build abstraction layers that let us think about things in higher level ways, hopefully ultimately in a way that matches the terms that the end application uses. End applications have concepts like account balances, user status, and other such stateful pieces of information. If you're going to have the state, workaround that you pretend you don't, you will cause confusion. Pick your favorite 5 Monad tutorials for proof.

Consider as an example the use case, "Provide a form to let us mark spammers, and block them from our site." For all the theoretical advantages of avoiding state, this is going to be easier to model in a system where users have a piece of state known as is_spammer.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: