3 ms·
This is a little experiment demonstrating the capabilities of the goscript project (https://github.com/oxfeeefeee/goscript https://github.com/oxfeeefeee/goscrip
by zackoverflow 5y ago
This is a little experiment demonstrating the capabilities of the goscript project (https://github.com/oxfeeefeee/goscript https://github.com/oxfeeefeee/goscript) by compiling it to wasm.
Here's the source code (https://github.com/zackradisic/go-playground-wasm https://github.com/zackradisic/go-playground-wasm) if you would like to look at it and do something similar with your own projects.
I'm really excited for the future of goscript, Go is a great candidate for a scripting language thanks to its minimalistic design choices.
- chabad360 5y agoGot to admit, I think "Rewrite it in Rust" has gone too far this time.
- edoceo 5y ago> Goscript > A script language like Python or Lua written in Rust, with exactly the same syntax as Go's. Strange things are afoot at the Circle K.
- rdrey 5y agoThanks. I've never seen Bill & Ted's Excellent Adventure and this comment lead me down a great little Internet rabbit hole
- zxcvbn4038 5y agoStop at the first movie, both the sequels are totally heinous.
- InvaderFizz 5y agoI enjoyed the newest one, but probably because it was dumb and nostalgic and I hadn't seen the original in twenty years.
- mappu 5y agoWhat GC is used in goscript? The upstream one, a Rust GC<> one, maybe the mini one from TinyGo, or something else custom?
- zackoverflow 5y agoI poked around earlier and found this file: https://github.com/oxfeeefeee/goscript/blob/master/vm/src/gc.rs https://github.com/oxfeeefeee/goscript/blob/master/vm/src/gc... Perhaps someone can shed more light on how exactly it works
- lelandbatey 5y agoFrom looking at it for like 20 seconds (I ain't no serious rustacean, so forgive if I'm wrong) I think they're using just a growable pool (as vectors) of each fundamental type in the Go language, then having each instance of each fundamental type be boxed in a Rc (reference counted) type so that they can count all references to each instance of each fundamental type.I believe that this can be used to get simple reference counting "for free" via the borrow checker of Rust. Probably many downsides, and apparently they don't yet implement GC of channels, but it seems like a nice straightforward way to get a script-ing/purely interpreted implementation of a language off the ground. The Rc module with the impl - https://doc.rust-lang.org/alloc/rc/ https://doc.rust-lang.org/alloc/rc/ Further docs on Rc- https://doc.rust-lang.org/book/ch15-04-rc.html https://doc.rust-lang.org/book/ch15-04-rc.html
- orsenthil 5y agoHow come this is so fast? I feel like the processing faster than I would get on an native compiled and run program. Are there any benchmarks?
- sudhirj 5y agoSpeculation here, but I think WASM lends itself very well to JIT compilation, and V8 has one of the best compiler teams in the world.