Live data from Hacker News

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

yinwang0.wordpress.com

91–100 of 145 posts

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

#91
The author states the "extreme" case of OOP is "everything is an object" and the extreme case of FP is "purity."

The problem with this analogy is that everything being an object doesn't by you much. But in Haskell, the type system helps you keep track of what's pure and what's not. So having a type system that keeps track of purity buys you something: lots of pure and extremely easy to reason about code. Non-deterministic (unpure) code is the same difficulty to reason about in any language. Isolating it from pure code just reduces the amount of code which is difficult to reason about.

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

#92
post #89

This person is pursuing a PhD in Computer Science? "If you look deep into them, monads make programs complicated and hard to write, and monad transformers are just ugly hacks." Wow. Just... wow.

Monad transformers are ugly, ugly, ugly (though not really hacks, since they are based on sound mathematics.)

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

#93
post #79
post #17

Earlier quoted context omitted.

FactoryFactoryFactoryClass, most of dependency injection frameworks, anonymous classes, several different one-method interfaces, (such as event handlers/observers), and probably more become unnecessary when you have first-class functions.

I am currently experimenting with Spring JavaBased config (As opposed to XML based) It seems to me that a lot of those factories are created to be able add complex behavior in the XML configuration. I almost want to say that it is XML injection what is causing such complexity.

No no no, I wasn't trying to say that Factory pattern in itself is useless, or dependency injection frameworks, or similar. These are all useful things, time-tested. However, in a language with first-class functions, all these cease to be "obscure patterns that you need a certificate to think of and design" and simply become "just another day of life". For example, you don't need to create a FactoryFactoryFactory class with appropriate functions and the whole framework around it, you simply write a function that takes the appropriate parameters and returns the appropriate object, and pass it around. Similarly, you don't need a complicated Dependency Injection framework, you just pass parameters to a functions and it gives you what you want. It's that simple. Still, occasionally some advanced IoC functionality can be useful, but much less frequently.

To see this in action, try googling "factory pattern in Python". You will find hardly any results.

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

#94
post #29

This is solved long ago, without taking any extremes. In short, a language should be mostly-functional, which means when you really need to overwrite a value you just do it. In well-researched languages, such as Scheme you have set!, in CLs you have setf. All the monadic stuff (remember, that a monad is nothing but an ADT - Abstract Data Type) is already an extreme, because one must structure the code in a certain wa…

You can't have monads in Scheme due to the lack of a type system. What you can have are instances of monads, but the point of using the concept of a monad is to abstract over it, and to have functions that work with any possible instance.

Functions that work on "any monad" in Scheme can accept the monad operations as an extra parameter. A macro can hide this, like

    (with-monad m
       (monad-operation data))
See https://github.com/clojure/algo.monads for an implementation of this in Clojure.

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

#95
post #15
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…

>> There are a lot of things wrong with Java, of course, which does not mean that they are also issue of object-oriented programming. Inheritance (sorry...) doesn't work both ways: the fact that a Lexus is prohibitively expensive doesn't mean moving vehicles are prohibitively expensive. 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 someth…

Everything in Java is not an object, and the author never made this claim. Languages he referenced where everything is an object are Python and Scala.

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

#96
post #29

Earlier quoted context omitted.

You can't have monads in Scheme due to the lack of a type system. What you can have are instances of monads, but the point of using the concept of a monad is to abstract over it, and to have functions that work with any possible instance.

> You can't have monads in Scheme due to the lack of a type system. You can have monads in almost any language. The lack of static typing means you don't have static type safety with them, but monads aren't any different than anything else in that regard. > What you can have are instances of monads, but the point of using the concept of a monad is to abstract over it, and to have functions that work with any possible…

> How does not having static typing prevent you from abstracting over monads?

They were probably talking about the way Haskell can figure out which monad you're in through type inference. As an example, `return :: a -> m a` dispatches on the type of the function's return value, which doesn't map cleanly to a dynamically typed implementation. You need to be explicit about the monad you're in if you don't have the compiler helping you out.

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

#97

This is an interesting article. It is the first critique of functional programming I've read from someone who clearly knows their shit. I plan to look at miniKanren more when I get the chance. I done a fair amount of math though likely less than the author but I have a similar impression - the things that are hardest to understand aren't necessarily the best tool for every job, despite their beauty. And beautiful abs…

It is the first critique of functional programming I've read from someone who clearly knows their shit. The critique is 'Haskell takes FP to an extreme and I show this is true because someone tried to implement miniKanren and needed Oleg to do it'. That is not really a strong argument. Also note that he isn't really arguing against functional programming, but pure functional programming . the things that are hardest…

> The critique is 'Haskell takes FP to an extreme and I show this is true because someone tried to implement miniKanren and needed Oleg to do it'.

>That is not really a strong argument.

It's worse than that. The linked paper is about implementing minikanren as a monad transformer, which is a lot trickier than just porting it over, regardless of language. It's probably a lot easier in Haskell than in Scheme though.

Furthermore, if pure FP is useless, then monad transformers are useless too. But then the argument becomes "this useless thing is really tricky to implement in Haskell, therefore Haskell is useless". The only reason you would want Oleg's minikanren to be easy to implement is if you actually want pure FP. So the argument kind of negates itself.

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

#98

Is there a blend between the two? I really like loops...

Let go of your loops and learn to map, flatMap, and fold! Once I really figured out how to use those effectively, I've written far few indexed for loops. I tried to explain this philosophy on a recent and unheralded SO answer: http://stackoverflow.com/questions/19720830/is-it-safe-to-mo...

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

#99

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.

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

#100
post #29

This is solved long ago, without taking any extremes. In short, a language should be mostly-functional, which means when you really need to overwrite a value you just do it. In well-researched languages, such as Scheme you have set!, in CLs you have setf. All the monadic stuff (remember, that a monad is nothing but an ADT - Abstract Data Type) is already an extreme, because one must structure the code in a certain wa…

You can't have monads in Scheme due to the lack of a type system. What you can have are instances of monads, but the point of using the concept of a monad is to abstract over it, and to have functions that work with any possible instance.

http://www.pvk.ca/Blog/2013/09/19/all-you-need-is-call-slash...

Think again, Paul Khoung walks you through implementing some monads using call/cc

Post reply on HN