Live data from Hacker News

Ask HN: can you summarize OO for me in 64 words or less?

news.ycombinator.com

11–20 of 76 posts

Re: Ask HN: can you summarize OO for me in 64 words or less?

#11
Programming is about state (variables, constants, data), and behaviour (algorithms).

State and behaviour are deeply intertwingled, and object orientation seeks to make programming easier by acknowledging that fact.

Put simply: an object is something with state and behaviour, and an object-oriented programming system is one that makes working with objects easy.

Two ways they do this are information hiding (so you can consider an object a black box and not care about its inner workings) and inheritance (when two objects are similar, you only need to specify the differences between them).

Re: Ask HN: can you summarize OO for me in 64 words or less?

#13
Model behavior and attributes of program on real-world objects. If you are programming a house, a door object would have open() and close() member methods you call on a particular Door object. Easier to work on collaborative projects by virtue of clear interface.

Re: Ask HN: can you summarize OO for me in 64 words or less?

#14

Programming is about state (variables, constants, data), and behaviour (algorithms). State and behaviour are deeply intertwingled, and object orientation seeks to make programming easier by acknowledging that fact. Put simply: an object is something with state and behaviour, and an object-oriented programming system is one that makes working with objects easy. Two ways they do this are information hiding (so you can…

[In a similar vein, I was about to say:]

Object-orientation is fundamentally just a way of organising programs.

In most non-OO programming, you've got a bunch of data, and a bunch of procedures that can operate on the data. The two are defined and considered somewhat separately, though they must fit together.

In OOP, a kind of datum and the operations on it are instead designed, defined and used together, as essentially linked.

Re: Ask HN: can you summarize OO for me in 64 words or less?

#15
"In all other languages we've considered [Fortran, Algol60, Lisp, APL, Cobol, Pascal], a program consists of passive data-objects on the one hand and the executable program that manipulates these passive objects on the other. Object-oriented programs replace this bipartite structure with a homogeneous one: they consist of a set of data systems, each of which is capable of operating on itself." - David Gelernter and Suresh J Jag (61 words)

Re: Ask HN: can you summarize OO for me in 64 words or less?

#16
post #2

(I'm not trying to sound condescending, so bear with me) How else would you write software with modular and re-usable components?

I've got 8 minutes til I need to catch the bus.

The answer to your question hinges mainly on how you define components. In the Erlang language for example: It is completely functional but threads actually become somewhat stateful and ultimately end up recreating some similar scenarios for OOP programmers. On top of that, functions themselves showcase an even higher amount of reusability at times especially in functional languages because of the prevalence of lists of things and tuples. This prevents an over abundance of duplicate implementations of the same thing that, even though their signatures are identical (or nearly so) can't interoperate because they haven't been specified as exactly the same. So language wide consistency is a big plus for some functional languages.

Having said that no one tool is a golden hammer. OOP and Functional programming are just tools and there are others out there. Some not even based on Von Neumann architectures that are even more flexible than the ones we, Von Neumann proggies, are (think data flow architectures for example).

Re: Ask HN: can you summarize OO for me in 64 words or less?

#17
post #6

What language are you using? edit: I assumed that the vast majority of languages typically used in web development incorporated some OO features. I'm interested in what is familiar to you; perhaps that will help people describe something that means something to you. Your question is sort of odd.

I've drifted from language to language but most of time is either spent writing bash scripts, PHP, C (only if don't understand how a bash cmd), HTML, Javascript, and currently visual basic, many of you will moan at this, but I feel as if I get more out of knowing what OO is from VB than any of the other lanugages. This class wasn't by choice, it's pre-req for the school I'm in.

Re: Ask HN: can you summarize OO for me in 64 words or less?

#18
OO operates on ownership. The String's length, the String's text. Create a new String, and you expect it to look like a String and talk like a String.

If there isn't an inherent ownership and hierarchy of data and data properties, OO isn't at all necessary. When the structure is well-defined though, which is in many cases, it is the most intuitive abstraction.

Re: Ask HN: can you summarize OO for me in 64 words or less?

#19
post #8
post #3

Earlier quoted context omitted.

modular and re-usable components is not really OO specific tho.

That didn't answer my question though. You can technically convert any programming paradigm to anything that is touring-complete. Just because something is designed with OO methods doesn't mean that it can not be designed any other way. Original C++ compilers simply converted C++ code to C. But seriously, if you had to write software that abstracts complexity (good), has modular components (good) and let's you attack…

Research into statically typed functional languages approaches this question, and generates some pretty good insight. It turns out that OO is sort of a religion... just one approach to modularity and abstraction. Languages like ML and Haskell provide these features in a completely non-OO style, and are very expressive and powerful.

If you are curious, look at abstract data types and polymorphism in SML/OCaml and Haskell. Also, look at Haskell's type classes, and look at SML/OCaml's module system.

Here's a paper you can read: http://www.cs.utexas.edu/~wcook/papers/OOPvsADT/CookOOPvsADT...

Re: Ask HN: can you summarize OO for me in 64 words or less?

#20
Complex and confusing problems can be tackled by breaking them into modules, with interfaces between. Objects are one way of doing it.

Each object wraps up a program. The program's global variables become variables of the object. The program's functions become functions of the object. The public functions are the interface of the object (an interface is the part of a module that interacts with other modules, like the surface of an object). So basically, you have the inside of the object, and the outside (surface).

Think of it as support for the modules that you already wanted, that seem to be naturally present in the problem, or in how you naturally want to divide it up and think about it. That is, use OO to support your conception, instead of a priestly template to mold yourself into. Tools are good slaves, poor masters. If you follow your conception, you will make mistakes - but those mistakes will belong to you, and so you will learn from them.

Using objects for modularity does not work well for every case (e.g. I think parsing works better in the old-fashioned style).

OO is nothing special. There's no wonderful mysterious secret. It doesn't even have a precise definition that everyone agrees on. It's just a tool. Inheritance and polymorphism are grossly overrated, but presented as a quasi-religious AI solution-to-everything - but are useful in some cases (e.g. great for windows/GUIs). There's also a danger of having overly theoretical modules - the "spaces" you mention. Be problem-driven. What does the problem need?

Post reply on HN