Live data from Hacker News

OOP Isn't a Fundamental Particle of Computing

prog21.dadgum.com

91–100 of 163 posts

Re: OOP Isn't a Fundamental Particle of Computing

#91

Earlier quoted context omitted.

Your competence as a programmer was not questioned, Michael, and was not even remotely a consideration. Have a beautiful day!

Sorry if I seemed aggressive and snarky. OOP gets my blood boiling. The disgraceful state of most software architecture is a hot topic for me, having seen a couple of companies fail on account of code quality issues.

That's not OOP, its the designers and coders. The "problem" with being the mainstream programming paradigm is that the bell curve of talent is fully stocked from high to low ends.

The marketplace of managers looking for: a) cheap labor b) well-understood technology c) ability to fallback to expert knowledge

grew up with object-oriented paradigms.

Since OOP frameworks removed many low-level coding tasks, the cost of entrance into the labor market allowed the labor pool to be flooded with developers, it helped that demand was so high and investors so hungry that proof-of-concepts often became products.

What came out of all this is that OOP matured, but OOA and OOD didn't keep pace as market demanded disciplines. What you see today is many OO systems that were not analyzed or designed by architects who were good analysts and designers, but who understood OOP and had access to a pattern-book.

But, taking a page from category theory, we could abstract OO from OOP, OOA and OOD, and should be able to easily see that the same could eventually apply to FP, FA and FD should the bell-curve of talent fill out due to market demand.

Re: OOP Isn't a Fundamental Particle of Computing

#92

One of the reasons discussions of OOP leave me feeling dissatisfied is that OOP has a "blind men and the elephant" problem. One feels the tail and says, "this Creature implements Rope". Another feels a leg and says, "this Creature implements Tree". A third feels the side and says, "this Creature implements Wall". We end up discussing dramatically different things. My big issue with OOP is that it injects unnecessary…

I usually put it like this. Instead of having 23 poorly-understood and often badly implemented design patterns, functional programming has two design patterns: Noun and Verb. Nouns are immutable data: from integers to record types to OCaml's unions to Scala's tree-based Map and Set. (Occasionally Nouns have to be mutable, which means they have attached Verbs. I'm glossing over that for now.) Then I would have to ask…

The problem with the mutability debate is that most examples show two programs, one mutable and one immutable, on the scale of about 20 lines of code. At the small scale, it's a toss-up which is better. Often the mutable solution's more intuitive for most programmers, and sometimes just flat-out superior: more clear, easier to understand. Mutable state isn't evil. It's necessary in the real world. It's just that stateful actions don't compose well, especially when you involve concurrency or Big Code problems. Good programmers learn that they need to manage (not eliminate) mutable state. That's what FP is about.

So the aesthetic dominance that FP advocates hope to establish with their 20-line A/B depictions doesn't come through, because the truth is that the problems with mutable state very rarely show up (except in contrived, over-complex examples) at 20 LoC. At 20 LoC, the snippet you'll like better is going to be the one you're most familiar with. The real differences show up at 2000 LoC, which can't be put in a PowerPoint.

Immutable programming is somewhat less prone (but not immune) to complexity creep. For example, you see 500-line for-loops in corporate software all the time. The conceptual integrity is gone because so many people (who never learned what the others were doing) have added tweaks to it.

The difference between mutable and immutable programming is that making that sort of change to an immutable program also changes the API, unless it's purely a performance tweak (e.g. plus(2, 2) still returns 4, but does it faster). If you add logging to plus in a purely functional world, you change its signature from (Int, Int) => Int to something like (Int, Int) => (Int, String). As you might guess, that's a double-edged sword. Sometimes you want people to be able to add "purely stateful" (i.e. no API changes) effects without changing a signature... but very rarely.

So I think the major upshot of immutable programming is that it makes it impossible to add many varieties of complexity that corporate engineers tend to add silently (in pursuit of a short-term hack) without changing an API and breaking the build. This slows down complexity creep, and that's a good thing.

It's the reduction of that externalized-cost/complexity-creep dynamic that makes FP superior, in my opinion. A 60-line referentially transparent function really isn't less evil than a 60-line method of an object. They're both fucking incomprehensible, in most cases. You're just less likely to see the 60-liner in a mature FP codebase. Also, because functions compose better than stateful actions, it's usually a lot easier to break large functions up long before they get anywhere near 60 lines. (In my opinion, double-digits are "warning" territory and 25+ lines means it should almost always be split, at least into inner functions.)

Re: OOP Isn't a Fundamental Particle of Computing

#93

Earlier quoted context omitted.

I usually put it like this. Instead of having 23 poorly-understood and often badly implemented design patterns, functional programming has two design patterns: Noun and Verb. Nouns are immutable data: from integers to record types to OCaml's unions to Scala's tree-based Map and Set. (Occasionally Nouns have to be mutable, which means they have attached Verbs. I'm glossing over that for now.) Then I would have to ask…

The problem with the mutability debate is that most examples show two programs, one mutable and one immutable, on the scale of about 20 lines of code. At the small scale, it's a toss-up which is better. Often the mutable solution's more intuitive for most programmers, and sometimes just flat-out superior: more clear, easier to understand. Mutable state isn't evil. It's necessary in the real world. It's just that stat…

When you have state...I mean real state, it sure is nice to encapsulate that state in an object rather than in what is basically an unencapsulated monad. OO supports state encapsulation, pure FP basically does not, that is a big deal. Immutable programming sort of side steps the issue, that state is needed at all, that an interactive program can somehow be stateless is ridiculous, even many batch programs require some form of state (even if it is unencapsulated in a monad).

Your 60-line function decomposed into nice small parts using beautiful composable abstractions is an FP pipe dream. Yes, if the problem is well understood, someone has thought about it for a long time and has come up with some beautiful abstraction that works for a narrow set of related problems. Now, as soon as you venture outside of a well-understood/nice abstraction domain, your code is just as bad in FP, if you can figure out how to implement at all.

Re: OOP Isn't a Fundamental Particle of Computing

#94

Earlier quoted context omitted.

> It's strength is that it allows the business rules to be most directly mapped to the code that needs to be written. Absolutely this. Discussions around OOP vs functional always seem to ignore this massive boon to productivity that OOP brings. Being able to create something of a DSL and map your business rules onto basic operations on this DSL is a huge win. The trick is to design your objects and operations such th…

> Being able to create something of a DSL and map your business rules onto basic operations on this DSL is a huge win. Hold on - how is this a concept specific to object-oriented programming? Creating a DSL for your problem domain and solving the problem in the new language is exactly what functional programmers have been doing for decades! E.g. here's a mini-DSL in Haskell for parsing CSVs, built on top of the Parse…

Of course, anything you can create abstractions with you can create a DSL of sorts. But I think most would agree that OOP is the more natural paradigm for this.

Re: OOP Isn't a Fundamental Particle of Computing

#95

Earlier quoted context omitted.

Sorry if I seemed aggressive and snarky. OOP gets my blood boiling. The disgraceful state of most software architecture is a hot topic for me, having seen a couple of companies fail on account of code quality issues.

That's not OOP, its the designers and coders. The "problem" with being the mainstream programming paradigm is that the bell curve of talent is fully stocked from high to low ends. The marketplace of managers looking for: a) cheap labor b) well-understood technology c) ability to fallback to expert knowledge grew up with object-oriented paradigms. Since OOP frameworks removed many low-level coding tasks, the cost of e…

The nice thing about a language like Haskell, then, is that you have to be really smart to use it, reducing the market for low end programmers. Actually, many companies put Haskell (or even Scala) down as a requirement just to filter out the low end programmers, they have no strong intention of actually using those languages.

OO is accessible because it is much more naturalistic than FP, being based on natural metaphors (objects) and natural language concepts (subject verb) that make many computer scientists cringe (was it Dijkstra who was against anthropomorphic metaphors?). FP is much more based on math and logic, conveying certain benefits but requiring a change from the way we are normally wired; I've been in a room full of the best of the FP guys before and I could have sworn I was on a different planet.

FP is a reliable tool in moderation. But when I'm designing a text editor, object thinking is definitely preferable.

Re: OOP Isn't a Fundamental Particle of Computing

#96
post #86

Earlier quoted context omitted.

Python: "Paradigm(s): multi-paradigm: object-oriented, imperative, functional, procedural, reflective" JavaScript: "Paradigm(s): Multi-paradigm: scripting, object-oriented (prototype-based), imperative, functional" Ruby: "Paradigm(s): multi-paradigm: object-oriented, imperative, reflective, functional" From Wikipedia. So, where the faux pas is?

All data types in those languages are objects.

First you said that these languages are 'OO'. Confronted with evidence that, in fact, they are multi-paradigm languages and that includes functional style you changed your argument.

Now you're saying that those languages are not functional, because all the main datastructures in them are implemented as objects. Well, object models of JavaScript, Python and Ruby are vastly different and so I have to infer very wide definition of an object - that of data+methods - because there is nothing more that all three languages agree on in case of objects.

I have to tell you this - this kind of objects is not unique to OOP. The only difference between C, for example, and Python in this respect is that you call "methods" like this:

    list_append(my_list, my_element);
instead of

    my_list.append(my_element) # but note that you can write like this too:
    list.append(my_list, my_element)
My point is that every datastructure is an object. Every datastructure has some data (internal representation) and methods operating on them. LinkedList or HashTable is going to be an object no matter which notation you use to access them.

There is more to OOP than just objects, of course, but that does not matter. You can program in functional style using your language built-in objects without any problem at all. Take a look at PowerShell, for example of something even more exotic: turns out you can program in purely procedular language while using objects from .NET framework. On the other hand, there are bindings to wxWindow for Erlang; turns out you can program in purely (as in 'not supporting other paradigms'!) functional language using objects too.

I don't really know what you're trying to say, but JavaScript, Python and Ruby are perfectly capable of functional programming and can be used as languages supporting functional style. There is really no counterargument for this - or at least the fact that operations on main datastructures of these languages are implemented with syntactic sugar is not one.

Re: OOP Isn't a Fundamental Particle of Computing

#97

One of the reasons discussions of OOP leave me feeling dissatisfied is that OOP has a "blind men and the elephant" problem. One feels the tail and says, "this Creature implements Rope". Another feels a leg and says, "this Creature implements Tree". A third feels the side and says, "this Creature implements Wall". We end up discussing dramatically different things. My big issue with OOP is that it injects unnecessary…

I usually put it like this. Instead of having 23 poorly-understood and often badly implemented design patterns, functional programming has two design patterns: Noun and Verb. Nouns are immutable data: from integers to record types to OCaml's unions to Scala's tree-based Map and Set. (Occasionally Nouns have to be mutable, which means they have attached Verbs. I'm glossing over that for now.) Then I would have to ask…

[deleted]

Re: OOP Isn't a Fundamental Particle of Computing

#98

Earlier quoted context omitted.

> It's strength is that it allows the business rules to be most directly mapped to the code that needs to be written. Absolutely this. Discussions around OOP vs functional always seem to ignore this massive boon to productivity that OOP brings. Being able to create something of a DSL and map your business rules onto basic operations on this DSL is a huge win. The trick is to design your objects and operations such th…

> Being able to create something of a DSL and map your business rules onto basic operations on this DSL is a huge win. Hold on - how is this a concept specific to object-oriented programming? Creating a DSL for your problem domain and solving the problem in the new language is exactly what functional programmers have been doing for decades! E.g. here's a mini-DSL in Haskell for parsing CSVs, built on top of the Parse…

The difference, at least in my eyes, is that OO languages have a convention for the grammar of the DSL.

Re: OOP Isn't a Fundamental Particle of Computing

#99

One of the reasons discussions of OOP leave me feeling dissatisfied is that OOP has a "blind men and the elephant" problem. One feels the tail and says, "this Creature implements Rope". Another feels a leg and says, "this Creature implements Tree". A third feels the side and says, "this Creature implements Wall". We end up discussing dramatically different things. My big issue with OOP is that it injects unnecessary…

[deleted]

Re: OOP Isn't a Fundamental Particle of Computing

#100
post #13

There is nothing theoretical behind OOP its just how we currently abstract and modularize code for human consumption. I know its flame war stuff but I really think marketing from certain languages got everyone into the OOP paradigm as the best way, Its funny sometimes I talked to people who programmed in the 80's and they talk about how OOP didn't really solve anything for them. Its always interesting conversation.

OOP was quite popular in the 80s.
Post reply on HN