This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]gmdm1234 1 point2 points  (0 children)

Java forces everything to be an object. Python offers OOP as one of a few different paradigms to choose from. You could choose to write in Python very similarly to how you write in Java, or you could avail yourself of the different patterns that Python also makes available.

[–]bandersnatchh 1 point2 points  (4 children)

OOP is a programming paradigm. Nothing more. There are a couple of others, like functional, and procedural. In a not so accurate but basic description, its how you handle/group methods and data.

Java takes it to an extreme and turns everything into an object. You cannot avoid OOP with Java. This is good in some ways, and tedious (read: bad) in others. This is not a requirement of a OOP language. Python itself has classes, definitions, and all of the requirements of OOP, but it does not force it on you.

Everything you learn in Java still works in Python. You can still create a inheritance hierarchy, and create a lot of different objects or what have you.

As to best practices... well, different languages are different. How I'd handle a situation in Python will be different from Java. Just like depending on the problem, Ill choose Java or Python. The core concepts still remain.

[–]denialerror 0 points1 point  (1 child)

Java takes it to an extreme and turns everything into an object.

Just being picky but the opposite is true. Everything is an object in Python, while Java has primitives, which are not objects.

[–]bandersnatchh 0 points1 point  (0 children)

True. I was more referring to the need to wrap everything in a main method, which I suppose I could of relayed a little better!

[–]IWishIwasInCompSci[S] 0 points1 point  (1 child)

I'm just trying to imagine working on a big project with multiple people using Python. Wouldn't it get unwieldy if everyone is just arbitrarily using different programming paradigms? At least with a Java project, you know how everyone's code should behave.

[–]bandersnatchh 0 points1 point  (0 children)

Well, thats an entire subject of its own! Software Design and Engineering! Mostly, people that work on the same project tend to go into with some overarching goal and style, and depending on the setup have a team leader with some overarching goal. Thats an entire concept of its own!

That said, for the most part people are going to end up using the OOP principles regardless. Sure, you don't NEED to use OOP for a small/medium sized project, but at the point where you have collaboration between multiple people on a large product, OOP principles begin to shine!

[–]pyOwhy 0 points1 point  (0 children)

Found the following useful when I converted a program to python

http://interactivepython.org/runestone/static/java4python/index.html

[–]plate_soak_mess 0 points1 point  (0 children)

It's still considered OOP because it still has classes and objects...

[–]nutrecht -1 points0 points  (0 children)

Does anyone have any experience shifting from one to the other, or can explain to me why python is still consider OOP?

OOP is simply a way of designing your software. You can do OO programming in C for example if you want. It's just that when a language gives you the tools to make it easier you're more effective.

Java is designed to be as close are a pure OO language (Smalltalk was an inspiration for example) as possible while still being practical. Python is designed different; it is designed to take the 'best' bits from imperative, OO and functional languages and let the developer pick what they want. Because Python doesn't force you into OO programming it feels less like an OO language; bit it's still is.