News for hackers. Stuff that matters.
Re:Motivation – Keli Language by cannabis_sam on Monday August 31, 2020 @12:28PM (#24333026)
> An api that was written to simply process a list of Orders into a Report might be abstracted into a fold on some monad, which at first seems a great idea. But if you're not careful, readability suffers a lot. It's much easier to get to know an application when its code deals with business objects that you already understand well, than to read hundreds of lines of code that deal only with abstractions.

Do you have a code example? It would be interesting to see what this kind of code looks like.

Personally, I find complaining about a ”fold over a monad” to be equivalent to complaining about an ”integer indexed loop over an array”. It’s a pretty straightforward implementation detail that have very little to do with your business logic.

And business logic is far, far easier to model using ADTs (it’s literally just AND and OR, applied to data structures) than confounding object inheritance hierarchies.

In fact, I’ve seen a lot more unnecessarily abstracted garbage (usually “design pattern” workarounds to limitations in the object model) in just about every oop based web framework I’ve worked with.

Re:Motivation – Keli Language by scarmig on Monday August 31, 2020 @12:47PM (#24333258)
Well, we're used to the AbstractBeanHandlerFactoryFactories already. A slight discomfort of learning something new can seem much bigger when you're already acclimated to abuse.
Re:Motivation – Keli Language by strbean on Monday August 31, 2020 @02:13PM (#24334261)
Posting to name-drop SimpleBeanFactoryAwareAspectInstanceFactory
Re:Motivation – Keli Language by robocat on Monday August 31, 2020 @03:52PM (#24335290)
Re:Motivation – Keli Language by hinkley on Monday August 31, 2020 @07:28PM (#24336940)
They're talking about Existential Crises in another post today.

I think I still have a copy of the book that Johnson wrote to accompany the creation of Spring (which someone wants $300 bucks for on Amazon, I didn't know it was a collector's item). The last time I used Spring, I had the distinct thought that I should go through his book as if it were a bingo card, comparing it with the latest version. It seems like it has reacquired all of the bits of J2EE that it set out to avoid.

If, outside of Spring, there is anything in the Java world that more perfectly embodies Nietzsche's warning about fighting with monsters, I don't know what it is.

Re:Motivation – Keli Language by raegis on Monday August 31, 2020 @04:10PM (#24335440)
The guy next to me on the bus is asking why I'm laughing so hard. I'm not sure how to respond. "These class names are really funny!"
Re:Motivation – Keli Language by dllthomas on Monday August 31, 2020 @04:34PM (#24335643)
InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Re:Motivation – Keli Language by philosopher1234 on Monday August 31, 2020 @04:59PM (#24335871)
I'm glad we got the Simple one
Re:Motivation – Keli Language by IncRnd on Monday August 31, 2020 @05:39PM (#24336203)
Sometimes, though, you can only get the desired effect with SimpleBeanFactoryAwareAspectInstanceFactory_EX.
Re:Motivation – Keli Language by cannabis_sam on Friday September 04, 2020 @09:19AM (#24374657)
Thank you! I’m deeply familiar with the phenomenon!
Re:Motivation – Keli Language by HelloNurse on Monday August 31, 2020 @12:51PM (#24333311)
I'd prefer readability to suffer because the fold over a monad needs something clever that requires a bit of reasoning to understand than because vast amounts of "readable" boilerplate (for example, trivial getters and setters) hide a needle in a haystack.
Re:Motivation – Keli Language by mattmanser on Monday August 31, 2020 @03:49PM (#24335266)
Maybe in the 00s, but these days most languages have collapsed boiler plate down massively.

This comes across as an old fashioned view (bordering on extremely old-fashioned).

Re:Motivation – Keli Language by munk-a on Monday August 31, 2020 @07:56PM (#24337129)
I haven't seen evidence of reduced getters & setters in my day to day yet - they still seem pretty prevalent when OOP comes into the picture. I'd even say they got a bit worse because now it's excessive getters and setters with gigantic JavaDoc style comments all around them. If I see "@returns id integer The ID" one more time I'll be tempted to throw my monitor out the window.
Re:Motivation – Keli Language by mattmanser on Tuesday September 01, 2020 @06:55AM (#24340398)
What are you talking about? Get setters used to be 10 lines long like:

    int id;
    public int Id
    {
        get {
          return id;
        }
        set(val) {
            id = val;
        }
     }
They're now one liners, and obviously necessary

    public int Id { get; set; }
I don't keep up with Java any more, but C# has super short shortcuts for assignment like:

    public int Id { get; set; } => generateId();
If you, or your company, are misusing a completely optional documentation feature, which you definitely should not be using to annote obvious stuff like IDs, that's your problem, not OOPs.

Switching to a functional language won't save your monitor, you'll still be forced to write bad code if doing stupid things like that are in your style guide.

Re:Motivation – Keli Language by Sharlin on Tuesday September 01, 2020 @04:13PM (#24346464)
Your comment is entirely specific to C#. Java has no such shortcuts, its setters and getters look identical to how they looked in 1994:

    private int id;
    public void setId(int id) {
        this.id = id;
    }
    public int getId() {
        return id;
    }
Re:Motivation – Keli Language by csirob on Tuesday September 01, 2020 @12:05AM (#24338455)
> If I see "@returns id integer The ID" one more time I'll be tempted to throw my monitor out the window.

I honestly believe we're in a dire need for a more up-to-date metaphor that lets us better express our anger at a computer, due to monitors becoming paper thin and lightweight in the past decade or so.

Re:Motivation – Keli Language by webmaven on Tuesday September 01, 2020 @12:14AM (#24338497)
> > If I see "@returns id integer The ID" one more time I'll be tempted to throw my monitor out the window.

> I honestly believe we're in a dire need for a more up-to-date metaphor that lets us express our anger at a computer, due to monitors becoming paper thin and lightweight in the past decade or so.

My experience may not be representative, but I believe I have encountered variants of "hurl the keyboard at the monitor" more often than "monitor out the window".

OTOH, that phrase doesn't account for laptops.

Re:Motivation – Keli Language by csirob on Tuesday September 01, 2020 @12:21AM (#24338535)
> OTOH, that phrase doesn't account for laptops.

It is also not anger-ready for people working on tablets with rubber keyboards attached.

Re:Motivation – Keli Language by HelloNurse on Tuesday September 01, 2020 @11:32AM (#24342888)
Hitting the desk with a fist of moderate force is harmless and rattles lightweight modern computer equipment very satisfactorily.
Re:Motivation – Keli Language by panzerklein on Tuesday September 01, 2020 @06:13AM (#24340144)
Putting fist through the monitor?
Re:Motivation – Keli Language by qppo on Monday August 31, 2020 @01:12PM (#24333563)
folding over a monad (or any other combinator) doesn't require extra reasoning or anything clever, that's the point.
Re:Motivation – Keli Language by JadeNB on Monday August 31, 2020 @02:55PM (#24334742)
I think HelloNurse's point was less that a fold is inherently clever or subtle (as you say, it isn't), and more that, if there is something clever or subtle involved, the lesser verbosity of the fold makes it easier to see than would a more familiar, boilerplate-heavy approach in which the clever or subtle point could be lost.
Re:Motivation – Keli Language by chrischen on Monday August 31, 2020 @04:33PM (#24335625)
It does if you are unfamiliar to the pattern. It probably has more to do with experience with the patterns used rather than readability.
Re:Motivation – Keli Language by treetide on Monday August 31, 2020 @05:50PM (#24336267)
I just wrote about some possible pitfalls down the ADT route: https://treetide.com/posts/domain-model-pitfalls-oop-fp.html

> As more operations are demanded, it is more likely that the existing partitioning of the world into the nice distinct cases won’t suit that operation anymore. Then, as a fix, we can introduce more specific cases, or make existing ones more general - leading to ambiguity, bloat and mental load for the existing operations.

Just an aspect.

Re:Motivation – Keli Language by cannabis_sam on Friday September 04, 2020 @09:22AM (#24374680)
I like it!

It’s the kind of reasonable discussion that I crave in this field.

Re:Motivation – Keli Language by misja111 on Tuesday September 01, 2020 @02:32AM (#24339090)
> Personally, I find complaining about a ”fold over a monad” to be equivalent to complaining about an ”integer indexed loop over an array”.

This was just an example of a behaviour that, if taken too far, could eventually lead to those 'hundreds of lines of abstract code'. Of course a single fold in itself is nothing to be concerned about. But an API that accepts a type 'm a' instead of '[Order]' has lost some of its connection with the business domain already.

Again, this might not be bad, it can even be good, but the problem is that many FP enthusiasts overdo it.

> In fact, I’ve seen a lot more unnecessarily abstracted garbage (usually “design pattern” workarounds to limitations in the object model) in just about every oop based web framework I’ve worked with.

Yes, this is the same problem which pops up in the OOP world as well. I guess it is a human thing to want to use your latest powerful language tool wherever you see a possibility for it.

Re:Motivation – Keli Language by cannabis_sam on Friday September 04, 2020 @09:46AM (#24374857)
> 'hundreds of lines of abstract code'.

Yeah, I’ve spent way to much time digging into “hundreds of thousands” of lines of abstract OOP code. And it’s sadly, largely ceremonial, mostly due to limitations in the language. The less fanatic about OOP the language is, the more useful it is, is a good rule.

But it’s absolutely not exclusive to either paradigm.

> But an API that accepts a type 'm a' instead of '[Order]' has lost some of its connection with the business domain already.

I completely agree, but I’m also curious how any API interface like that would pass code review. Since it’s so obviously too general.

But I guess the perceived upside is that the equivalent oop-construction would not get caught in code review.

> Yes, this is the same problem which pops up in the OOP world as well.

I know. I’ve spent more time working within oop than without. The type based FP-world just have orders of magnitude better tools.

> I guess it is a human thing to want to use your latest powerful language tool wherever you see a possibility for it.

This is kind of a sad way to dismiss people, as if they’re some kind of ephemeral fireflies...

The reality is that trying to force reality into in an inheritance-based, tree-structured taxonomy, is not only stupid, it also creates endless maintenance headaches.

Some problems fit that model better sure, but most things fit a much simpler ADT-based model since it’s much closer to how we think logically. (In terms of logical primitives and implicit recursion)

Re:Motivation – Keli Language by cuddlybacon on Monday August 31, 2020 @06:23PM (#24336499)
I think many of the responses to your parent post are focusing too much on `fold` and not the custom monad that is implied to just be a re-implementation of list.