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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Piccolo – A Stackless Lua Interpreter

269 点作者 vvoruganti大约 1 年前

9 条评论

vvanders大约 1 年前
&gt; ... and frankly I really like just plain vanilla Lua. I think it matches perfectly with Rust because they&#x27;re so different, I think having an Rust embedded language that frees you from even having to think about ownership is very powerful because it can be used for things where having to think about ownership can be more trouble than its worth. Let each language play to their strengths, and Rust and Lua in a lot of ways have complementary strengths.<p>Tons of awesome technical details in the post and I&#x27;ve always felt that Lua&#x27;s co-routines are incredibly undervalued. We used to run Lua in all sorts of crazy places and it really punches above its weight.<p>The above quote + zoom out at the end also makes some really good observations. Some of the most powerful systems I&#x27;ve worked on picked a couple core technologies that were complementary with good interop rather than a one-size fits all. Will be interesting to see where Piccolo goes.
10000truths大约 1 年前
&gt; However, piccolo works very hard to guarantee that piccolo::Executor::step returns in a bounded amount of time, even without the cooperation of the running Lua code.<p>The issue is that there exist ways to make a single bytecode instruction take an unbounded amount of time to execute. For example, Lua&#x27;s &quot;string.find()&quot; is implemented in native code. The interpreter only sees a single OP_CALL opcode, so it will count it as 1 instruction executed. But the <i>actual</i> execution time of the native implementation of string.find() is dependent on its inputs, which are not only variable length strings, but can be maliciously crafted to run in exponential time. Here&#x27;s an example, shamelessly stolen from Mike Pall himself:<p><pre><code> string.find(string.rep(&quot;a&quot;, 50), string.rep(&quot;a?&quot;, 50)..string.rep(&quot;a&quot;, 50)) </code></pre> The only way to solve this is to track execution time <i>within</i> the native code as well (i.e. make them fuel-aware), and ensure that they abort immediately if they exhaust the fuel.
评论 #40243646 未加载
wis大约 1 年前
I love how there are many Piccolo REPLs embedded in the article and interleaved with the paragraphs.<p>Piccolo looks amazing, I got a perfect use case for it, and I&#x27;m excited for when I get the chance to use it, thank you for working on it.
rnmmrnm大约 1 年前
A bit off topic: I just wrote a bunch of lua C debug api code (lua_sethook) to pre-emptively run and context-switch multiple lua &quot;coroutines&quot; (well not so &quot;co&quot;).<p>Is this library offering a lua implementation more well-designed for this use-case? I got all this code to unload the coroutine stack to store and and reload it before continuing it later. Does having C bindings to this library makes sense?
评论 #40240101 未加载
评论 #40240052 未加载
camgunz大约 1 年前
I really enjoyed the &quot;Zooming Out&quot; section, a lot of good food for thought in there.
klaussilveira大约 1 年前
I wonder if a Rust reimplementation of Lua will, one day, be faster than LuaJIT.
评论 #40241425 未加载
评论 #40240740 未加载
评论 #40242356 未加载
qudat大约 1 年前
I love the design of the website, nice work!
jxyxfinite大约 1 年前
Beautiful website! Would love to learn more about the stack
alberth大约 1 年前
Monospace font<p>Please don’t use monospaced fonts for long-form text.<p>It’s extremely different to read because your eye struggles to see the “shape” of each word, when everything is equally spaced apart.
评论 #40244959 未加载
评论 #40244561 未加载