Live data from Hacker News

All programming philosophies are about state

worldofbs.com

231–240 of 254 posts

Re: All programming philosophies are about state

#231

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 th…

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

#232

Earlier quoted context omitted.

>I think your mistake is that it's not about the "abstract"/academic/philosophical or etymological meaning of those terms (functional, imperative, etc). No mistake made by me. The popular or even academic usage of the terms isn't relevant to the topic here. The reason is because the way these terms are used are highly inconsistent even in academia. They're not formally defined, they're just used for informal fuzzy co…

> Try writing fibonacci with everything immutable in say something simple like JS or python. Good luck doing it without using recursion or reduce. SSA, no recursion, no reduce ;) def factorial(X: int) -> int: encode = lambda n: ((lambda N: lambda g: lambda f: lambda x: x if N == 0 else f(g(N-1)(g)(f)(x)))(n) (lambda N: lambda g: lambda f: lambda x: x if N == 0 else f(g(N-1)(g)(f)(x)))) decode = lambda f: f(lambda x:…

Clever. Very cool. Of course the y combinator. Even so my point stands.

This snippet was clearly functional .

Re: All programming philosophies are about state

#233
post #181
post #154

I’ve been a programmer all my life, got first sw job around 2000 in business-oriented area (consulting + programming + “ops”). Before that were 5-7 years of toy programming as a kid. I experimented with tech a lot, got into paradigms early and never restricted myself to a single language/env/os/hw. I haven’t created nothing big, stellar or rocket science, but a couple of my projects lived for 10-17 years and counting…

Maybe you simply gravitated towards sensible ways of dealing with it? There are quite a bunch of things that are _hard_ (IMO) and related to state management a non-exclusive list of examples: - GUIs in general, the more interactive they are, the more state you need to manage. - Caching (at any level) is a form of state. You need to be aware of how and when data changes and who changes it and which parts of the cachin…

It’s hard to tell. My gut feeling, especially the one I get from popular state management libraries, says I actually gravitate away from it, in a sense. I see what they are for, but it feels like they are made with a sugar-coated landing/tutorial page in mind, while at the same time making things more complex, basically trading more for less. They turn languages and paradigms indise out to get cool effects, but make your way of thinking diverge from how business requirements speak, creating a gap between programmers and consultants.

As others noted, the size of my projects may skew the perspective. But I’m not sure how big something should be (and tightly coupled) to start worrying about it, unless my primitives aren’t too great to use without a second thought. What bugs me even more us that popular libraries don’t even provide them out of box, suggesting to write code and to spread structures in a special convoluted way instead.

Re: All programming philosophies are about state

#234

Earlier quoted context omitted.

"SSA form"?

Static single assignment is a property of an intermediate representation, the language used by the front-end of the compiler (the part that handles a specific language, parsing, semantics, and whatnot) to the back-end of the compiler (the part that handles a specific architecture, emitting assembler instructions as well as optimizations). One of the tricks of making compilers is transforming the code into whatever fo…

Thanks! TIL.

Re: All programming philosophies are about state

#235
post #145
post #117

Earlier quoted context omitted.

Well… I’m not sure how helpful that example is, but yes you could probably find something in common between SQL and Haskell, and on the other hand, no, what I said did not mean that. Look up Graham Hutton’s writings on relations. He has published quite a bit about this, and he knows a thing or two about functional programming.

I think relations are not a precondition for something to be called declarative programming. Most definitions I‘ve found are way broader and generic.

I never claimed they were, and I don't know if they are. But relations are in the category of declarative, and are a generalization of functions.

Re: All programming philosophies are about state

#236

"All Programming is about State". All code is state. All state is code. It's turtles all the way down.

Code is logic. Data is state. To say that code is state is like saying that electrical circuits are electricity. Code carries data in the same way that electrical circuits carry electricity.

State is data over time!

Re: All programming philosophies are about state

#237

Earlier quoted context omitted.

>I think your mistake is that it's not about the "abstract"/academic/philosophical or etymological meaning of those terms (functional, imperative, etc). No mistake made by me. The popular or even academic usage of the terms isn't relevant to the topic here. The reason is because the way these terms are used are highly inconsistent even in academia. They're not formally defined, they're just used for informal fuzzy co…

> All of these programming styles, more or less can imitate each other when managing state. None of them have a crystal clear way of handling state that's specific to their style. OOP can imitate Imperative and vice versa. And the point is that this doesn't matter. It's not about C++ OOP being able to "imitate imperative" or not, it's about what C++ (or OOP in general) adds to the table regarding how programmers shou…

>And the point is that this doesn't matter. It's not about C++ OOP being able to "imitate imperative" or not, it's about what C++ (or OOP in general) adds to the table regarding how programmers should think and hide state.

That's your point. And MY POINT is that your point is missing the true relationship between these programming styles. C++ is not a topic here. That is a specific implementation of a programming style. We are talking about programming paradigms, not specific languages.

Additionally How is anything added to the table if every language can more or less imitate one another? Obviously you're referring to a bias that a language sort of pushes you toward. This is what YOU are saying. What I am saying is that YOUR perspective, again, is the one missing MY point.

Let me put it to you this way. When you notice everything is more or less isomorphic then you notice a true difference. FP is fundamentally different. Imperative and FP styles are MORE different then all the other styles of state management compared. Then from this you can see that there's a missing hierarchy within all these programming language paradigms. This is what I am pointing out. I'm presenting flaws of the original point, and making a new point.

>It's like you're arguing that "in the end, chemistry is just physics". Or worse, "in the end, cooking is just physics". Sure, but that is pedantically irrelevant information in a regular cookbook or when talking about national cuisines.

No I'm not. I'm saying that YOUR and the OP's point is wrong because the "everything is the same" result is what you get when you compare programming paradigms this way. You need a hierarchy and only sibling nodes in the hierarchy can be compared.

>My whole point was that it's not about the isomorphism, but the higher level trappings. Funny how you've managed to miss the whole argument, it's not even like I didn't spell it out (or like I haven't already said that SSA is nominally "functional programming") but it doesn't matter

In logic and in programming as you get more and more higher level things become more and more isomorphic until finally at the highest level of abstraction everything is the same thing. This follows logic.

In programming and in nature as you get more and more lower level things ALSO tend to become the same. But this does not follow logic. From our observations everything looks to be made out of atoms, and by design all programming styles compile into assembly instructions. But this doesn't follow any form of logic; it doesn't HAVE to be this way by logic, it is simply this way by observation or by design.

That being said, your comment about higher level trappings make no sense. Going in EITHER direction things should become more and more samey. Additionally I'm not even going to a higher level or a lower level. I am simply saying these programming paradigms have hierarchy. I am also saying within each paradigm, things are so flexible that there is no specific way of managing state. You can manage state the EXACT same way in all paradigms, except ONE style. By seeing it this way a clear hierarchy emerges. That is it.

SSA has nothing to do with this. This is a term from compiler design and you're accusing me of going to a lower level? Still I get your point and in SSA from the way you use it is not "nominally" functional programming. IT IS functional programming. Literally look at the other persons post who implemented fib. That's totally functional.

Re: All programming philosophies are about state

#238

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 th…

this one made me laugh!! thank you :)

Re: All programming philosophies are about state

#239

Earlier quoted context omitted.

i've been thinking about this for a while. my basic question is: languages give or don't give features mostly to avoid spaghetti code; what if what's really needed is tools to make dealing with spaghetti code easy?

I’m right there with you. It feels much more interesting than the 3 strategies we have collectively formulated for avoiding code. Those strategies have plateaued. Functional programming isn’t good enough. We need something different.

The problem with your desire is that the most cutting edge OOP paradigm is event-sourcing, which is essentially functional. Event sourcing isn't a clearly defined pattern, but it kinda blends functional ideas, "given a state and a change, i'll give you a new state" such that your system will give a non-deterministic new state based on a change. That's de facto functional programming.

Having said that, the leanest system will be reference types under the hood, as for example, the C# stack frame is limited to 1mb and can't contain your app's entire state.

So we arrive at today's cutting edge which is F#, Clojure, etc. that are functional wrappers around heap-based lookups.

Re: All programming philosophies are about state

#240
post #98

Earlier quoted context omitted.

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?

Is it a thing anywhere? Who chooses not to care about the resources, the things you're there to divvy up.

Not caring at all is certainly a choice I can see individuals making, but someone who is politically engaged and doesn't care about the resources, I can't even fathom it.

Post reply on HN