views:

715

answers:

12

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.

+6  A: 

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.

Yacoder
Wouldn't that be c#?
Aiden Bell
Mono is a framework, not a language. I assume you mean C#.
David Lively
Java is not a "pure" Object Oriented Language... It has basic types outside the class hierarchy.
fortran
@fortran: Should we advice Michas to learn Smalltalk-80 and only then something _useful_?
Yacoder
Technically you can write procedural code with C#/Java (Not sure about Smalltalk) by using static classes/methods.
Finglas
@fortran: C# also has primitive types outside the class hierarchy.
FrustratedWithFormsDesigner
@fortran: Neither is C# a 'pure' Object oriented language..
tommieb75
@fortran: Oh, we already did actually... =)
Yacoder
@FrustratedWithFormsDesigner, tommieb75 - No, all C# types (including int, bool, etc.) derive from System.Object.
mbeckish
@Yacoder it would be also useful if we advise him to eat five pieces of fruit a day, but that's not what he was asking either.
fortran
@FrustratedWithFormsDesigner, tommieb75 - http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29#Common_Type_system_.28CTS.29
fortran
Seconded. If you want a scripting language, learn Ruby, but if you want to learn a practical language for the purpose of learning OOP, Java or C# are it. Smalltalk isn't really widely used anywhere outside of academia, nor is Eiffel; having a broad base of support and question and answer sites, Java/C# seem the clear winner.
Dean J
I used C# for a while. It looks for me about as OO as C++ with QT 4. It does not force to use any particular paradigm. I do not think C# on Linux is mainstream too.
Michas
@Michas: C# language is not tied to any specific platform and it actually kinda forces you to use OOP... At least it did teach me to use OOP =)
Yacoder
@Dean J Smalltalk is used mostly in business - not in academia. That's because Smalltalk for a long time was only affordable for big business, costing many thousands of dollars. Have a look at Cincom Systems or the IBM VisualAge tools, which Eclipse was derived from.Learning Smalltalk was the most eye-opening experience.
Richard Durr
@Richard Durr; hunh. The only two places I've seen/heard of Smalltalk were academia and DoD, although I'd say the academic projects using it had a high probability of being DARPA funded anyways.
Dean J
Richard Durr
+7  A: 

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

Hope this helps, Best regards, Tom.

tommieb75
+14  A: 

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.

Alexander Gessler
Yap, Smalltalk is as strict OO as things can get. As far as I remember, there are no operators and no commands except `self` (equivalent to `this` in other languages) and I think something that points to the "static" class members. Everything else is an object, and really everything else. This goes as far as that code blocks are objects, to which you apply `If` and `ElseIf` methods/messages. You have to rethink when doing arithmetics too because there are no operator precedence rules, as `+` and `*` are methods applied to a numeric object and are thus evaluated in the order of occurence.
herzmeister der welten
@michas Smalltalk will also teach you the MVC pattern, and won't introduce you to the craziness of C++/PHP class systems. You can try ruby, and it will help you learn, (especially the metaprogramming parts), but if you want to know how to do OO-design, the smalltalk libraries are about as good as you'll get.
Tim Snowhite
+3  A: 

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

FrustratedWithFormsDesigner
+17  A: 

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.

Robert Cartaino
+6  A: 

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.

Brandon Bodnár
Good suggestions, but I'd suggest *first* talking to colleagues or friends: it's usually more fun and a better use of (probably limited) time.
NVRAM
Doh. Of course, I forgot about the talking to coworkers bit. That is almost always my first step when doing something new, and it was one of those so obvious things that I forgot it.
Brandon Bodnár
+3  A: 

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

willcodejavaforfood
+6  A: 

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.

KLE
+1  A: 

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.

Tim Schaeffer
+2  A: 

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.

Seth
+2  A: 

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.

dsimcha
A: 

.net is a pure oop language b,coz it satiesfy all of the oops concept .Here we can use only those features which fully fill the oop needs .

saurabh