TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Goja: A Golang JavaScript Runtime

111 点作者 mihaitodor8 个月前

9 条评论

nchmy8 个月前
I just dug through a lot of the issues and PRs in Goja, and eventually found that the grafana&#x2F;k6 team recently forked Goja as Sobek [1], because the Goja dev has not been able to dedicate sufficient time to their PRs - namely ES Modules support [2], which was one of the only modern (ES6+) JS features outstanding [3]<p>So, Sobek seems to be the way forward...<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;grafana&#x2F;sobek&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;grafana&#x2F;sobek&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;dop251&#x2F;goja&#x2F;pull&#x2F;430">https:&#x2F;&#x2F;github.com&#x2F;dop251&#x2F;goja&#x2F;pull&#x2F;430</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;dop251&#x2F;goja&#x2F;milestone&#x2F;1">https:&#x2F;&#x2F;github.com&#x2F;dop251&#x2F;goja&#x2F;milestone&#x2F;1</a>
评论 #41471099 未加载
评论 #41493107 未加载
alixanderwang8 个月前
I work on the D2 project ([0]) and we switched from other Javascript runners (v8go) to Goja. Using a JS runtime with a dependency on cgo means your Go program loses the (huge) benefit of cross-compiling to different architectures, since at build time it gets linked to the current system&#x27;s libc.<p>If you&#x27;re interested in some production code with Goja, this is our code for calling RoughJS ([1]) from Go in order to produce the hand-drawn diagram look: [2]<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;terrastruct&#x2F;d2">https:&#x2F;&#x2F;github.com&#x2F;terrastruct&#x2F;d2</a><p>[1] <a href="https:&#x2F;&#x2F;roughjs.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;roughjs.com&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;terrastruct&#x2F;d2&#x2F;blob&#x2F;master&#x2F;d2renderers&#x2F;d2sketch&#x2F;sketch.go">https:&#x2F;&#x2F;github.com&#x2F;terrastruct&#x2F;d2&#x2F;blob&#x2F;master&#x2F;d2renderers&#x2F;d2...</a>
评论 #41480776 未加载
nine_k8 个月前
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.
评论 #41470163 未加载
评论 #41469887 未加载
throwaway133378 个月前
This is the runtime pocketbase uses to allow javascript interop.<p>Pocketbase is the framework that makes me want to switch to golang. It just makes a lot of sense.<p>One thing that concerned me, though. How do I debug goja? It doesn&#x27;t seem like I can set breakpoints as usual.<p><a href="https:&#x2F;&#x2F;pocketbase.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pocketbase.io&#x2F;</a>
评论 #41477743 未加载
评论 #41468716 未加载
nchmy8 个月前
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?<p>Or is the point of it to be able to use existing JS scripts within a Go application?
评论 #41471346 未加载
评论 #41471094 未加载
评论 #41470710 未加载
评论 #41473027 未加载
评论 #41471862 未加载
评论 #41471441 未加载
评论 #41473876 未加载
bitwize8 个月前
You know, back when I got started as a Schemer, I remember people complaining about how many implementations of Scheme there were and how difficult it was to port between them. Today in JavaScript land we have Node, Deno, Bun, Goja, Sobek, Nashorn, whatever the browsers have, QML, GNOME, all of them subtly different. But instead of complaining, which people seem inclined to do when they encounter nested parens, people bro down and wrote code necessary to make them all interoperate if necessary -- despite JS having even less of a core language standard than Scheme does.<p>I guess it&#x27;s the Lisp Curse or something, I dunno.
donatj8 个月前
I&#x27;ve been a pretty happy Otto[1] user for a number of years now.<p>The article makes no comparisons seemingly? I don&#x27;t think there&#x27;s even a never. I find that pretty odd.<p>I&#x27;m curious if there&#x27;d be any reason to switch.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;robertkrimen&#x2F;otto">https:&#x2F;&#x2F;github.com&#x2F;robertkrimen&#x2F;otto</a>
评论 #41471085 未加载
dialogbox8 个月前
The name looks a obvious choice but... Ouch. It&#x27;s a very funny name for Korean. It means eunuch. Lol
评论 #41470405 未加载
评论 #41471103 未加载
评论 #41472105 未加载
siamese_puff8 个月前
Great article. I was looking for something like this last week.
评论 #41471161 未加载