4 ms·
Part of the issue with Object Oriented design is how they maintain state and deal with their dependencies. A pure function has a very portable interface that m
by williamcotton 13y ago
Part of the issue with Object Oriented design is how they maintain state and deal with their dependencies.
A pure function has a very portable interface that makes it suitable for the distributed and social nature of the way we create software together.
These kinds of problems were not envisioned by the creators of the original Object Oriented systems like Smalltalk. Objects were designed for personal computers and building and using software designed for personal computers.
While shared workspace environments were explored in systems like Self, they were always designed around the objects being these visual instances running in a GUI.
Objects detached from a system like Self or Smalltalk lose a lot of their powers of abstraction. They are not and have never been portable, even if they were designed to be reusable.
- seanmcdirmid 13y ago> A pure function has a very portable interface that makes it suitable for the distributed and social nature of the way we create software together. Citation needed. I personally don't talk to other programmers in terms of functions, but I use plenty of metaphors and analogies that come with my evolutionary capabilities to use natural language (math, on the other hand, was something I had to learn).
- williamcotton 13y agoI'm citing my own experience as a professional. Programmers talk to other programmers in terms of functions all the time. Every API you use exposes functionality. If that API assumes some sort of state, that can cause issues for the consumer of the API. It also forces whatever entity is maintaining state be tightly coupled to the consumer and leads to centralized systems. If the API does NOT have state and instead uses a token based system for authentication and access permissions it is operating in a functional manner. State is maintained outside of the function. The less coupled that two modules are the more portable that they are. You can bundle up something like the "express" npm package and ship that off to whomever. You can easily build modules on top of an express application by passing the entire app to another module. This pattern has been used to build an entire ecosystem of loosely coupled middleware. These are not Object Oriented designs. They aren't entities that communicate by sending messages to one another while floating around in some global workspace. They are interfaces that pass state around as arguments to function calls. Global state is very nicely demonstrated in how modules can be shared between Node and Browser Javascript. What is global? All of the I/O. Files, XHR, mouse clicks, sockets... all of these are the inputs and outputs and all are handled by "window" or "process" or other global state. Modules can be easily be reused between the server and client if they do not interface at all with any sort of global state.
- seanmcdirmid 13y ago> Programmers talk to other programmers in terms of functions all the time. I seriously doubt it. In order to talk in terms of only functions, you would need to give up identity...because what is identity but not a key for encapsulated state? Without identity, you really are talking with just values, but you have problems describing things with handles. There is no single Bob, just a new Bob who is reconstituted each time you talk about him. Naming anything is weird, and the pure lambda calculus of course avoids it. Most APIs are not purely functional, but somewhat object-oriented (oriented around identity) if only in a few key aspects that are needed to do anything at all.
- weavejester 13y agoYou can have identity without encapsulated state, you just need something that's sufficiently unique, such as a UUID or SHA hash.
- seanmcdirmid 13y agoIt is the same thing actually, either will give you the other.
- weavejester 13y agoHow does a raw UUID equate to encapsulated state? Adding a UUID doesn't inherently hide or restrict access to data.
- seanmcdirmid 13y agoThink about it like this: as long as you have an identity, someone can remember something about you...and therefore state! If you didn't have an identity, then that would be impossible, it is like a superpower where no one could "remember" who you are, and therefore nothing about you. A UUID is synonymous to state, and in fact, procuring and propagating these IDs would be the main step to implementing state in a pure language.