Looking for a pure object oriented language [close

2020-06-01 01:24发布

I think object oriented programming is overrated, however I want to learn this paradigm. I have been trying to do this in PHP 5 and C++ with QT 4. Unfortunately, I tend to program in structured way, I do not use much of inheritance nor multiple instances. I think I have to learn a pure object oriented language that force me to use above features.

I think the best option is probably to learn Ruby. Could You confirm or name better alternative?

I work mainly on a x86-64 Linux.

15条回答
老娘就宠你
2楼-- · 2020-06-01 01:39

Try Java or C# on Mono.

Rationale:

  1. I respect Smalltalk, and one should certainly know its concepts to understand OOP better, but learning the language itself is impractical IMHO.

  2. While Java and C# might not be "absolutely pure" OOP-wise (e.g. they have incorporated some of the functional programming approaches), they are inherently OOP-based, they are mainstream (thus have much larger communities) and they are easier to learn than Smalltalk IMHO.

查看更多
欢心
3楼-- · 2020-06-01 01:39

I would suggest to take an Agile like approach and just write the code the way you feel must natural to you. Then try to re-factor it to OO paradigm. I very much recommend Marin Fowler's classic on the subject (refactoring) and then a good delve into Gang-of-four's Design Patterns (very well-known, unmistakable), then perhaps Joshua Kerievsky's "Refactoring to Patterns" and again Fowler's PoEAA , can get you very far indeed in understanding and thinking in OO.

This is in shear contrast with the Up-Front-Deisng like approach of trying to do OO after reading stuff about OO concepts. No need to mention a good theoretical background is well paid when trying the Agile-like approach but the spirit is to refactor yourself into OO instead of pivoting from anything you are now doing to OO.

查看更多
够拽才男人
5楼-- · 2020-06-01 01:43

A lot of people are suggesting Smalltalk, so I'm going to be different and suggest Eiffel. ;)

A good language to learn OO principles on, also has neat stuff like DBC (Design By Contract).

查看更多
啃猪蹄的小仙女
6楼-- · 2020-06-01 01:45

I suggest python. It passes the "everything is an object => pure OO language" criteria mentioned by a few others for choosing Smalltalk. Functions and even the python null value (None) are all objects.

It is more OO than Java (java has int and Integer). And more importantly, it is vastly more popular than Smalltalk, so you're more likely to be able to get help with it.

Python also does polymorphism without inheritance ("duck-typing") and functional programming, both of which are becoming more common in "mainstream" languages.

查看更多
Bombasti
7楼-- · 2020-06-01 01:47

Try the Common Lisp Object System (CLOS). It is not "pure" OOP like Smalltalk but the type hierarchy in lisp is at least complete (which is more than can be said for Java), and most other languages, even OO languages, don't have generic methods, multidispatch, method combinations, esp :before, :after and :around. run-time class objects, or reinitialize-instance, all of which CLOS provides.

查看更多
登录 后发表回答