Hacker News new | past | comments | ask | show | jobs | submit login

But you are forced to use classes and instantiate objects, even if the resulting program you write is procedural. Languages like, say, Python, don't force you to ever declare a class.



I wouldn't recommend it, but you are only required to declare one class in a java program that contains the static "main" method. If you strictly use primitives and static methods there would be no instantiation needed.

I think the only real difference is that in python your methods would be scoped at the global level. While in a single class java program your methods would be scoped within the class.


Right, but you are required to declare a class. You are required to acknowledge that the object system exists. Python has no such requirement.

Mechanically, what can be accomplished in one language can be accomplished in the other. But that's not what this distinction is about.


The distinction I am making is based on this:

"It lets you easily use objects and OO concepts when they are the best approach, but it does not force you to use them when the particular problem is more functional (or even more procedural for many short, simple scripts.)"

I was disagreeing with the point that OO languages "force" you to use OO concepts. OO concept to me means encapsulation/inheritence/polymorphism. Java in particular does not force you to use any of these OO concepts. You do have to declare one class, but "class" in that sense is purely for scoping. You don't have to instantiate it or acknowledge its object-ness.


And my point is that while you are not forced to design an OO program, you are forced to use OO mechanics. Considering that other multiparadigm languages don't force this (C++, Python, Ruby, Perl, Objective C, Lisp), I think it's an important distinction.


Perhaps "OO Structure" or "OO Syntax" would have been a better choice of words. You can abuse java by declaring your class with a static main and then write things procedurally within that, but you have to have that class and its OO Structure.

In Python, that is not needed. Objects are there when they make sense(such as most gui design), but not required, even in structure or syntax, when they do not make sense.


Precisely, and even if you do write it in a procedural fashion from that point forward you have the clutter of the OO code around it.

(It is of course not clutter if you are actually writing in an OO fashion where it makes sense and is very useful.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: