Java Python

Can we compare OOP of Python and Java2 min read

It’s true that OO programming can result in issue such as heap fragmentation or other non-deterministic platform states, such as performance deteriorations. Indeed, the issue of OO heap use was one reason why C++ took many years to replace C in embedded development projects. Back in the 1990s, disks, CPU, and memory were at such a premiums that, at least in the minds of designers, they precluded the use of OO languages (which also precluded potential productivity gain from using these emerging languages).

I think it’s still fair to say that a Python programmer may avoid OO features unless no other option exists. In this article, I compare Python and Java to show how they stack up against each other in terms od design. I hope this will allow for an objective assessments.

The Student class in the code has three data members: name, age, and major subject.

Listing 2—A Java student class.

The Java code in Listing 2 is very similar to the Python codes in Listing 1. Notice that the use of OO can produce quite readable codes in either language. Listing 1 is not likely to baffle a Java programmer, even without a background in Python. Likewise, a Python programmer well versed in the Python’s OO features would easily understand the Java code in Listing 2.

Nowadays, OO languages are used in embedded platform pretty much as a matter of course. However, there is still some resistance to using the OO features in languages such as Python and PHP. The reasons for this resistance might have more to do with programmer preferences than with reality!

Take your time to comment on this article.

Leave a Comment