Live data from Hacker News

Goodbye, Object Oriented Programming

medium.com

311–320 of 355 posts

Re: Goodbye, Object Oriented Programming

#311

Earlier quoted context omitted.

> Except that there is a real advantage to using pure functional programming; being able to easily prove theorems about your code and understand different components in isolation. And how often does that occur in practice for most of the programs people write? Even the most hardcore Haskell programmer isn't going around proving theorems about their modules beyond what the type system can provide for free (and that is…

> And how often does that occur in practice for most of the programs people write? Very frequently. The simple theorems that equational reasoning supports are very convenient for refactoring and optimizing code. Understanding components in isolation is useful for testing, isolating bugs, and refactoring of subprograms independently from their contexts. Since I do testing and refactoring frequently, I make good use of…

> Very frequently. The simple theorems that equational reasoning supports are very convenient for refactoring and optimizing code.

I was generalizing across all programmers. Of course individual cases may vary, and it really depends on the code that you write!

> Not really. Statically typed OO doesn't prove nearly as much about the behavior. This is mostly due to potential for aliasing of stateful sub-components.

Haskell simply avoids aliasing with value semantics, and even then you can add it back and get the same problems.

> That's simply untrue. Encapsulated state in Haskell can be modeled by a variety of types. One is `Machine i o = i → (o, Machine i o)`. Such machines can be composed, each component machine having its own internal, encapsulated state.

I'm not disagreeing. My point is that you have to bury the state in something else, which is then exposed via a signature (well, in Haskell which supports this, of course).

> I'd say pure FP is a lot younger.

We could debate a lot on what pure FP is, what pure OO is, and who climbed the ladder faster. But the fact that paradigms developed around the same time is probably due to the programming field maturing in that time frame.

Re: Goodbye, Object Oriented Programming

#312
post #263

Earlier quoted context omitted.

> Except that there is a real advantage to using pure functional programming; being able to easily prove theorems about your code and understand different components in isolation. And how often does that occur in practice for most of the programs people write? Even the most hardcore Haskell programmer isn't going around proving theorems about their modules beyond what the type system can provide for free (and that is…

> And how often does that occur in practice for most of the programs people write? Even the most hardcore Haskell programmer isn't going around proving theorems about their modules beyond what the type system can provide for free (and that is true of statically typed OO also). "What the type system can provide for free" isn't static. Part of working in that kind of language is structuring your code such that importan…

> "is this piece of code equivalent to this other piece of code?" is what I'd venture to suggest programmers spend most of their day asking, and Haskell-like languages make that easier to answer.

It is a boring question to ask, and one that doesn't come up much in my work. Does this mean Haskell-like languages are not appropriate for my domain?

Re: Goodbye, Object Oriented Programming

#313

Earlier quoted context omitted.

They come Berkeley and MIT, colleges that are renowned for teaching functional languages in their intro to programming courses, don't they.

Err, not exactly, Berkeley and Mit use python now and have been for a while.

I can't speak for MIT but Berkeley has essentially translated SICP material to Python and then you have to write a Scheme interpreter.

Students there have more FP experience than most.

Re: Goodbye, Object Oriented Programming

#314
post #11

Earlier quoted context omitted.

> For instance I have yet to see an easy and simple to use (and as such maintainable) functional widget and gui library. Like react?

My impression of react is that it's very object oriented. Defining reusable, stateful components is classic OO design. Now, I don't have much experience with React so maybe someone can explain why it should be considered "functional".

