Live data from Hacker News

All programming philosophies are about state

worldofbs.com

91–100 of 254 posts

Re: All programming philosophies are about state

#91
post #85

Earlier quoted context omitted.

Not really. Try to interact with DB in FP. Yes, there is a referential transparency ... when combining functions which call DB (e.g. using monads). As a result you get a composite function, which is the same every time you run that composition. Who cares really? When you execute that composite function though you will potentially get different results and your "referential transparency" goes out the window. Of course…

No, but this is why we have things like linear types or encapsulating side effects in a state monad to describe these kinds of strict sequencings. I personally think pure functional programming is still very unergonomic but referential transparency in the face of side effects is not an unsolved problem. Besides, it's good practice to limit how widespread side effects are in any program, anyway.

Referential transparency is something you can reason about. While technically monads are "reasonable" you are not going to reduce them by substitution. Yes, you can if you have a good imagination, but how does it help? While combining effects is thread safe etc., executing resulting function not necessary is. So we just kicked the can down the road adding another layer on top of existing compiler.

Monads is a nice way to hide state I have to admit, but not because of referential transparency and "reasoning".

Re: All programming philosophies are about state

#93
post #4

It's been a while but I used to enjoy telling folks in the early years of their career that software engineers and anarchists have a lot in common because both view "the state" as the main cause of problems.

Oh this one was good. I'm going to have to put that in my back pocket. The punchline is that obviously that's not the only thing they have in common.

Re: All programming philosophies are about state

#94

Earlier quoted context omitted.

Well sure, it’s “sound of mind” to you because that’s your political view. To people on the right it’s just completely naive. The first half is mathematically impossible and the second half is so wishy washy that it leaves room for everyone to claim they were born further back in one aspect or another on the proverbial board.

> it leaves room for everyone to claim they were born further back in one aspect or another on the proverbial board. Because generosity is exploitable, it's better to exploit.

Because generosity is exploitable, it deserves examination for integrity. That's a different way to phrase it that avoids your strawman.

Re: All programming philosophies are about state

#95

Earlier quoted context omitted.

DB operations are not what is being described in the conversation about referential transparency. We’re talking about something that starts with things like reduce vs. a for loop with mutable variables to accumulate values. Once the language forces you to think in terms of stateful operations to perform even basic tasks, the reflexive tendency is to use mutable state to perform any task. At that point, nobody really…

But we do have loops in the real world, don't we? So in a true FP we are talking about recursion as an alternative to for loops. Can you easily reduce recursive function? If you can, I can as well "reduce" for loop. Otherwise we are talking about a paradigm without recursions and side effects.

https://clojuredocs.org/clojure.core/reduce

Re: All programming philosophies are about state

#96
post #83
post #71

Earlier quoted context omitted.

“He who is not a républicain at twenty compels one to doubt the generosity of his heart; but he who, after thirty, persists, compels one to doubt the soundness of his mind.”

I really dislike this quote. It always comes across like it's designed to ease greedy people of their guilt for moving to the right as they earn more money. To me, being sound of mind is wanting everyone to have what you have, or at least an equal shot of getting there from wherever they had the roll of the dice of being born.

Reminds me of a great 30 rock joke, being fiscally liberal and socially conservative.

Politics is really just dividing up the shared resources, which is the root of that joke. Who cares about politics and doesn’t care about the resources part?

I guess after 30 people forget how to share per that quote. Never happened to me though. Personally I don’t even think it’s accurate, in my life I’ve never seen people swing from generous to… let’s just say “not”

The people who were always like that a little got more so.

Re: All programming philosophies are about state

#97

Earlier quoted context omitted.

But we do have loops in the real world, don't we? So in a true FP we are talking about recursion as an alternative to for loops. Can you easily reduce recursive function? If you can, I can as well "reduce" for loop. Otherwise we are talking about a paradigm without recursions and side effects.

https://clojuredocs.org/clojure.core/reduce

Recursion, what was the point of the link?

Re: All programming philosophies are about state

#98
post #83

Earlier quoted context omitted.

I really dislike this quote. It always comes across like it's designed to ease greedy people of their guilt for moving to the right as they earn more money. To me, being sound of mind is wanting everyone to have what you have, or at least an equal shot of getting there from wherever they had the roll of the dice of being born.

Reminds me of a great 30 rock joke, being fiscally liberal and socially conservative. Politics is really just dividing up the shared resources, which is the root of that joke. Who cares about politics and doesn’t care about the resources part? I guess after 30 people forget how to share per that quote. Never happened to me though. Personally I don’t even think it’s accurate, in my life I’ve never seen people swing fr…

> fiscally liberal and socially conservative

That's top left on the political compass... Is that not a thing in the US?

Re: All programming philosophies are about state

#99
post #68

State = context. In a pure functional language the state would be concerted into extra function parameters. Many bugs arise from unexpected context: programmer writes code expecting one context but gets an oddly-shaped context they weren't planning for (the other bugs are typos, where the context is correct but your code is not what they planned it to be, or when downstream code has different behavior than they expec…

State is not the same as context, because (nonpure) functions also perform state changes, and concurrent execution can cause shared state to change at any time during the execution of a function, including for objects the function created itself (weren’t existing context). Bugs arise from incorrect assumptions. These can be assumptions about state or context, but really it can be any kind of assumption. Assumptions a…

> How to minimize the assumptions a given piece of code has to make, and minimizing its dependencies, are the bedrock of all software engineering advice

Would this be a case of managing the complexity of the developer's systems model?

Abstractions in effect clamp the complexity presented to the programmer & may include assumptions about the given piece of code. Question being are the cognitive assumptions presented to the programmer able to result in unintended consequences, how often, & how severe in systemic terms?

Re: All programming philosophies are about state

#100
post #71

Earlier quoted context omitted.

Out of curiosity, why former?

“He who is not a républicain at twenty compels one to doubt the generosity of his heart; but he who, after thirty, persists, compels one to doubt the soundness of his mind.”

God, this is such condescending nonsense. The older I get, the more left I lean, because the more of the world you see the more you see what chaos our current ideology has wreaked upon it. The only people I see going the way this quote does are unthinking idiots who were fashionably "liberal" in their youth without understanding any political theory, and are now fashionably "conservative" with even lesser understanding.
Post reply on HN