4 ms·
I wonder how a functional version of this would go.. You need transportation, so you define an engine and a set of wheels and a chair, and a whole universe. Yo
by RyanZAG 11y ago
I wonder how a functional version of this would go..
You need transportation, so you define an engine and a set of wheels and a chair, and a whole universe. You define a way to have the engine, wheels and a chair work together. You try to sit in the chair, but it's too small. You can't change the chair because it's all immutable, so you create a new chair along with a new universe and build a new car with the new chair.
You need to get to work, but you don't want to pollute your universe with state, so you don't know where work is. So you put all of your state in your relational stateful database and forget that this part exists in your universe. Of course theoretically you could model your knowledge as a function based off the state of the universe, but you don't have budget to do that. You write comments about quick hacks to get around purity constraints. The hacks are never removed and you end up passing stateful maps of database tables around. You make a big todo note about how you should implement a new method for handling this that you've read in a new academic paper, but never get the 500 hours you need to implement it.
EDIT: For those not getting it, the article is describing the difference between the theory behind OO interaction between self contained actors and how this really plays out in actual code. Instead of doing the theoretical part of communication between actors, we have code which does getCoworker().getWallet(). In the same way above, I've tried to show the difference between theoretical functional programming where we can create pure functions and how this actually plays out in real functional code.
- danieldk 11y agoYou can't change the chair because it's all immutable, so you create a new chair along with a new universe and build a new car with the new chair. No, if you read Okasaki, you knew you only have to reconstruct the part of the universe (up to its origin) that refers (directly or indirectly) to the seat ;). In fact, you can safely have two universes with different seats, where most of the universes is shared.
- RyanZAG 11y agoOh that makes for a funny part of the ending too then. While going about your work, you suddenly disappear along with your universe and everything in it. Someone somewhere in the world drank a cup of coffee, which means that he now has an empty cup instead of a full cup. A new universe had to be created with the full cup replaced, and unfortunately your universe had to be thrown away. You continue life as a clone in a new universe with an empty coffee cup somewhere in Nebraska. Why did this happen? Someone picked a copy-on-write map implementation because it had a slightly faster O(logN) delete behavior and unfortunately the re-use function of the map wasn't implemented yet because the author has gone on to do a series on the use of monads in baking the ultimate croissant.
- TeMPOraL 11y agoHence, Many World Interpretation of quantum mechanics.
- koenigdavidmj 11y agoSorting in O(n) time: 1. Apply a quantum permutation to your list. 2. Check if it's sorted. 3. If not, destroy the universe.
- arethuza 11y agoThat made me think of Greg Egan's Quarantine: https://en.wikipedia.org/wiki/Quarantine_%28Greg_Egan_novel%29 https://en.wikipedia.org/wiki/Quarantine_%28Greg_Egan_novel%...
- moron4hire 11y agoBest-case runtime = 1. Worst-case = infinity.
- AndrewOMartin 11y agoI think the joke is that in all cases but the best-case, you won't be around to observe it, this becomes practical once you can create a universe for every permutation and destroy all but the universe which notifies you that it's the best-case. In all good text books this is left as an exercise for the reader.
- AnimalMuppet 11y agoIn a really good text book, this is left as an exercise that the reader won't do.
- danieldk 11y agoNo, checking whether a list is sorted is O(n) ;). Bogosort is O(n) in the best case and O(inf) in the worst case).
- platz 11y agoI've never considered the many-worlds interpretation of quantum physics under the light of persistent data structures.. very interesting!
- cpeterso 11y ago"If you want to make an apple pie from scratch, you must first create the universe." — Carl Sagan