r/AskProgrammers • u/G_oni_vv • 6d ago
What if a programming language could intelligently manage its own memory and execution?
Similarly, imagine a graphics application where only one object changes. The runtime could identify which data actually needs updating instead of recalculating everything unnecessarily.
My goal isn't simply to create another garbage collector or claim that this will automatically outperform existing languages.
I'm exploring whether a programming language can make resource management more intelligent while keeping it automatic for the programmer.
I'd like to hear your thoughts:
Would combining adaptive memory management, predictive execution, and incremental processing make sense as part of a language runtime?
Or would you prefer these responsibilities to remain separate systems?
I'm particularly interested in the architectural trade-offs and potential problems with this approach.
View all comments
0
u/GiveMe30Dollars 6d ago edited 6d ago
I'll speak to the "automatic memory management" as pect of this since it's something I have related knowledge on, but just know that the trifecta of "automatic memory management, predicitve execution and incremental processing" is a massive hairball that you're asking the end-user to accept by default. These aren't unconditionally good, either: "incremental processing" (which I assume relates to incremental computation because what else can it be) means that you have to keep the incremental data around somewhere, for a "who knows?" amount of execution performance. You know, the thing that directly goes against intelligent memory management.
Your goal of:
Immediately presumes a global garbage collector, unless by "automatic resouce management" you're also including affine drop handlers eg. Rust. The "intelligent resource management" would then be an opportunistic optimization that is probably determined via syntax (eg. Local destruction for all owned items at the end of a scope).
The problem mostly boils down to:
Do you see now why most languages stick to one core memory management strategy, and have other strategies be opt-in via eg. specialized data structures?
The closest thing I know of that is spiritually similar to what you're proposing is Functional But In Place. That is still GC-dependent, just also has in-place destructive writing if the type system can assert that the handle to an object is unique upon write, and defaults to clone-on-write otherwise.
Honestly I don't quite get the motivation behind this question anyways. Memory management are such a pervasive concern in programming language execution that intentionally making it more complex it isn't going to lead to anything good for the end-user.