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条回答
倾城 Initia
2楼-- · 2020-06-01 01:48

For a pure Object orientated language, look at Smalltalk. I am reading this up at the moment.

Hope this helps.

查看更多
贼婆χ
3楼-- · 2020-06-01 01:54

The problem isn't really the language, but the way you use it.

We don't use OO features because they are fancy, but because we gain time (including the long run of course) with them.

May I suggest having your code reviewed by a fellow programmer? And you discuss it? And you can review his? I think that feedback would help you much more than reading, or writing code alone, where you don't have to confront or discuss stuff on concrete code.

查看更多
劳资没心,怎么记你
4楼-- · 2020-06-01 01:54

Read the article Design Principles Behind Smalltalk from Daniel H. H. Ingalls, who implemented Smalltalk. It dictates the true essence of OOP.

查看更多
劳资没心,怎么记你
5楼-- · 2020-06-01 01:55

The problem is not the language. No matter what language you use, you could still code everything in one class, or using class level methods, and end up writing structured code. While a pure OO language will make it harder, I've graded plenty of students who try to shoehorn structured programming into Java and C#.

My suggestion would be to look through some good examples of OO programming, and to look at how OO lends itself to certain design patterns that really show off the power of OO to do the same things structured programming does but with less code that is much more readable to other programmers.

查看更多
Melony?
6楼-- · 2020-06-01 01:55

I think it's better if you just keep doing what you're doing and gradually try to work OO into your coding style in multiparadigm languages. OO is a great way of modeling some things, but it's not the be all and end all of programming. OO is great where you need flexibility. Procedural is a perfectly good paradigm for parts of your code where you want a simple solution to a simple problem and don't need a lot of abstraction.

Learning a "pure" OO language will give you a feel for how to use OO features, but as you won't be forced to choose what paradigm to use for any given piece of code, it won't give you a good feel when to use them. I think a much better way to learn practical OO, as opposed to OO as a religion, is to learn a multiparadigm language like D, Python or Ruby (or stick with C++ and PHP, though the OO features of these languages are very "bolted on"), read up on design patterns to understand the "why" of OO, and gradually try to integrate more OO design into your programs, with the ability to compare the results to what you would have written procedurally in the same language. The OO version will often be better, but not always.

查看更多
家丑人穷心不美
7楼-- · 2020-06-01 01:57

If you want a pure OO language, try Smalltalk. Everything is an object in Smalltalk. This is not the case for Java, where primitive types (int, float) aren't objects by themselves.

If it need't be a 'pure' OO language, Java is a good choice because it's more mainstream.

查看更多
登录 后发表回答