TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Lua: Good, Bad, and Ugly Parts (2012)

202 pointsby Svetlitskiover 3 years ago

16 comments

linkddover 3 years ago
Lua is a very nice piece of technology. Its source code is pretty easy to get into, the documentation is complete.<p>It has its quirks yes, but if I need to add scripting to a software, I&#x27;d consider Lua before considering writing a DSL, simply because you can pretty much embed Lua&#x27;s source in your C&#x2F;C++ software as a static library[0].<p>The stack-based approach makes it so easy to interact with C&#x2F;C++, and I&#x27;ve been looking at the Rust bindings[1] recently out of curiosity, looks promising.<p><pre><code> [0] - https:&#x2F;&#x2F;github.com&#x2F;lubgr&#x2F;lua-cmake [1] - https:&#x2F;&#x2F;github.com&#x2F;amethyst&#x2F;rlua&#x2F;blob&#x2F;master&#x2F;examples&#x2F;guided_tour.rs</code></pre>
评论 #29700533 未加载
评论 #29700544 未加载
评论 #29700230 未加载
评论 #29701820 未加载
评论 #29700947 未加载
leephillipsover 3 years ago
At first Lua seems strange, but after a while you start to appreciate it. It’s designed with a small number of concepts that manage to lead to expressive code with excellent performance.<p>I use it for two things: scripting TeX¹, where it allows you to do amazing things², even complex numerical calculations³ within the document; and writing Pandoc filters, where it is now the standard method.<p>1 ‘LuaTeX comes of age’. LWN. Available from: <a href="https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;731581&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;731581&#x2F;</a><p>2 <a href="http:&#x2F;&#x2F;wiki.luatex.org&#x2F;index.php&#x2F;TeX_without_TeX" rel="nofollow">http:&#x2F;&#x2F;wiki.luatex.org&#x2F;index.php&#x2F;TeX_without_TeX</a><p>3 <a href="http:&#x2F;&#x2F;www.unirioja.es&#x2F;cu&#x2F;jvarona&#x2F;downloads&#x2F;numerical-methods-luatex.pdf" rel="nofollow">http:&#x2F;&#x2F;www.unirioja.es&#x2F;cu&#x2F;jvarona&#x2F;downloads&#x2F;numerical-method...</a>
评论 #29703368 未加载
nerdponxover 3 years ago
I really appreciate that the article has a &quot;Different&quot; section for things that are <i>different from</i>, but not necessarily better or worse than, other programming languages.<p>This is also a very good summary, and tracks with my own experience getting into Lua for Neovim scripting.
评论 #29700569 未加载
BoogerDanover 3 years ago
Lua appeals to my sensibilites and I want to make use of it. It seems to be a well-designed language and it has a very performant JIT. But a big weakness for non-embedded use cases seems to be its ecosystem. A recent little project I wanted to use Lua on included a sqlite database, oldschool 3DES encryption, and an SMTP client. For many languages, there would be a clearly mob-approved library for each of these. But I found 3 or 4 possibilities to use sqlite in Lua, with no clear winner. I ended up using Ruby instead.
评论 #29702677 未加载
评论 #29706144 未加载
monatronover 3 years ago
I work on a project that leverages Kong&#x27;s API Gateway, which is essentially Nginx + Openresty (Lua) + Kong (More Lua). The killer feature wrt Kong is the plugin ecosystem, which (among other things) allows you to act on the request&#x2F;response lifecycle at various stages. Developers coming onboard to the project usually have little to no experience writing Lua, but we&#x27;ve found that coming up to speed on the language and it&#x27;s runtime to be fairly painless. These days Kong has shims to write plug-in code in a few different languages (javascript, python, go, and more recently a wasm runtime) but despite our teams unfamiliarity with the language we still go back to Lua because performance can&#x27;t be beat.
jonpalmiscover 3 years ago
I’ve had a very positive experience using Lua as an extension language.<p>I was writing a text editor at the time. I wanted as much of the core code&#x2F;actions to be written in Lua as possible, as I’ve always disliked very thin scripting APIs that sit on top of opaque native procedures.<p>I was able to wrap a handful of native functions in Lua code, then write the remaining 85% of the editor core in Lua. Everything was very fast and the process was straightforward. I’d definitely choose it again.
ufoover 3 years ago
Lua 5.4 now includes a short utf8 library in the standard library. It has ways ways to get the utf8 string length and regex patterns for utf8 codepoints. However, it doesn&#x27;t include any functionality that would require large tables of characters (for example, knowing which unicode characters are alphabetical).<p>-----<p>The requirement that return be the last statement is to avoid a syntactic ambiguity. Since Lua has no semicolons, there would be no way to know whether a line following the return statement is part of the return statement.<p><pre><code> return f()</code></pre>
评论 #29702582 未加载
kdheepakover 3 years ago
You can also write rust ( or go, or write in any other language that allows you to expose a C ABI ) and make a Lua module. This solves a number of the different, bad and ugly issues in my opinion. For example, I think using rust’s chrono or unicode_segmentation library makes life so much easier than having to deal with that in Lua. Neovim embeds lua 5.1 jit, and it’s possible to write plugins in rust for neovim using this mechanism.<p>For any one that knows what I’m talking about it should be obvious how to do this. If not, I wrote about this more here, in case you are interested:<p><a href="https:&#x2F;&#x2F;blog.kdheepak.com&#x2F;loading-a-rust-library-as-a-lua-module-in-neovim.html" rel="nofollow">https:&#x2F;&#x2F;blog.kdheepak.com&#x2F;loading-a-rust-library-as-a-lua-mo...</a>
1vuio0pswjnm7over 3 years ago
Could have sworn I saw this submission 4 days ago.<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;user?id=Svetlitski" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;user?id=Svetlitski</a><p>The timestamps next to the two oldest replies make it seem like they were more recently submitted, too. But I think they are 4 days old.<p>Seems like the title should be &quot;Lua: Good, Different, Bad and Ugly Parts&quot; as there is a fourth section, preceding &quot;Bad&quot;, in the blog post called &quot;Different&quot;.<p>Language wonks can endlessly dismiss Lua as a programming language, but it continues to be &quot;embdedded in&quot;, i.e., used to extend, useful network applications, e.g., dnsdist, haproxy, nmap. To learn to use the application to its fullest, one has to learn some Lua.
评论 #29700175 未加载
评论 #29700190 未加载
JonChesterfieldover 3 years ago
A missing &#x27;good&#x27; - the reference implementation is extremely easy to extend with existing C or lua libraries. E.g. embed sqlite.c and bindings to it and all of penlight (a bunch of standard library like utilities written in lua).<p>There are some package managers. However concatenating all the source plus a bunch of libraries into one .c file also works great, My bootstrap&#x2F;install is to clone that one file via git and feed it to clang.
dangover 3 years ago
A couple past threads:<p><i>Lua: Good, bad, and ugly parts</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6616817" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6616817</a> - Oct 2013 (19 comments)<p><i>Lua: Good, bad, and ugly parts</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5348513" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5348513</a> - March 2013 (110 comments)
erwincoumansover 3 years ago
It is nice small, so Lua even ran on Playstation 3 SPU!<p>We used to ship lua binaries for the premake build system.<p>For me, the indexed from 1 rather than 0 is a big turn off.<p>Roblox has the mlua fork, with increased performance and added type annotations: <a href="https:&#x2F;&#x2F;github.com&#x2F;Roblox&#x2F;luau" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Roblox&#x2F;luau</a>
评论 #29703167 未加载
chirszover 3 years ago
I hope something like `ArrayBuffer` and `TypedArray` would be added to Lua, like to JavaScript.
评论 #29701318 未加载
评论 #29700979 未加载
anonymoushnover 3 years ago
(2012)<p>&quot;lua 5.2 has no globals&quot; is a bit of a misleading takeaway from the getfenf&#x2F;setfenv changes in lua 5.2.
评论 #29705338 未加载
jbotzover 3 years ago
This is from 2012 (should say so in title).
daneel_wover 3 years ago
Plenty of good bullet points, but it&#x27;s now a quite outdated article. A lot has happened in Lua since 2012.