News for hackers. Stuff that matters.
Re:All Programming Philosophies Are About State by kazinator on Monday February 06, 2023 @09:24PM (#34687786)
Imperative: modifying state is the point of a bit-flipping machine; get out of my way so I can have fun!

OOP: OK, I mostly had enough fun, can we try to tame the bit-flipping chaos with real-world analogies, without deflating all the fun?

Functional: Any Monad is by definition an Endofunctor, which also means it's an object in the category of Endofunctors, where the monadic μ(flatMap) and η(unit) operators satisfy the definition of a Monoid in that particular Monoidal Category. You got that?

Declarative: I'm gonna need a corner office with a view, and $200K/y.

Re:All Programming Philosophies Are About State by noman-land on Monday February 06, 2023 @11:56PM (#34688941)
This made me laugh. Especially because I've read that exact monad snippet before and had several wtf moments in rapid succession.
Re:All Programming Philosophies Are About State by bradrn on Tuesday February 07, 2023 @12:53AM (#34689243)
I feel I should point out that that ‘functional’ quote is (a) only applicable to pure, strongly-typed functional languages, and (b) pretty much irrelevant unless you happen to be interested in category theory.
Re:All Programming Philosophies Are About State by fulafel on Tuesday February 07, 2023 @01:42AM (#34689536)
Yep, the FP scene is split into the pragmatic and the academic sides.

I think it is not precisely delineated along the static vs dynamic sides: In addition to Elixir/Erlang, and Clojure we have eg F# and Elm from the static side in the pragmatic team.

Re:All Programming Philosophies Are About State by bradrn on Tuesday February 07, 2023 @03:03AM (#34690025)
I think the distinction you’re trying to make is that of ‘impure’ vs ‘pure’; ‘pragmatic’ vs ‘academic’ strikes me as a rather loaded choice of terminology, especially since languages like Haskell are rather widely used practically.
Re:All Programming Philosophies Are About State by tasuki on Tuesday February 07, 2023 @06:08AM (#34691260)
I don't think that's the distinction fulafel tried to make.

Elm is very much pure, yet it's on the pragmatic side: it forgoes certain powerful abstractions (higher kinded polymorphism, type classes), which enables the compiler to give very helpful error messages, and makes the language easier to learn.

Re:All Programming Philosophies Are About State by bradrn on Tuesday February 07, 2023 @07:07AM (#34691647)
> Elm is very much pure

Huh… you’re quite right. I always thought it was impure. In that case I retract my previous comment (pity I can’t edit it any more!).

Re:All Programming Philosophies Are About State by epwr on Tuesday February 07, 2023 @01:25AM (#34689454)
You might want to look a bit more closely before you write functional programming off like this.

Eg. Clojure is a modern functional language that is used for a lot of things & happens to be dynamic.

Re:All Programming Philosophies Are About State by bradrn on Tuesday February 07, 2023 @03:00AM (#34690010)
Since when was I writing off FP? My main language for personal projects is Haskell. I was just pointing out that the category theory stuff isn’t really relevant at all.
Re:All Programming Philosophies Are About State by irrational on Tuesday February 07, 2023 @01:08AM (#34689334)
Isn’t OOP a subset of imperative programming and functional a subset of declarative programming?
Re:All Programming Philosophies Are About State by EugeneOZ on Tuesday February 07, 2023 @01:16AM (#34689400)
You can be very declarative with OOP.
Re:All Programming Philosophies Are About State by seanhunter on Wednesday February 08, 2023 @12:53AM (#34704639)
Not really. For example ocaml allows oop in a functional programming language.

OOP is about encapsulation of data and algorithms which deal with that data in logical units (objects) and allowing certain operations eg inheritance, polymorphism (sometimes) etc over those objects. It can be declarative or imperative.

Re:All Programming Philosophies Are About State by dgb23 on Tuesday February 07, 2023 @02:09AM (#34689678)
There’s another variation to ‘functional’:

Let’s treat data as what it is so I can sleep at night again.

Re:All Programming Philosophies Are About State by jraph on Tuesday February 07, 2023 @02:51AM (#34689955)
This made me smile. I'm not sure I get the declarative one though, can someone expand on this? Is it because the sentence is very declarative? or because declarative programming allows lets to declare expensive to compute stuff (by mistake) too easily?
Re:All Programming Philosophies Are About State by cubefox on Tuesday February 07, 2023 @09:06AM (#34692866)
I think it's the first.
Re:All Programming Philosophies Are About State by overtomanu on Tuesday February 07, 2023 @09:14AM (#34692979)
You don't tell the computer how to do the task, but you tell what result you want. Eg: SQL
Re:All Programming Philosophies Are About State by deafpolygon on Tuesday February 07, 2023 @03:38AM (#34690257)
Functional languages is what happens when you let a bunch of mathematicians get a hold of a compiler.

At it's core, it's about treating data like data and not about having to much about with "objects".

Re:All Programming Philosophies Are About State by ahartmetz on Tuesday February 07, 2023 @03:55AM (#34690363)
...and it's a real shame that Haskell has to be like that. I feel like much of the, sorry, mathematical wankery, is well separable from the stuff that actually makes program behavior more predictable in the functional style. I hear that F# has some success at doing exactly that.
Re:All Programming Philosophies Are About State by quchen on Tuesday February 07, 2023 @04:42AM (#34690667)
> mathematical wankery

Some blog posts are wankery. Haskell in practice is as separate and separable from it as you want.

I learned what a mathematical monad is out of interest (after using them in practice for years), and my conclusion is that it was a huge waste of time with close to zero use for my programming in Haskell.

Re:All Programming Philosophies Are About State by tome on Tuesday February 07, 2023 @05:16AM (#34690897)
> I learned what a mathematical monad is out of interest (after using them in practice for years)

Agreed. I regret that I tried to learn what a mathematical monad was before using them, out of a belief that it would help me get started quicker with Haskell. It didn't. It made something confusing that's actually pretty simple.

Re:All Programming Philosophies Are About State by lysecret on Tuesday February 07, 2023 @07:15AM (#34691732)
Can confirm been working with F# for 2 months and I really miss the strong type system, DU and match statements when I go back to Python.
Re:All Programming Philosophies Are About State by azubinski on Tuesday February 07, 2023 @05:23AM (#34690944)
Applause!
Re:All Programming Philosophies Are About State by DonaldPShimoda on Tuesday February 07, 2023 @10:52AM (#34694328)
I wish people would quit propagating this hostile view of functional programmers. The vast majority of them — even in academia — are happy to never mention or even fully learn about the scary math words, and most of those who _do_ learn about them work really hard to not make the community unwelcoming to those who don't know or don't want to know. But the reputation precedes, which causes people to avoid it altogether, which is really a shame.

The whole "a monad is a monoid in the category of endofunctors, what's the big deal?"-in-a-condescending-tone bit comes from "A Brief, Incomplete, and Mostly Wrong History of Programming Languages": a satirical blog post from 2009 (http://james-iry.blogspot.com/2009/05/brief-incomplete-and-m...). It is not indicative of the general community, but the joke has been reproduced enough that people who don't know anything will encounter it, think the practitioners are serious about it, and write off the whole thing as unwelcoming. It's a bummer.

Re:All Programming Philosophies Are About State by hinkley on Wednesday February 08, 2023 @11:48AM (#34710770)
It would help if functional didn’t collect all the people with their heads all the way up their own asses. Functional has more shibboleths than anybody except maybe professional consulting groups like IBM GS.

You can’t have exclusive language and then be surprised when nobody wants to worship at the altar of your obfuscation.

Re:All Programming Philosophies Are About State by DonaldPShimoda on Thursday February 09, 2023 @12:13PM (#34727322)
> ETA: Look. I was reading 25 year old complaints about why Lisp isn’t popular 25 years ago. You can go on scratching your heads for another 25 years or you can start taking criticism instead of deflecting.

Is this... directed at me? Are you saying that I've been guilty of this behavior? Could you point me to an example? Because I put a lot of effort into helping the functional programming community be more welcoming, so it'd be important to me to know if I've gone astray somewhere.

> It would help if functional didn’t collect all the people with their heads all the way up their own asses.

I don't disagree that the kind of people who like to be particularly condescending tend to also end up in this community.

That said, I will point out: (a) there are still plenty of assholes in non-functional (or even anti-functional) communities, and (b) the community has grown a lot over the years, and has mostly shifted to being much more positive and inclusive. Unfortunately, the reputation from decades ago is still strong, and I honestly believe part of that is due to historically-justified propagation from people like you in this comment and the other person in the comment to which I originally replied, to name two examples. There's a lot of residual hostility against the FP community that I don't think is truthfully justifiable anymore.

Re:All Programming Philosophies Are About State by rshaban on Tuesday February 07, 2023 @01:44PM (#34697128)
this one made me laugh!! thank you :)