Show HN: CandyJS – transparent bridge between Go and JavaScript
github.com
github.com
But the main goal of the project is be fully transparent more than the performance. At the very beginning I was making every case by hand but this is a endless work: https://github.com/mcuadros/go-candyjs/blob/54c8beb723aa8b1b...
I will take a closer look to the NaN issue and also a closer look to your code.
BTW I made a PR to go-duktape based on you fork: https://github.com/olebedev/go-duktape/commit/65f0be48ece4f6...
As of integrating (some of) changes from my fork to the go-duktape mainline, thanks a lot! Didn't get around to do it myself.
CandyJS looks much simpler. Good work.
About the pool of workers, they share the stack? Or how you keep the same status on each.
The use case I had was along the lines of:
* Bind/Expose a bunch of Go functions to N JS worker contexts.
* Execute a large queue of JS-functions using the workers.
Spidermonkey did actually have a way to do a kind of shallow copy of a context and save/restore stack, which shared state, however this actually ended up making things much slower for my use as it required locking the threads and constantly copying stacks.What do you think are some of the pros/cons between Go and JavaScript? When would you prefer to use JavaScript instead of Go, or vice versa?
I think Go can be more performant than Node.js, but I remember seeing some conflicting benchmarks where V8 can actually manage more RPS.
The other thing that comes to mind is how React Native uses JavaScript to manipulate UI Components on iOS. If Google ever supports Go on Android, then this kind of thing could be pretty interesting.
A good example could be a chan bot in Go with plugins written on JS. (like https://github.com/djosephsen/lazlo) but with CandyJS the effort to make this will be minimal, since you can use the same structures on JS and Go.
About the performance, CandyJS javascript is much slower than pure Go, since the reflection is very expensive.
A small quick bench of this example: https://github.com/mcuadros/go-candyjs/blob/master/examples/...
Pure Go: 165951 requests
CandyJS: 36304 requests
That means that CandyJS is 4,5 times slower than pure Go. Both
With go-duktape, you can compile CandyJS just lake a normal Go package without any other tool or library.
Other reason is that many of the features are based on ECMA6 Proxy, something that is not supported on v8.
var engine = gin.default();
engine.get("/back", CandyJS.proxy(function(ctx) {
var future = time.date(2015, 10, 21, 4, 29 ,0, 0, time.UTC);
var now = time.now();
ctx.json(200, {
future: future.string(),
now: now.string(),
nsecs: future.sub(now)
});
}));BTW this behaviour is undocumented, I will fix that.