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

> Why do closures and objects arise in such a natural fashion

My reasoning is we need a partitioned stateful function which is impossible to achieve and the alternative are worse:

- partition global state with your own object id

- passing all state as arguments




Other ways to manage state as well:

- Managing state through a monad or effect system

- Managing state through coroutines / continuations

- Managing state through dynamic scoping (poor man's effect system)

- Associating implicitly mutating functions with types without having full objects (Rust)

Some of these are pretty powerful, especially effects and continuations. I think the reason we don't see more of them is because we haven't figured out a wholly ergonomic way to fit them into a language yet.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: