Live data from Hacker News

What's wrong with Object-Oriented Programming and Functional Programming

yinwang0.wordpress.com

111–120 of 145 posts

Re: What's wrong with Object-Oriented Programming and Functional Programming

#111

Earlier quoted context omitted.

> the way it manages side effects is that it does so through lazy evaluation This is actually not true. Lazy evaluation forced Haskell to stay pure, but it is purity that provides the tools for constraining effects. You could have a strict Haskell-like language that manages effects in the same way, indeed such languages exist.

> You could have a strict Haskell-like language that manages effects in the same way, indeed such languages exist. I'm unaware of any strict purely functional language with monads. Could you give an example? Thanks!

Disciple[1], and I believe "Mu" Haskell ( the Standard Chartered dialect ) though I don't know for sure because it's not open source.

[1]: http://disciple.ouroborus.net/

Re: What's wrong with Object-Oriented Programming and Functional Programming

#112
post #16

This is a gross mischaracterization of functional programming and basically attacks a straw man--one that's lamentably common when talking about functional programming. I'm going to repost a comment I wrote on the blog. It's long and really needs editing, but I hope it gets my thoughts across. I think the part about OOP is also misguided, but it's so obviously tacked on to a rant about functional programming that I j…

I think the point of the argument about functional programming is that you can't defend a stance of absolute rejection of all things non-functional, because that kind of world could not exist. Similarly, an all-object world does not make sense, either.

His other point about OOP, though, that it doesn't have first-class functions -- that's equivalent to complaining that it isn't functional enough, which is not supposed to be the point of OOP, anyway. There's a lot you could criticize about OOP, but he doesn't make that strong of a case here. He's sort of treating it as a mirror image of fp, but it came from a different world with different values and it's not on the same footing.

Re: What's wrong with Object-Oriented Programming and Functional Programming

#113

Sign. Yet another discussion full of trolling pros and cons of FP vs. OO Guys, listen to Simon Peyton Jones himself: "Haskell is useless". He's discussing stuff with Erik Meijer in this video: http://www.youtube.com/watch?v=iSmkqocn0oQ

His comment was of course tongue in cheek. He wouldn't spend 25 years of his life working on it if he thought it was useless.

Re: What's wrong with Object-Oriented Programming and Functional Programming

#114
post #54
post #22

This is a low quality article from someone who, given his qualifications, should know better. The criticisms of functional programming languages range from trivially true (you can't be purely functional and have side effects) to incorrect (it is certainly not difficult to create a circular data structure in Haskell - it's easy given laziness). The criticism of OOP is verging on nonsensical. Of course functions can be…

> This is a low quality article from someone who, given his qualifications, should know better. It really depends which audience this article is targetting (Do you believe that S. Peyton Jones speaks in monads to his mother?). If this article was written in response of a talk between undergraduates in a TA session, it is perfectly acceptable, and even provides links to advanced material for the curious. > A general d…

> It really depends which audience this article is targetting...

I disagree. Low quality articles like this are part of the reason why many undergrads are full of strongly held opinions about things they don't know much about. They think you can dismiss a huge paradigm with a glib one-liner: "functions are not objects".

> Yes, but why have that definition, if you already have functions as builtin types?

Because we can't talk about objects without having a definition of what they are? I have no idea what point you're trying to make here. I'm just trying to be clear about my terminology.

> Careful, the wording is a bit lacking here imho: you join two different ideas and make it seem like the second one validates the first, while it's not the case.

Think about it a little bit and you'll see why they are actually very related. His statement about Java is meant to imply that proper higher order functions and OOP are in opposition in some way (at least I assume that's his point, it's still not clear to me because that is obviously incorrect). I am saying that proper higher order functions alone are enough for a very pure form of OOP, so there is clearly no opposition.

> That shows you probably don't follow much the field. Anyway, this article doesn't fit your standard (see first point), ergo this man's whole work doesn't, ergo the whole field doesn't? That twice too much stretching from someone who isn't very careful in his own argumentation.

I'm going to ignore the digs at me and elaborate on what I meant. The author wrote an article about programming languages that was full of elementary errors, both in logic and in technical details. If he can't make a simple argument correctly, how am I supposed to have faith that his research isn't similarly full of errors? It's easy to disguise sloppy thinking in technical writing.

Re: What's wrong with Object-Oriented Programming and Functional Programming

#115
post #55

Earlier quoted context omitted.

http://karma-engineering.com/lab/wiki/Tutorial10

Genuinely wondering: does this provide type safety?

No, that would happily evaluate "(sequence_ ((display 'a) nothing))".

Re: What's wrong with Object-Oriented Programming and Functional Programming

#116

Reminds me of this paper; "The Interactive Nature of Computing: Refuting the Strong Church-Turing Thesis" -- http://cs.brown.edu/people/pw/strong-cct.pdf "The theoretical nature of computing is currently based on what we call the mathematical worldview. We discuss this worldview next, contrasting it with the interactive worldview."

The paper's author should be slapped by the any CS book contains (Theorem: IP=PSPACE)

Re: What's wrong with Object-Oriented Programming and Functional Programming

#117
post #19

Earlier quoted context omitted.

Indeed; I'm used to writing systems software, so user interaction tends to elude me :). That being said, I would dare say that the business layer is the one which would benefit the most from a FP perspective. I can think of dozens of bugs in my code that originated in my inability to correctly keep track of what was otherwise needlessly exposed state. Being many layers closer to the silicon, I don't actually use any…

Indeed, many languages would benefit simply from having modifiers that reverse the typical use of "const". Make everything immutable / side-effect-free by default, and add a "mother may I" keyword that allows mutation / side-effects without giving a compile error. Hopefully, programmers would learn to avoid writing code that requires the "stomps-all-over-shit" keyword except when they really did need it. (assuming ta…

One of D's improvements upon C/C++ is its ability to enforce "deep const-ness".

Re: What's wrong with Object-Oriented Programming and Functional Programming

#118
post #43
post #20

Earlier quoted context omitted.

> But isn't the main point of the article that OOP just doesn't always fit the problem domain, that sometimes you want to model something in a way where forcing it into objects (nouns and verbs) only adds complexity without benefits? Perhaps that's the point of the article, but the fact that a programmer might want to use a paradigm in an unfit manner is arguably not a problem of the paradigm . OOP is fairly foreign…

> not a problem of the paradigm Correct. The main problem I see with OOP is that some people advocate it as the only correct way to write maintainable code, which, of course is completely wrong. In fact, OOP doesn't translate well to some problems. There are also problems where FP doesn't work as nicely as other paradigms. In short, there is no silver bullet and advocates of any paradigm should be more open about tha…

> Correct. The main problem I see with OOP is that some people advocate it as the only correct way to write maintainable code, which, of course is completely wrong.

Yes, my opinion is similar. There are problems that naturally lend themselves to being modeled using objects, and others which have to be beaten into submission. Not having to beat them into submission with half-witted OOP implementations, like C++, does help, but it is not always sufficient to take away the sensation of "unnaturalness", if you don't mind the invented word.

Re: What's wrong with Object-Oriented Programming and Functional Programming

#119
post #5

This article is remarkably low on arguments , despite being so long. Just a few of its gems: > OOP is wrong because of its definition of an “object”, and its attempt of trying to fit everything into it. When that goes to the extreme, you arrive at the notion “everything is an object“. But this notion is wrong, because: > There exists things that are not objects. Functions are not objects. This has two problems: 1. It…

> Smalltalk functions are first-class objects What about the functions inside those objects? And functions inside that function object. Like a chicken and egg problem. I neither agree nor disagree with him, what he's trying to say is that there is a difference between methods and functions . Methods (1) are functions (2) wrapped inside an object. (1) and (2) are different. He's just trying to say that "everything is…

It's been a long time since I had anything to do with Smalltalk, so I may be shitting you -- unfortunately, I'm also on the run and cannot properly check the following statement, so please take this with a grain of salt -- Smalltalk does not have named functions that aren't methods. In other words, if something takes arguments, returns things and has a name, it's always a method of an object (i.e. it's a message to which an object responds). In other words, while (in abstract terms), a method (1) is different from a function (2), Smalltalk only has (1). You can't define a "function" outside the scope of an object, like in C++. You could define a class that only has a long bunch of static methods, not modeling any kind of logical abstraction, but it's considered bad style.

Re: What's wrong with Object-Oriented Programming and Functional Programming

#120

Just http://www.scala-lang.org/ and everybody's happy :)

I'm putting a lot of time and effort into mastering Scala, because I think that it's the future, paradigmatically speaking. But I think the muddled syntax and the complexity of the language may doom it. But I think it's the vanguard of the revolution. I was really psyched about Pyret ( http://www.pyret.org/ ) when I read about it here over the weekend, and I think it hopefully represents the future of how we program.

Come to #Scala and #Scalaz on Freenode IRC, it's a great learning resource. (REPL in the chat so you can get realtime help with code).
Post reply on HN