开发者

Looking for a pure object oriented language [closed]

开发者 https://www.devze.com 2022-12-18 02:09 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 7 years ago.

Improve this question

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 instan开发者_开发百科ces. 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.


Object-oriented programming isn't about syntax. It a programming paradigm.

A language can force you to use objects (if everything is an object, for example) but using one of those languages isn't going to "force" you to learn object-oriented programming.

I do not use much of inheritance nor multiple instances

You have to learn when and why you use these techniques (data abstraction, encapsulation, polymorphism, and inheritance) to think in objects. Get a good reference in object-oriented programming and use whatever language (that supports OOP) you are most comfortable with to apply those techniques.


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.


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

Hope this helps.


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.


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).


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.


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.


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


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.


Learn the paradigm and then which language you choose matters less.

Head First Object-Oriented Analysis and Design: A Brain Friendly Guide to OOA&D alt text http://ecx.images-amazon.com/images/I/51eQgNjOOWL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU02_.jpg


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.


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.


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.


Object-oriented programming has very little to do with what language you use and a lot to do with your approach to programming. Object-oriented programming depends on how you plan things and how you structure your code. You could use a language like Java, which forces you to use some object-oriented features, but if just sat down and put all your code in the main() method you have not done any object oriented programming.

My suggestion is not to learn a different language, but to study the paradigm of object-oriented programming itself and the various ways a program is planned and implemented using object-oriented analysis and design. Learn about abstraction, encapsulation, inheritance, and polymorphism to start. Get a good feel for UML. Then study design patterns that are used in object-oriented programming.

Make sure you're doing all these things before you code. The biggest shock you may face is how much time you have to think before you code anything. Spending the time to plan your program in an object-oriented way is very difficult for people accustomed to just sitting down and coding in a process-oriented way. If you take the time to plan what you're going to do in advance (of course don't go too crazy since programming is about small iterations), you'll find you can create much better code the first time, for increasingly complex tasks.


I see a lot of suggestions here to learn languages that are frankly not marketable. As a young person you may not care and have this zest for learning (I know b/c I've been there), but down the road when it comes time to put food on the table you will regret screwing around with these languages. Ada is honestly my favorite language and I'd love to program in it for a career, but she don't pay the bills so I had to break it off with her. :(

0

精彩评论

暂无评论...
验证码 换一张
取 消