TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Please rank programming languages by how well they provide OOP support.

5 pointsby granularalmost 16 years ago
Is Smalltalk the best? Is Perl's Moose better than Python's built-in OO? How does CLOS measure up? Where do C++ and Java land on the scale?

5 comments

jrockwayalmost 16 years ago
CLOS is probably the best, if you ignore the fact that built-in types aren't actually objects. (They can pretend to be, but aren't. You also can't make built-in functions generic, which is quite annoying.)<p>Moose is a close second, and provides a lot of sugar that I really wish I had in CLOS. Roles are pretty much mandatory for proper OO these days, and Moose is the only production system that has them. I also love sugar like lazy_build. The type constraint system is just wonderful.<p>Continuing down, Ruby is a bit better than Python, but both are workable. They give you what you would expect from class-based OO, and you have a basic MOP, too.<p>At the bottom are Java, C++, and PHP. This style of "OO" barely resembles OO. Java is probably the worst here, but C++ makes it very hard to do things right. PHP's design simply makes no sense at all. None have any useful MOPs to speak of, unless you consider "reflection" a metaobject protocol.<p>Smalltalk is a special case; it is obviously pure OO, but the features it provides to the programmer are less numerous than other systems. Smalltalk is what Java should have been, before Java was even conceived.<p>Anyway, my advice is to try them all and decide what you like best. CLOS has features I wish Moose had, and Moose has features I with CLOS had, but they are both quite usable, and allow me to model my program cleanly. It is also easy to steal features for one from the other.<p>The key feature of Moose and CLOS is their extensive MOP, which lets you tweak or completely override nearly every feature of the object system. Instance storage, method calls, attribute behavior, etc., etc., is all implemented in "itself". The end result is that you can extend the object system with the object system that you are extending. This is powerful because it means your extensions can be written in your extensions, making for code that works exactly how you desire. No compromises. (Moose is an object system built on top of Class::MOP, and it is possible to write Moose extensions in Moose. Excellent!)<p>Python and Ruby have a MOP, but it is not as featureful. Compare the availability of meta-object-protocol extensions for CL, like Elephant and Context; and for Perl, like the entire MooseX:: namespace; with extensions available for Ruby and Python. It is just not close<p>Even if you don't care about the MOP for yourself, you will care about how easy it makes writing useful libraries. Most of the MooseX:: modules you will find compose and work perfectly with other MooseX:: modules. The metaobject protocol makes sure everything stays compatible.<p>Personally, when I start using object systems other than Moose and CLOS, the implementation details get in the way of writing good code. I avoid them when possible. (If you haven't used Moose or CLOS, please don't reply and say, "oh, Java is fine, you're using it wrong". You don't know enough to make that argument.)
评论 #689271 未加载
SwellJoealmost 16 years ago
<i>Is Smalltalk the best?</i><p>Define "best".<p><i>Is Perl's Moose better than Python's built-in OO?</i><p>It is more complete. Better? Maybe, maybe not. It's very nice, though.<p><i>How does CLOS measure up?</i><p>Measure up to what? Other LISP object systems, or Smalltalk, and Moose, and Python?<p><i>Where do C++ and Java land on the scale?</i><p>On a scale of 1 to Verbose, they're pretty far up the scale.
评论 #688010 未加载
评论 #688116 未加载
asimjalisalmost 16 years ago
What's the goal of this ranking? What are you trying to accomplish?
评论 #688003 未加载
jackdiedalmost 16 years ago
emacs or vim? You aren't asking a technical question, you are asking a religious question.
评论 #687968 未加载
gaiusalmost 16 years ago
<a href="http://www.jvoegele.com/software/langcomp.html" rel="nofollow">http://www.jvoegele.com/software/langcomp.html</a>
评论 #690018 未加载
评论 #688902 未加载