5

Ask HN: How is Python's OOP is superior vs. Lisp CLOS?

 2 years ago
source link: https://news.ycombinator.com/item?id=31808632
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Ask HN: How is Python's OOP is superior vs. Lisp CLOS?

Ask HN: How is Python's OOP is superior vs. Lisp CLOS?
7 points by stealthcat 41 minutes ago | hide | past | favorite | 4 comments
Python classes may be clunky but it is said that Python class system is more flexible than other languages' OOP, even Lisp CLOS.

How does Python class system actually compare to Lisp CLOS?

I've seen arguments for Python class system is the blocker for important code optimizations, AOT or JIT. Are there elaborate explanations on why we get near-machine code speed for compiled SBCL Lisp but we cannot even save the image for PyPy runs? Seems like a problem worse than GIL.

> (...) it is said that Python class system is more flexible than other languages' OOP, even Lisp CLOS.

Who says this? Python does expose a bit of the plumbing of its class/object system - but I can't recall seeing anyone calling it especially powerful or flexible?

I don't think I've seen anyone argue for any object system being strictly more flexible/powerful than CLOS.

Some, like smalltalk, ruby, Dylan or Javascript original prototype based object system might be useful, simpler subsets of CLOS - and might so arguably be "better".

Afaik much of the problem with python has to do with the language being quite dynamic, and also somewhat complex scope handling.

> Are there elaborate explanations on why we get near-machine code speed for compiled SBCL Lisp

But not for CLOS code. CLOS is a subset of Common Lisp and its addresses flexibility, expressiveness, runtime dynamics AND decent speed. But fully dynamic CLOS code (with added meta-level) will not be 'machine level' speed.

See Julia for a more recent approach to multimethods and perfomance. There are also CLOS optimizations in the past and some newer approaches -> but these usually lead to less runtime dynamics.

I've never heard that Python OOP is any good, not to even mention superior to other contemporary systems (like Java). Could you share the source where it is said that "Python class system is more flexible than other languages"?
s.gif
I would guess it's talking about things like __str__, __repr__, __add__, __getitem__, __new__, @staticmethod, @property, @dataclass, and so on. I agree that doesn't necessarily mean "good", but it is flexible out of the box.
s.gif
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search:

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK