this post was submitted on 21 Mar 2024
294 points (94.8% liked)

Programmer Humor

19821 readers
903 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 9 months ago (2 children)

I think using both is normal. Closures and objects are duals of each other. Do whatever is understandable and maintainable, neither paradigm is magic.

[–] [email protected] 4 points 9 months ago

that's a nice way to look at it. thanks!

[–] [email protected] -1 points 9 months ago (1 children)

Is the duality statement meant to be true in a technical sense?

[–] [email protected] 1 points 9 months ago (1 children)

Yeah! For example, if the language allows closures to capture state, they can act like properties on an instance.

[–] [email protected] 1 points 9 months ago (1 children)
[–] [email protected] 1 points 9 months ago

A closure is a function with captured state. An object is state with methods.