“Closures are poor man's objects and vice versa” - What does this mean?

后端 未结 6 964
囚心锁ツ
囚心锁ツ 2020-11-28 02:48

Closures are poor man\'s objects and vice versa.

I have seen this statement at many places on the web (including SO) but I don\'t quite

6条回答
  •  旧巷少年郎
    2020-11-28 02:55

    EDITED: The title of the question does not include "vice versa" so I'll try not to assume the asker's intent.

    The two common camps are functional vs imperative languages. Both are tools that can accomplish similar tasks in different ways with different sets of concerns.

    Closures are poor man's objects.

    Objects are poor man's closures.

    Individually, each statement usually means the author has a some bias, one way or another, usually rooted in their comfort with one language or class of language vs discomfort with another. If not bias, they may be constrained with one environment or the other. The authors I read that say this sort of thing are usually the zealot, purist or language religious types. I avoid the language religious types if possible.

    Closures are poor man's objects. Objects are poor man's closures.

    The author of that is a "pragmatist" and also pretty clever. It means the author appreciates both points of view and appreciates they are conceptually one and the same. This is my sort of fellow.

提交回复
热议问题