It depends on how you use React. You can use it in a stateful, OO way. Or you can use it in a more functional way. A good example of how to use React in a functional manner is the Redux framework (basically you don't use the stateful parts of React and treat your components as a tree of pure render functions). http://redux.js.org/

Re: Goodbye, Object Oriented Programming

#315
post #72
post #65

Earlier quoted context omitted.

Well said. I feel the same way about this as I do platforms. There is amazing projects on every platform. There is horrendous projects on every platform. Taking sides just a narrows your point of view and lessens the amount you can learn.

We have to take sides. If I commit to iPhone, but there's a lot of stuff in android but I can't take advantage of. And vice versa

Choosing one platform over another should be a pragmatic decision, not a religious one (the latter of which would constitute 'taking sides').

Re: Goodbye, Object Oriented Programming

#316

Earlier quoted context omitted.

I don't have any idea what you're talking about when you say 'functional came before OO'. I'm guessing you are talking about Lisp, but not only are Common Lisp (and the languages it evolved from) not at all functional in any technical sense of the word, many of them only had dynamic scoping, and often used mutation of data structures implicitly. Stop talking nonsense. EDIT: If you are talking about scheme, then the s…

> Neither Schema nor Lisp nor any but a very few quite obscure languages satisfy this. That doesn't seem like it would be a very useful definition then.

Haskell, Ocaml, etc. There's nothing at all functional about Common Lisp, not even a little bit, far from it, if anything the opposite.

Re: Goodbye, Object Oriented Programming

#317

Earlier quoted context omitted.

I don't have any idea what you're talking about when you say 'functional came before OO'. I'm guessing you are talking about Lisp, but not only are Common Lisp (and the languages it evolved from) not at all functional in any technical sense of the word, many of them only had dynamic scoping, and often used mutation of data structures implicitly. Stop talking nonsense. EDIT: If you are talking about scheme, then the s…

>I don't have any idea what you're talking about when you say 'functional came before OO'. Lambda calculus is technically the first functional language, and predates computers. But if we're talking about actual programming languages, SASL, one of the earliest functional languages actually implemented, was released the same year as Smalltalk, and was influenced by the older ISWIM, which was never implemented. >I'm gue…

How is 'the same year as smalltalk' predating it?

Simula was working in like '67, which is like 5 years before smalltalk.

My point is that functional languages do not predate OO languages, and if anything come later, and you never really addressed that.

Re: Goodbye, Object Oriented Programming

#318

Earlier quoted context omitted.

Conceptually, components have state, but it's all managed by react, so you only ever write pure functions. Granted, depending on how you update state in event handlers and lifecycle methods, you will need to think about state a lot, but this is an unavoidable fact of UI programming. > every component must be created by extending a base class This is an implementation detail, instead of ES6 classes you can also use Re…

Conceptually is nice. All react code I've seen or wrote of even the most trivial systems have components (and more then a few) that override lifecycle methods - which is by almost definition OO's polymorphism. Buy even if you could write every component with the stateless style it doesn't change the fact that your framework/GUI-library is using OO extensively and in it's fundamental concepts, I think that makes it OO…

It's not "overriding" lifecycle methods, it's passing lifecycle methods to a component factory function.

Re: Goodbye, Object Oriented Programming

#319
post #274

Earlier quoted context omitted.

The RAM model is nice for some simple space and runtime complexity analysis. Of course, it doesn't know about eg caches or parallelism, either. (Lambda calculus is an interesting foundation mostly for work on correctness of algorithms---indeed analysing cost of computations is harder. Chris Okasaki has done a good case study of analysing runtimes of purely functional algorithms / data structures.)

Can you use lambda calculus to prove the correctness of quicksort? :-)

Depends on which version you are talking about.

If you are happy to prove correctness of tree-sort, which does the same comparisons as quicksort, it's straight-forward.

If you want to talk about the clever in-place quicksort, you'll want to talk about a slightly more complicated model.

Either implicitly, where you still model everything as lambdas, or explicitly: you can model state (like an array) and its manipulation inside a lambda calculus framework just fine. Eg using linear typing, or something like Haskell's state monad (which has a pure description, but ghc is smart enough to optimize it to what you would expect when translating to machine code).

Re: Goodbye, Object Oriented Programming

#320
post #286
post #241

Earlier quoted context omitted.

Cobol is certainly considered bad.

While I think that you are definitely right and that nowadays Cobol would probably not be the first choice for 98% companies out there, I think we should also consider that according to TIOBE ( http://www.tiobe.com/tiobe_index ) Cobol is one of the 20 most used languages in the world - and it's also thanks to it that we can use banks efficiently. Can we all say goodbye to Cobol? Go and ask those ones who program in s…

Oh, you can make great money doing Cobol. Demand is niche, but supply is even smaller.

(My grandfather made very good money in the late 90s converting Cobol and assembly programs in banks and insurance companies to y2k.)

Post reply on HN