If Nu were mutable... #1029
Replies: 8 comments
-
|
We're researchers and experimentation is a key part of research. It might be worth making a fork of Nu just to see if its affordances do end up being significantly stronger than its current approach. That said, this wouldn't be a matter of letting the two forks fight each other out and see who wins as, at some point, one fork would have to be chosen based on our own values. |
Beta Was this translation helpful? Give feedback.
-
|
from discord monologue on branch - https://github.com/bryanedds/Nu/tree/mutable |
Beta Was this translation helpful? Give feedback.
-
|
In order to keep World operations from invalidating not just immutable Model values but also any immutable property value, we'd have to go full in on mutability, even to the point of making non-value-type properties mutable. The middle way wouldn't really work. This means not only will we lose MMCC in practice but also gameplay undo / redo. Additionally, mutable property changes will have to have their change events raised manually, which tends to be unreliable or if they are somehow automated, requires an unfortunately complex implementation for every involved type (EG, ObservableCollections in WPF - https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?view=net-9.0). Currently, losing these major features alone are enough to justify halting work on the branch for now. Perhaps at some point it will make sense to bring it into completion, however. |
Beta Was this translation helpful? Give feedback.
-
|
bryanedds — 11:53 PM |
Beta Was this translation helpful? Give feedback.
-
|
My curiosity got the best of me and I spent the past couple days converting the rest of the code in the |
Beta Was this translation helpful? Give feedback.
-
|
We managed to get the ergonomic improvements from mutable Nu into functional Nu by using a special technique that makes an immutable world state appear mutable in the |
Beta Was this translation helpful? Give feedback.
-
|
I'm going to make a guarantee going forward - On every github release (https://github.com/bryanedds/Nu/releases), I'm going to merge This makes |
Beta Was this translation helpful? Give feedback.
-
|
Closing as dealt with. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
UPDATE - READ FIRST!
We're now guaranteeing a policy of merging
mastertomutablebranch at every release. Themutablebranch is a purely imperative branch of Nu that we maintain for a couple of reasons -Risk Mitigation - even in 2025, we're still waiting for the games industry to start widely adopting functional programming. It was my guess that this would start happening 5-10 years, but of all industries, the game industry remains a particularly stubborn hold out. If it remains as such, we still have a path toward relevancy with this branch.
Marginal Performance Increase over Nu in Imperative Mode - you don't need to use the
mutablebranch in order to get nearly all its performance benefits! Instead, you can just flip Nu's existing Imperative switch to true and Nu's will internally (albeit dynamically via if expressions) utilize imperative semantics! However, when shipping your game, you can eliminate all of that runtime checking by shipping with themutablebranch.Keeping the mutable branch up to date has little cost on our end but has upsides that more than pay for it. This makes
mutableNu now an officially supported API!Original post -
...the biggest changes to the API would be that property setters no longer return the World value. Getters and setters will still take a World value (since their backing data will and should continue to live inside the World data abstraction), but there wouldn't be a need to return a World value anymore from setters and most other functions.
Other than that, the only thing needing to change would be to make an imperative Undo / Redo system. Presumably MMCC would go away as well? Well, no, it would stay around so long as the user's models remain functional, interestingly. Otherwise is would be a pretty straight-forward overall effort.
This discussion is effectively a continuation of the blog entry here - https://vsynchronicity.wordpress.com/2025/03/22/jon-blows-seeming-dismissal-of-functional-game-programming/
Beta Was this translation helpful? Give feedback.
All reactions