7 ms·
I'm afraid the memory management scheme might cause the Nimrod ecosystem to end up with too many libraries that require GC, and since the building blocks are al
by eudox 12y ago
I'm afraid the memory management scheme might cause the Nimrod ecosystem to end up with too many libraries that require GC, and since the building blocks are already using it, why not use it yourself?
Either make it fully manual, or do something like Rust (No small feat). A GC you can switch on and off sounds like a good idea, but programmers don't keep half the promises they make ("It's just an MVP, I'll refactor it to use manual memory later").
- charlieflowers 12y agoStill, there are times when GC is fine for a particular application. In those cases, Nimrod is pretty fantastic, especially given its metaprogramming capabilities.
- def- 12y agoAlso, the GC can be controlled, so you can set exactly when it is allowed to run, something like this for a game: gcDisable() while true: gameLogic() renderFrame() gcStep(us = leftTime) sleep(restTime) http://nimrod-lang.org/gc.html http://nimrod-lang.org/gc.html
- FnuGk 12y agoThen what happens if the GC keeps taking longer than the allowed time? Will it then not keep allocating more and more memory that will never be freed?
- def- 12y agoI guess so. This is only viable if you have enough time for garbage collection.
- camperman 12y agoNimrod's pointers to garbage collected memory are separate from the pointers you can allocate yourself. So you could do manual memory management on the parts that really need it - say for a game in a tight loop - and leave the collector to worry about the smaller and less time-critical stuff. Also the GC is only triggered on a memory allocation. It doesn't run in a background thread or anything like that. So if the GC fails, then the allocation of memory fails (as I understand it) which means your scenario would be caught early.
- Dewie 12y ago> Nimrod's pointers to garbage collected memory are separate from the pointers you can allocate yourself. Does this mean that they use different heaps?
- mcguire 12y agoLikely, yes. (Welcome to real-time programming; if you don't keep track of your time-budget, you're gonna have a bad day.) I haven't looked at Nimrod's GC, but I believe it's indeed incremental; it won't take more time than you give it, but it will leave things uncollected if you don't give it [enough] time.
- sitkack 12y agoin a game, detect gc pressure and schedule some slo mo candy to use as gc cover.
- rbehrends 12y ago> I'm afraid the memory management scheme might cause the Nimrod ecosystem to end up with too many libraries that require GC, and since the building blocks are already using it, why not use it yourself? And what would be the problem with that? The number of application domains where even soft real-time GC is inappropriate is very, very small. And designing freedom from garbage collection into a language (other than the simple option of allowing manual allocation/deallocation) is not cost-free, either, and can weigh down the design, too. You can optimize your language design for having garbage collection or for not having garbage collection, but if you try to do both at once, a language design that specifically favors one or the other will likely beat out the compromise solution for the case it's optimized for. And yes, that means that Nimrod (or any other language) won't be perfect for everything under the sun. Which is fine: there's nothing wrong with having multiple programming languages, each of which is better suited for a different task.
- audunw 12y agoNo, I think Nimrod's approach is absolutely correct. What I hope will happen is that once Nimrod's effects system matures, the compiler will be able to figure out when it can statically free references when they go out of scope, rather than always using the GC. Rusts approach, I think, is in the entirely wrong direction. You should only have one kind of reference, but if you use it correctly the compiler should figure out how to free it. You should then be able to make an assertion that a procedure (possibly "main") does not allocate any GC memory, and have the compiler tell you what part of your code violates this constraint.
- eudox 12y agoI agree in that I don't entirely buy Rust's approach, mostly because of the cognitive overhead that it puts on me, but I don't think it's plausible to think future changes to the compiler (Without the introduction of new constraints on the behaviour of pointers) will give us statically-determined deallocation points. If it were possible, it would have been done five years ago and merged into clang!
- pcwalton 12y agoIt's trivially impossible with unrestricted aliasing. No compiler can statically predict the properties of an unrestricted arbitrary graph about which, in the limit, absolutely nothing is known until runtime.
- TylerE 12y agoSo, because something doesn't work in some theoretical corner cases, it isn't worth bothering with at all?
- pcwalton 12y agoCreating arbitrary graphs in memory is not a "theoretical corner case". It corresponds to, for example, Graphviz reading in a graph from user input. Or, if you want something that could technically be done with manual memory management but might as well be an unrestricted graph for all any reasonable analysis could infer, creating a doubly-linked XML/HTML DOM.