Several months back I remember reading a thread on here about Araq planning on adding a borrow checker. Is that still the plan? I don't really want Nim to have a borrow checker so I'm asking about this before I decide to invest more time into learning/using Nim.
Thanks!
@MrZoraman, Although there was some discussion on this forum in the past about making Nim a little safer as to controlling mutation, I don't think that it was @Araq who instigated the suggestions but rather others such as myself who thought it might be a good option to have so as to compete with languages that are regarded as "safe" such as Rust.
However, neither @Araq nor most of us here that suggested such an option want a "borrow checker" with all the syntax and rules such as Rust, and I don't think there is any way @Araq would approve such a change: he already laments the requirement of "newruntime" to have added "owned" key words at particular spots and regards that as one of the hold-ups to that concept, even if it can be made to work and accomplish its goals.
The form of "borrow checker" that I suggested would be built on tome of "newruntime" (when it works) and as suggested wouldn't require any more syntax changes that what are required to support it.
That said, we are up to version 1.0 and therefore there is a backward compatibility guarantee which would mean that any such additional features that would break current Nim would have to be optional so all current code would continue to compile and run.
That said, Nim already has an almost invisible form of "borrow checker" in Data Flow Analysis (DFA) as to the lifetimes of things that can be accessed so as to error out when it sees that something would be attempted to be accessed after its lifetime; that is one of the essential parts of what a "borrow checker" does, with the other being to prevent mutation of things by more than one "controller" at the same time; which is what my proposal for "newruntime" would attempt to extend it to do with (almost?) not cost in extra syntax .
Finally, both "--gc:destructors" and "--newruntime" are development features that are under development to check the feasibility of such schemes, with neither fully working nor any definite time frame for when either may be completed and accepted as main stream Nim.
For the above reasons, I wouldn't let rumors and FUD statements by others prevent you from exploring and using Nim in its current state of development, which is a very productive and useful computing language. The time "invested" in learning and using any computing language is almost always a net win even if you never use it for work related projects, as you advance as a programmer in learning other points of view.
For myself, if Nim ever adopts the form of "borrow checker" that Rust uses without options to not use it, I'm "out of here", as one of the reasons I am a fan of Nim as compared to Rust is its ease of learning and use. I think many here share my view (and yours).
Several months back I remember reading a thread on here about Araq planning on adding a borrow checker. Is that still the plan? I don't really want Nim to have a borrow checker so I'm asking about this before I decide to invest more time into learning/using Nim.
We have something resembling a "borrow checker" already, see https://nim-lang.org/docs/manual.html#procedures-var-return-type for the details, it's planned to expand this mechanism so that var T and openArray[T] can be put into objects/tuples/etc.
But it works differently enough from Rust that you cannot re-use your opinion of Rust and apply it to Nim.
You need to try Nim, there are no known shortcuts, it's a language of its own with its own idioms, strengths and flaws.
Furthermore, it seems like there will be an allocator API.
All in all, Nim may manage to meet the needs of 2 very different use-cases:
Even better, it may be able to mix both and still keep the developers happy: