I'm assuming you refer to my comment. I was reasoning about "why would you want to do that?" and OP clearly said "so that you don't need a runtime". My point was that *if that is the goal* GC and memory management are not the only things to reconsider, you would have to redesign the language from scratch (goroutine scheduler included).
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rusts concept of ownership is indeed powerful but it is a bit messy to wrap your head around. Maybe it gets easier with time, maybe some of the Servo devs are lurking on the list? I for one likes both the languages.
I knew that was coming. One question, are there cases of "escapes to heap" because we don't know what happens in called functions when we could know with bottom up instrumentation, such that the memory could be put on a delete now, or delete ASAP list?
I asked this a few years ago and the answer is that we're not that smart yet. Maybe we're close enough now.
The compiler already does that, it's called escape analysis.
Ian
We could implement a very restricted subset without a major change to
the language: if you have a pointer in a local variable, and you send
that pointer on a channel, then we could set the local variable to
nil. It might be interesting to see how many programs that would
break.
Ian
Gerard <gvds...@gmail.com> writes:
> Obviously you are right. Rust is however completely different and compared
> with Go it's highly complex.
I agree.
> The thing is, the ownership model is relatively easy to understand
> and, from a user perspective, easy to use.
I disagree.
I regard the ownership model of rust as the only thing preventing me
from using it, because it is *such a chore* to use. i.e. the complexity
of rust (as in, the cognitive overhead of using it) is about 80%
the ownership model for me.
So again, I think you should make clearer what your goals and
motivations are. Because to me it looks like you want to take the worst
part of rust and bolt it onto go, sacrificing the best part of go (its
simplicity and ease of use) in the process. And I don't understand why
you would rather reimplement complicated stuff for go, than rip out
stuff from rust, which sounds much easier to me. I'd think that if you
use rust without generics and algebraic datatypes and re-add libgreen
you have roughly the feature set of "go with the rust ownership model"
as a language (yes, there are still differences, but I would consider
them reatively minor). And you can probably start using that today.
That's not the thing and i am aware of that. The question is just what is required to implement the ownership model?
On Saturday, August 22, 2015 at 5:23:36 PM UTC+2, Roberto Zanotto wrote:You have a runtime for goroutine scheduling and for other things anyway. If you want you can take away GC form Go, maybe reflection also, then replace goroutines with system threads and maybe you don't have a runtime anymore. But those are really valuable things that make Go fun to write, easy to read and to maintain. If you want to go more low level you can use C or Rust, I bet that managing memory manually or having to make the compiler happy with memory ownership rules is not as fun and productive as having an efficient and concurrent GC.Also, the Go compiler and runtime are written in Go. What project are you working at that needs to be lower level than that?
On Saturday, August 22, 2015 at 5:07:21 PM UTC+2, Gerard wrote:The reason is to not have GC so that it would be more "low level" and you don't need a runtime.
On Saturday, August 22, 2015 at 3:43:52 PM UTC+2, Egon wrote:
On Saturday, 22 August 2015 15:25:57 UTC+3, Gerard wrote:
This is not a request! It's just a question.
What would be required to implement the Rust ownership model into Go? Syntax not much I think. Obviously a different compiler (probably LLVM) and new filename extensions. Also the functions that change a parameter should have this parameter prefixed with the keyword var. Also the C FFI would be changed and the Go FFI changed as well, since the code generates non-GC code. "Green threads", the key feature of Go, needs to be altered as well, possibly even removed. But what else?
Again, this is just a question because I am curious.
What would be the reason for including the ownership model? And how much of the ownership model? AFAIK the Rust ownership model only deals with what you can do with the values and how you can pass them around.I suspect you could do a some part of the ownership checking as a static analyzer without changing the language or compiler. Probably you could add some constraints as comments (e.g. this value shouldn't be modified after this point).+ Egon