Some of the most popular OO programming languages and their features
C — inheritance can be had only with severe alterations to the language — which is just what C++, Objective C and some others are.
MS PowerScript, MS Visual Basic: all .NET-based MS languages are "object-aware" — so they can use objects created elsewhere. But in these languages there is no syntax to define classes, so they aren't object-oriented. (Note this is a point often missed.)
FORTRAN — I don't know about the very latest, but as of 10 years ago, the latest versions were incapable of OO.
Most languages have facilities for specifying what members of a class are accessible from other parts of the code, and what is not. In Java and C++, this is accomplished by keywords
public, private, protected
The syntax for these keywords depends on the language, but the idea is similar.
Members marked public
are for consumption by any code using the
class, and form the "public interface" of the class.
Members marked private
are for use only by code of the class
itself. Members marked protected
may be used by code of the class itself, and by code of subclasses of the class.
(Java also adds another level — "package" level.)
In Python, there is no absolute protection from accessing anything from anywhere. Instead, the names of private members are just scrambled, to prevent their accidentally being accessed.
Features: these are only tangentially related to OO programming.
All of these but C++ have exceptions and garbage collection. Exceptions are a way to deal with serious errors in code, where it makes no sense to go further. They to pop out of low-level code where the most is known about what went wrong, directly to higher level code where more is known about the situation and what to do about it. Properly used, this allows for much better problem reporting, and much more stable code.
However, exceptions would be a bad idea if the programmer has to clean up memory after creating it... such hopping would leave a memory allocated, resulting in a "memory leak". So: languages with exceptions also have "garbage collection", by which the system keeps track of what memory is being used, and periodically disposes of any memory that is no longer referred to.
So Java, Python, C# all have exceptions and garbage collection, and C++ has neither. (There are libraries for adding them to C++ — it isn't natural, and nearly as foolproof or convenient as in languages built for them.)
These things are both very powerful tools, very easy to get used to.
(or static vs. dynamic types — depending on point of view). In C++. Java, and C#, classes are defined in the code, and that's that... When the code is run, an object of a given class has the properties it got from its class structure. This is a very good thing for code robustness — you know what you're getting, when you have an object of a given class.
Python is loosely typed: although an object initially gets properties from its class, properties can be added or deleted on the fly. This is kind of cool for modeling real-world situations where things acquire and lose properties, but for program robustness, it's a bit of a loss. To compensate, one must "program to an interface", asking each object if it has a certain property, before trying to use that property, or else rely on trust. Objective C is also loosely typed.
The ability for code at run-time to base logic on the properties and behaviors of objects, to ask an object: "Do you have this method?". C++ lacks this, in Java it is provided as a standard package, in Python it's just the normal way one codes. This is the flip-side of the fact that in C++ the properties can't be changed, in Java new classes can be assembled on the fly, and in Python properties of any object are changed at any time.
All of these languages possess a further means of making sure that symbol names from one area of code don't conflict with those from another. Among other things, this makes it easy to use nice short names meaningful only within their own namespace.
A similar mechanism, a "package", is more than just a namespace, having also to do with making services available, rather like loading libraries in C.
So C++ has namespaces, but libraries are made available as in C, by means of header files and linking, compile-time and run-time. (This business is one of the weaknesses C++ inherits from C: it is not present in any of these other languages.)
In Java, packages have a strong meaning, both as a namespace and a set of facilities to be loaded, and it is also possible to specify that class members can only be accessed by code of the same package.
Can one class inherit from two parent classes? Good Question.
In C++ and Python, the answer is "Yes, but be careful". In Java the answer is just "No". A separate mechanism, "interfaces" provides most of the capability.
C++ has a very interesting capability of compile-time type manipulation, a separate programming environment concerned primarily with types, called "templates". It mostly replaces C's text based preprocessor "macro" functionality, and introduces a completely new ideas of programming, and and very wild idea — metaprogramming.
The primary capability of templates in modern Java is take by "generics" (which are slick but not nearly as much fun).
Such things are just beside the point in Python.
C++, like C, is compiled to direct machine code for a particular hardware architecture, and programs written in it are said to run "on the metal". This has some advantages for those who need them. Java, C#, and Python each run in a virtual machines.
Running "on the metal" gives direct access to hardware and services that may not be available in a virtual machine. The programmer has more direct control in a language that refers to the "metal".
One advantage that running "on the metal" does not have: speed. It is a common misconception that C++ is faster. It is not. In fact, in some situations, simple Java code may outperform C++ on the same hardware. It's a complicated question, whose uninformed answers outnumber informed ones.
One advantage of a virtual machine is that it can be selectively isolated from the real "host" hardware, so that it can't do any damage to the host system or its data. For applications that run across the Internet, whose users could be anybody, this is a very strong advantage.
Another advantage of virtual machines is that they can be made to run on any hardware, so the same program runs, without compiling, in the virtual machine on very different host hardware.
Python is a scripting language: one runs the code directly rather than compiling it. This has several consequences. First, it saves a step between writing code and running it — easy to get used to. It also means that encapsulation in Python is incomplete and hard to control — because the whole program is just code for all the world to see. And it also implies the loose typing of Python.
As code is actually interpreted from text each time it is run, there is also a natural performance hit in running interpreted code. But be aware: these performance issues are complicated, and many people spout facile judgments that are hogwash in practice. This is really not a strong reason not to write in an interpreted language.
Again, C and C++ compile code directly to machine instructions. In some sense, and in some cases, this should result in the fastest performance. Sometimes it indeed does. In the real world, often the opposite happens, for complex reasons (often having little to do with hardware or software).
A common misconception runs that compiled Java and C# code runs slowly, the reason given being that it is said to be "intepreted" when it is loaded to be run. This process is completely different from what happens in scripting languages however, and often results in code that runs faster than code compiled for a specific architecture.
In any case, speed concerns are never a strong reason to pick one language over another. (Yes, that means you!)
C++: pointers, references, constness
Java: primitive vs Object contained classes