Live data from Hacker News

Goja: A Golang JavaScript Runtime

jtarchie.com

1–10 of 36 posts

Re: Goja: A Golang JavaScript Runtime

#2
This is the runtime pocketbase uses to allow javascript interop.

Pocketbase is the framework that makes me want to switch to golang. It just makes a lot of sense.

One thing that concerned me, though. How do I debug goja? It doesn't seem like I can set breakpoints as usual.

https://pocketbase.io/

Re: Goja: A Golang JavaScript Runtime

#3
In short: Goja is an ES5 interpreter written in pure Go and seamlessly integrating with it. You pass a struct, the JS side receives an object, you update it, and the Go side seamlessly gets an updated struct. No cgo overhead.

Re: Goja: A Golang JavaScript Runtime

#4

This is the runtime pocketbase uses to allow javascript interop. Pocketbase is the framework that makes me want to switch to golang. It just makes a lot of sense. One thing that concerned me, though. How do I debug goja? It doesn't seem like I can set breakpoints as usual. https://pocketbase.io/

Actually I decided to learn golang for extending using Golang for better DX (type hints and compiler errors)

Re: Goja: A Golang JavaScript Runtime

#5

This is the runtime pocketbase uses to allow javascript interop. Pocketbase is the framework that makes me want to switch to golang. It just makes a lot of sense. One thing that concerned me, though. How do I debug goja? It doesn't seem like I can set breakpoints as usual. https://pocketbase.io/

Actually I decided to learn golang for extending using Golang for better DX (type hints and compiler errors)

It's certainly a good idea to know golang while using something like pocketbase.

However, one of the strengths of pocketbase, I think, is that the creator chose to add bindings for a very well known scripting language (js) to allow projects to be rapidly developed. It feels like django rethought.

Using go for the base of your project and then gluing things together via scripting seems like a good idea. It's quite a big feature of the framework.

Re: Goja: A Golang JavaScript Runtime

#6
post #3

In short: Goja is an ES5 interpreter written in pure Go and seamlessly integrating with it. You pass a struct, the JS side receives an object, you update it, and the Go side seamlessly gets an updated struct. No cgo overhead.

It's definitely cool, and and accomplishment. I think it's a bit strange to compare it to "no cgo overhead" though

I say that because it's an interpreter rather than a jit, and doesn't have nearly as many person hours put into it as v8.

I can see the argument that if you just need to evaluate a quick expression or maybe some user supplied script or something, it could be very handy, but I have a hard time believing that the cgo overhead is a factor when using cgo to invoke v8 compared to the parse/jit overhead that v8 will do.

This is all armchair speculation of course. I use go regularly, but have no taste for javascript, so I have no dogs in that race. Definitely cool that there's an interpreter focused on correctness though.

Re: Goja: A Golang JavaScript Runtime

#8

Earlier quoted context omitted.

Actually I decided to learn golang for extending using Golang for better DX (type hints and compiler errors)

It's certainly a good idea to know golang while using something like pocketbase. However, one of the strengths of pocketbase, I think, is that the creator chose to add bindings for a very well known scripting language (js) to allow projects to be rapidly developed. It feels like django rethought. Using go for the base of your project and then gluing things together via scripting seems like a good idea. It's quite a b…

performance seems pretty solid too, removing one of my prime motivators for switching to Go for extension work. PocketBase just seems to have made a lot of great decisions based on the conceptual integrity of the project goals.

Re: Goja: A Golang JavaScript Runtime

#9
The examples in the article seem awfully contrived. Can someone please explain what a real-world use case for something like this would be? Why not just do it all in Go?

Or is the point of it to be able to use existing JS scripts within a Go application?

Post reply on HN