On 13-05-29 12:51 PM, John Mija wrote: > How could be integrated the Go language in Rust?
To embed a language, it generally needs to present a cdecl callable interface (= accept C callbacks), and be willing to schedule its coroutines and IO operations as steps within someone else's event loop. It will also need some form of marshaling of data values and/or mapping between types in the embedded and embedding languages; but that part is often the easiest part. Rust has been shifting[1] to a structure that permits embedding _Rust_ programs in others[2]; but embedding Go in Rust would be a different direction and probably requires work on Go's side. It seems someone is working on it[3] but I doubt it would be very easy today. > If somebody were to write a Go compiler to be integrated in Rust[1], > which path would be the best one? To create bindings to commands > [568][acgl] [2] or write the SSA library/interpreter [3] in Rust? That would be another option. I have no idea how mature those semantics are or the associated tooling. That route would probably run much more slowly; I suspect you'll have better luck trying to get the two runtimes to cooperate via linking. > What reasons could want somebody to use Go from Rust? > > + It could be used in programs where you want give power to users to run > some tasks, i.e. into a database; today, it's being added JS to some DBMSs Those contexts usually embed very lightweight / dynamic languages expressly for user convenience. Typical programs are one line, or even one expression long. They also tend to support runtime evaluation from strings, very loose typing, extending the type and value dictionaries at runtime, etc. Go, like Rust, was not developed with these pressures in mind, and I suspect it's not an ideal language in that sense. Though of course here we are on universal Turing machines, you're always free to use unusual tools for any given job. With enough effort you might be able to get it working. > + To Run web scripts in Go --into a fork of Servo-- which will allow > create powerful applications easily with a great performance and easily > of debugging. Similarly here, I think the "in a web page" environment is not terribly fertile soil for the Go semantics. Even setting aside the same argument above (most js programs, by volume, are probably onclick="" handlers and only a few expressions long) I think the backward compatibility issues -- your program now only runs in GoScript-aware browsers -- would limit applicability. It has been tried with quite a number of other languages, even nice small terse ones. In any case, this is getting far afield; this is rust-dev, not golang-nuts. If you want to try, I suspect your difficulties will emerge mostly on the "embeddable Go runtime" side, which we can't help you with. -Graydon [1] https://github.com/mozilla/rust/pull/5022 [2] http://brson.github.io/2013/03/10/embedding-rust-in-ruby/ [3] https://code.google.com/p/go/issues/detail?id=2790 _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
