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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Lua is so underrated

321 点作者 nflatrea5 个月前

60 条评论

antirez5 个月前
Lua is great to embed, but for Redis I picked it as a scripting language with many regrets because I don't like the language itself: it looks almost like designed to have some kind of friction compared to what you expect to write in a language that is at the same level of abstractions. Little design decisions here and there that cumulate into a language that is somewhat hostile (for me, at least). Yet, it is so fast, easy to integrate, small footprint and reliable, that many times it is still the way to go. Btw, the hostility is present even at C-API level, with the stack approach: it's not rocket science but more cognitive load than needed. Even if I was exposed in the past to stack languages like FORTH, I still had to do some mental gym while writing the bindings. Why?
评论 #42522006 未加载
评论 #42521294 未加载
评论 #42521767 未加载
评论 #42521155 未加载
评论 #42527868 未加载
评论 #42521690 未加载
评论 #42521563 未加载
评论 #42554054 未加载
transpute5 个月前
If you like Lua, see Terra, <a href="https:&#x2F;&#x2F;terralang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;terralang.org&#x2F;</a><p><i>&gt; Terra is a low-level system programming language that is embedded in and meta-programmed by the Lua programming language.. Like C&#x2F;C++, Terra is a statically-typed, compiled language with manual memory management. But unlike C&#x2F;C++, it is designed from the beginning to be meta-programmed from Lua.. In Terra, we just gave in to the trend of making the meta-language of C&#x2F;C++ more powerful and replaced it with a real programming language, Lua.. Terra programs use the same LLVM backend that Apple uses for its C compilers. This means that Terra code performs similarly to equivalent C code.</i><p>From Pat Hanrahan&#x27;s research group at Stanford, <a href="https:&#x2F;&#x2F;amturing.acm.org&#x2F;award_winners&#x2F;hanrahan_4652251.cfm" rel="nofollow">https:&#x2F;&#x2F;amturing.acm.org&#x2F;award_winners&#x2F;hanrahan_4652251.cfm</a><p><pre><code> Hanrahan and his students developed Brook, a language for GPUs that eventually led to NVIDIA’s CUDA. The prevalence and variety of shading languages ultimately required the GPU hardware designers to develop more flexible architectures. These architectures, in turn, allowed the GPUs to be used in a variety of computing contexts, including running algorithms for high performance computing applications, and training machine learning algorithms on massive datasets for artificial intelligence applications. </code></pre> Papers: <a href="https:&#x2F;&#x2F;terralang.org&#x2F;publications.html" rel="nofollow">https:&#x2F;&#x2F;terralang.org&#x2F;publications.html</a>
评论 #42520541 未加载
评论 #42520145 未加载
评论 #42518588 未加载
评论 #42520725 未加载
opticfluorine5 个月前
Having just gone through the exercise of integrating Lua with a custom game engine over the past few weeks, I have to echo how clean the integration with other languages is.<p>It&#x27;s also worth noting that the interface is clean in such a way that it is straightforward to automatically generate bindings. In my case, I used a handful of Roslyn Incremental Source Generators to automatically generate bindings between C# and Lua that matched my overall architecture. It was not at all difficult because of the way the interface is designed. The Lua stack together with its dynamic typing and &quot;tables&quot; made it very easy to generate marshallers for arbitrary data classes between C# and Lua.<p>That said, there are plenty of valid criticisms of the language itself (sorry, not to nitpick, but I am really not a fan of one-based indexing). I&#x27;m thinking about designing an embedded scripting language that addresses some of these issues while having a similar interface for integration... Would make for a fun side project one of these days.
评论 #42518912 未加载
评论 #42518883 未加载
评论 #42520353 未加载
Levitating5 个月前
I can&#x27;t say I appreciate Lua any more after reading this. It only reinforced my annoyances with it.<p>It&#x27;s been a while since I wrote any Lua but I didn&#x27;t think it was intuitive at all. Why are arrays tables, why are they nil terminated and why do they start at 1.<p>I don&#x27;t think it&#x27;s underrated either. It&#x27;s very popular for writing scripts in (older) game engines.
评论 #42519174 未加载
评论 #42517312 未加载
评论 #42521623 未加载
评论 #42517261 未加载
评论 #42517299 未加载
fsmv5 个月前
I built a chatbot with lua plugin commands and I really had an awful experience trying to incorporate it in my C++ program. I really don&#x27;t understand why people say it&#x27;s easy to embed because you have to do a ton of stack manipulation to do anything. Not only that but the language itself is cumbersome, frustrating, and does nothing at all to help you when you make a mistake.<p>I will never use lua again and avoid any project that uses it.
评论 #42518741 未加载
评论 #42518680 未加载
评论 #42518719 未加载
评论 #42518853 未加载
评论 #42518814 未加载
评论 #42518700 未加载
bvrmn5 个月前
It&#x27;s hard to use lua for any sizeable chunk of code due to weak typing, absence of type hints and error handling. No it&#x27;s not underrated in any way.<p>It&#x27;s funny how through the years I&#x27;ve started to appreciate statically typed languages and type hints (Python, TypeScript) as well. Up to my current stance: it&#x27;s a disservice for a community to write hintless python or js code.<p>P.S. Recently I&#x27;ve rewritten 1.5k cloc of JS into TypeScript. As usual there were dozens of cases of missed nulls, null attribute accesses or semantically questionable nulls.
评论 #42518924 未加载
评论 #42520333 未加载
评论 #42518901 未加载
评论 #42518838 未加载
aeturnum5 个月前
I have really enjoyed working with Lua when it&#x27;s come up and I think it&#x27;s an extremely good language. In particular, as Noë says, its interface for embedding into C&#x2F;C++ is clean and flexible. There are performance concerns, but considering how widely Lua is used for game logic in high performance video games clearly those concerns can be addressed.<p>That said, I think there are other warts that can be confusing and make the language difficult. The <i>Nil-Terminated Arrays</i> section points out one oddity about `nil` - but there are many others. There are a number of confusing corner cases (or were - I haven&#x27;t used it in a while). As an example, if you have a list of values and you pass that list into a new table, the resulting table may be different than if you add each value in that list in order.<p>I also think that the flexibility of embedding means that you are often learning the Lua &lt;=&gt; C interface as much as you are learning Lua. So jumping from deploy to deploy is more confusing than most languages.<p>Nevertheless I fully agree the language is underrated!
评论 #42517537 未加载
评论 #42517256 未加载
pavlov5 个月前
My humble opinion is that most applications that need scripting should just embed JavaScript.<p>It has a massive advantage in the existing ecosystem. People don’t always love it, but millions of them already know it. You don’t need to re-learn array indexing and nil termination quirks and the dozens of other things where Lua is subtly different in ways that you’ll find out at runtime.<p>There are JS engines in all sizes, from tiny interpreters to world-leading JIT performance monsters. And most operating systems nowadays ship with a high-quality engine and embedding framework that you can access without installing anything, like JavaScriptCore on the Apple platforms.<p>Do your users a favor and just use the boring standard language instead of making them learn a completely new one that doesn’t offer meaningful practical benefits for them. It’s probably not as much fun for you, but you’ll save time for both the users and yourself in the end.
评论 #42517273 未加载
评论 #42518801 未加载
评论 #42517283 未加载
评论 #42530030 未加载
评论 #42517302 未加载
评论 #42518938 未加载
评论 #42521553 未加载
评论 #42517311 未加载
评论 #42518510 未加载
hipadev235 个月前
Luau [1] developed by Roblox is a backwards-compatible fork of Lua 5.1 with some very significant improvements to speed and QoL [2]. It also mostly alleviates the nil-terminated array problem.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;luau-lang&#x2F;luau">https:&#x2F;&#x2F;github.com&#x2F;luau-lang&#x2F;luau</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;luau-lang&#x2F;rfcs&#x2F;tree&#x2F;master&#x2F;docs">https:&#x2F;&#x2F;github.com&#x2F;luau-lang&#x2F;rfcs&#x2F;tree&#x2F;master&#x2F;docs</a>
评论 #42522961 未加载
01HNNWZ0MV43FF5 个月前
I&#x27;ve had fun embedding Lua a couple times, but as with wasm I almost never have a case where I need to run new code without being able to recompile the whole binary, so I don&#x27;t get to use it often.<p>The most fun was when I made a game engine (&quot;engine&quot;) in C++ that used Lua for all the game logic. The fast debug cycles are very useful there. Maybe I should still do that for Rust gamedev, since Rust notoriously compiles slowly.<p>The second-most fun was an IRC bot that could reload its Lua logic without disconnecting. Nowadays I&#x27;d write a bouncer and just let the main process restart. (Or use wasm, a wasm IRC bot would be good...)<p>The third-most fun was using Lua as a Turing-complete configuration language. If I needed an array of something, I just made Lua make an array, instead of generating Lua code.<p>One of the least fun was the Blender plugin that exported 3D models as generated Lua. If I did that one again today, I&#x27;d just use MsgPack or some ad-hoc binary format.
ternnoburn5 个月前
Lisa is deeply, deeply overrated, ime. But I&#x27;m coming from the games industry where it&#x27;s widely used.<p>The only benefit of Lua ime is the ease at which it embeds in C++. Beyond that, it&#x27;s a nightmare.
评论 #42518747 未加载
lopatin5 个月前
I think it&#x27;s a stretch to call it underrated. Isn&#x27;t it the defacto language for embedded scripting stuff? I&#x27;ve seen it used as a mini language in production in game engines, databases, and trading systems.<p>On the other hand, if the article is saying that it deserves to be more highly rated in the non-embedded space, I think I would need more than a handful of syntactical niceties to explain why it deserves to be in the same conversation as Python, Ruby, etc...
评论 #42517244 未加载
Animats5 个月前
Except for &quot;tables&quot;. Lua tables are too weird. Trying to make one construct do the work of an array, a struct, and a dict leads to a messy construct.
评论 #42519224 未加载
评论 #42518281 未加载
YoshiRulz5 个月前
There are a lot of good comments here already, but I can&#x27;t let this pass by the main page without taking the opportunity to rail against Lua because, no, it&#x27;s not underrated. It&#x27;s everywhere and terrible.<p>This article is fairly light on detail, only mentioning a couple table footguns, but there are MANY more. (I also disagree with it being &quot;accessible even for beginners&quot;, but I&#x27;ll stick to objective things.) For starters, the size operator `#` doesn&#x27;t work on map-like tables, and there&#x27;s no easy way to copy part or all of a table, or to serialise one for printing.<p>Lua doesn&#x27;t have `switch` or even `break`&#x2F;`continue`. Though it added a `goto`—years after we collectively realised that&#x27;s an antifeature. You can use `and`+`or` as a ternary, but you need to remember that it works differently with bools and that `nil` is falsey ofc. And `0` is truthy. Using a variable which hasn&#x27;t been declared yet or is otherwise out of scope gives `nil` rather than an error. In fact most logic errors are SILENT (yay dynamic typing), and some syntax errors are raised far from the actual cause. `&lt;const&gt;` isn&#x27;t.<p>Before Lua 5.3, all numbers were floats. The patterns used for `string.match` look superficially like RegEx but they are not, despite them predating Lua. The stdlib is woefully lacking, with the official documentation seeming to taunt you with examples of how several common functions could be implemented, but it&#x27;s left to you to copy them into your projects.<p>So yeah, Lua might be small and quaint, but that&#x27;s only because so much is not included &quot;in the box&quot;, and what is included is no good.
tga5 个月前
Mandatory plug for Redbean[0], a standalone Lua webserver (a single-file that runs natively on six OSes!), and Fullmoon[1], a web framework built on top of it.<p>Not exactly mainstream, but so simple and elegant.<p>[0] <a href="https:&#x2F;&#x2F;redbean.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;redbean.dev&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;pkulchenko&#x2F;fullmoon">https:&#x2F;&#x2F;github.com&#x2F;pkulchenko&#x2F;fullmoon</a>
jdblair5 个月前
Lua fits the same niche as Tcl, but the runtime is smaller and way better. Tcl started as a simple, embeddable scripting language (and low performance, it was just string substitutions!) and evolved into Tcl8, a mostly backward compatible object system after successive iterations to improve its performance and expressiveness. &quot;everything is a table&quot; gets you pretty far in Lua, in much the same way that &quot;everything is a list&quot; in lisp, and was a much better abstraction than Tcl&#x27;s &quot;everything is a string.&quot;<p>When I last used Lua professionally (10 years ago) I did discover some foot-guns related to the handling of NULL &#x2F; nil in the LuaSQL module. The Lua array length function was based on nil-termination, so a NULL value in a column could cause issues. Maybe this has been fixed by now?
pshc5 个月前
Lua as a language is pretty warty, with some obvious omissions. But it’s widespread as an embedded language, and has been around a long time, and I think that tends to give it a nostalgic halo effect.<p>I would like to see more minimalist scripting languages with modern sensibilities replace it.
habibur5 个月前
Add, no way to determine size of Array, which is the primary data structure anyway.<p>No item.length propery.<p>You might decide to count with foreach(), but that will terminate when it encounters the first value in the array that is NULL.
评论 #42519807 未加载
评论 #42520319 未加载
soapdog5 个月前
Really liked that post, then again Lua is one of my favourite languages.<p>I wrote this post <a href="https:&#x2F;&#x2F;andregarzia.com&#x2F;2021&#x2F;01&#x2F;lua-a-misunderstood-language.html" rel="nofollow">https:&#x2F;&#x2F;andregarzia.com&#x2F;2021&#x2F;01&#x2F;lua-a-misunderstood-language...</a> some time ago and it kinda touches similar points as the OP. Read on if any of yous want to see yet another person talking about Lua.
hprotagonist5 个月前
especially with fennel on top, i can certainly see the uses and appeal!<p>coming from mostly python, i miss a robust stdlib.
评论 #42517493 未加载
K0IN5 个月前
I used Lua the first time in Garry&#x27;s mod, and I had a absolute blast, was my first real programming language, I can vouch, it&#x27;s easy to pick up :) I also must admit, the gmod lua extension (glua) was so much more enjoyable, that since then I keep my own lua version with patched ! for not and != as alternative for ~= (Luas way for not equal)
评论 #42520904 未加载
keb_5 个月前
I love Lua as a language; even if it can be a bit cumbersome at times, its simplicity and low barrier of entry is refreshing. I&#x27;m currently building a full-stack web application with <a href="https:&#x2F;&#x2F;redbean.dev" rel="nofollow">https:&#x2F;&#x2F;redbean.dev</a> in Lua and it&#x27;s mostly been a joy.
thunkle5 个月前
I&#x27;ve been writing lots of lua recently. The only two things that bother me are indexes starting at 1. It&#x27;s made my 2d grid math more complicated. I also don&#x27;t like how I have to write a goto statement if I want to continue&#x2F;next inside a loop. Other than that I love the simplicity.
gustavopezzi5 个月前
Lua is a great language for extending systems and very high-level scripting. I like it. I had the pleasure of teaching a module in 2020 together with Roberto Ierusalimschy where we used Lua and LPeg to teach students how to write a simple programming language. It was a very fun class.
ashdnazg5 个月前
In the Spring&#x2F;Recoil RTS game engine[1] we adapted Lua to have deterministic execution allowing synchronous multiplayer simulation. In addition we relatively easily implemented a precise[2] serialization of the Lua VM, allowing us to support save&#x2F;load for games with no code required from their side.<p>In other languages these would require much more effort.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;spring&#x2F;spring">https:&#x2F;&#x2F;github.com&#x2F;spring&#x2F;spring</a> or <a href="https:&#x2F;&#x2F;github.com&#x2F;beyond-all-reason&#x2F;spring">https:&#x2F;&#x2F;github.com&#x2F;beyond-all-reason&#x2F;spring</a> (yay for forks!)<p>[2] Preserving the order of iteration on items in a hash table after deserialization and further manipulations.
jezek25 个月前
If you like how easy is to embed Lua but not liking it&#x27;s syntax or features you can try FixScript.<p>It&#x27;s a language I&#x27;ve created that has C-like syntax, the implementation is a single .c file. It&#x27;s unique feature is an ability to arbitrarily extend the syntax (in fact classes and the type system is implemented as a library). This can be used for specific needs of your project.<p>It has also an ability to have time limits for execution and is able to reload scripts in place for live code updates. It also has a JIT by default.<p>More information here: <a href="https:&#x2F;&#x2F;www.fixscript.org&#x2F;blog&#x2F;introduction" rel="nofollow">https:&#x2F;&#x2F;www.fixscript.org&#x2F;blog&#x2F;introduction</a>
pjmlp5 个月前
&gt; Lua is used in nvim for plugins since 0.5.0, you bet it&#x27;s efficient !<p>Not necessarily, plenty of editors have scripting options that aren&#x27;t going to win any performance price.<p>Also VI architecture goes back to the days of single digit MHz.
miohtama5 个月前
I guess one of the issues is that because Lua is tailored for embedded use case, it lacks appeal as a general purpose software development ecosystem and thus its usage is marginal.
评论 #42517211 未加载
enduranceX5 个月前
I took Roberto&#x27;s awesome &quot;Building a Programming Language&quot; course in 2022 and during a live class I had the opportunity to ask why they don&#x27;t incorporate more stuff into the language. He said that it was designed to be lightweight, effective and simple. Anything that goes against those principles should not be integrated into Lua&#x27;s codebase.
jhoechtl5 个月前
Lua as a language is underrated, yes. Lua as the implementatation of PUC Rio is what it is. It misses abstractions in the runtime to make it pre-emptive and parallel. It is also somewhat telling that Mike Pall despite his come back announcement didn&#x27;t deliver.<p>It comes with batteries but they only fitt into one brand well. Compare this to eg golang or Python.
cromantin5 个月前
The best way to use Lia is using Typescript - <a href="https:&#x2F;&#x2F;typescripttolua.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;typescripttolua.github.io&#x2F;</a><p>We have huge Lia codebase for game client and game server shared code all written in typescript. Our developers only see lua if something does not work and it’s not often.
jmclnx5 个月前
Lua can be used to access the NetBSD kernel, which is interesting. I have said it before, I should spend time learning Lua.
评论 #42519600 未加载
EGreg5 个月前
Is Lua currently even faster than JS and PHP, after all the effort that went into those languages’ optimizations?
评论 #42517259 未加载
评论 #42518508 未加载
aulisius5 个月前
I recently came across TypescriptToLua[0] which has improved my experience of writing Lua manyfolds. No more having to deal with 1-based indexes or lack of type hints.<p>[0] - <a href="https:&#x2F;&#x2F;typescripttolua.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;typescripttolua.github.io&#x2F;</a>
dr_kiszonka5 个月前
It looks like Lua&#x27;s conditionals, for loops, and function definitions terminate with the &quot;end&quot; keyword. Is this considered more readable or does it bring some other benefits besides helping the interpreter parse code?<p>Many people love Lua, so I suspect there is a good reason for this.
评论 #42518940 未加载
评论 #42517324 未加载
评论 #42517491 未加载
fire_lake5 个月前
Indexes should start at one in all languages IMO.<p>The zero thing is a historical quirk due to pointer arithmetic.
评论 #42522945 未加载
arccy5 个月前
Lua is nice but it being embedded in many different places means that there will often be environment specific context that&#x27;s injected for you to interact with, but any editor tooling won&#x27;t know what&#x27;s injected
评论 #42517288 未加载
评论 #42518397 未加载
owenthejumper5 个月前
The article doesn&#x27;t mention some of the most famous Lua cases out there: Roblox used it for game developers, HAProxy uses it for extending the LB, and others.
liberix5 个月前
Maybe it&#x27;s time to check out Luon [1], which has a syntax similar to Oberon and takes some concepts from Lua, it&#x27;s statically typed and targets the LuaJIT VM. It was recently covered in HN [2]<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;rochus-keller&#x2F;Luon&#x2F;blob&#x2F;master&#x2F;Readme.md">https:&#x2F;&#x2F;github.com&#x2F;rochus-keller&#x2F;Luon&#x2F;blob&#x2F;master&#x2F;Readme.md</a> [2] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42413343">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42413343</a>
xedrac5 个月前
My complaints with Lua are mostly superficial, but they irk me nonetheless. So if I have to use it, I&#x27;ll usually opt for Fennel.
ouraf5 个月前
I wonder how viable is Lua for a full stack application or webpage.<p>It has a very barebones standard library by design
shmerl5 个月前
I started using Lua for Cyberpunk 2077 mods and neovim configuration, it&#x27;s fun to use.
IYasha5 个月前
Scripting language with the worst syntax I&#x27;ve seen so far.
orthoxerox5 个月前
I like Lua. It&#x27;s a saner version of JS with much fewer warts. However, JS has a massive, enormous, insurmountable advantage in popularity. If I need an embeddable scripting engine in 2025, I will most likely go with JS.
cyberpunk5 个月前
Doesn’t lua use 1 indexed arrays? Breaks my brain.
评论 #42521535 未加载
synergy205 个月前
i wish luajit has been actively evolving though
评论 #42517241 未加载
评论 #42518073 未加载
eviks5 个月前
&gt; The one that bothers me the most, might be the fact that arrays (tables used as arrays) are nil-terminated, meaning the end of the array is marked by a nil value<p>This alone should underrate the language even more so that no poor user is exposed to this kind of nonsense
up2isomorphism5 个月前
Until its array start from 1.
cute_boi5 个月前
I feel Scala is also very underrated.
评论 #42517375 未加载
booleandilemma5 个月前
The 1-based indexing feels too icky to me. It was a language designed for non-programmers and it shows, imo.
评论 #42519101 未加载
kragen5 个月前
I feel like, except for small size, this post doesn&#x27;t really get into what I like about Lua, which is pretty unfortunate. Lua deserves a better case than this.<p>I&#x27;m maybe not the best person to write this because I&#x27;m not really a huge Lua fan. Though on projects with others I&#x27;ll use whatever language they&#x27;re using, left to my own devices, I probably write about 3× as much JS as Lua, about 32× as much Python as Lua, and about 20× as much C as Lua.<p>But Lua has some really nice attributes.<p>It&#x27;s a pretty reasonable very-high-level language comparable to Python, JS, Groovy, Perl, or Clojure. You can get a lot done in very little code. You don&#x27;t have to crank out piles of boilerplate the way you do in Java or sometimes C. It comes with concise and readable syntax, flexible data structures, garbage collection, strong dynamic typing, list structure, hashmaps, dynamic method dispatch, inheritance, operator overloading, cooperative multithreading, eval, exception handling, namespaces, closures with lexical scoping, etc. Its documentation is first-class. Most of this is pretty much standard for the dynamic-language category nowadays; there&#x27;s not much special in here to pick one language from the category over another.<p>Lua&#x27;s biggest advantage is that LuaJIT is <i>motherfucking alien technology from the future</i>. I wrote a straightforward escape-time fractal renderer in <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;kragen&#x2F;bubbleos&#x2F;-&#x2F;blob&#x2F;master&#x2F;yeso&#x2F;mand.lua" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;kragen&#x2F;bubbleos&#x2F;-&#x2F;blob&#x2F;master&#x2F;yeso&#x2F;mand.l...</a> with a dynamic function invocation in the inner loop (to switch between fractals) and LuaJIT&#x27;s trace compilation just compiles that right out. There&#x27;s also a real-time animated raymarcher in that directory in LuaJIT, though the framerate and resolution are pretty bad. You can literally just write high-level code at like a Python or JavaScript level and, as often as not, it just goes faster than C. (Sometimes it doesn&#x27;t. JIT compilers are unpredictable and sometimes disappointing.)<p>Now, probably somebody is going to reply to this and tell me that everybody runs JS in JIT compilers too, so this isn&#x27;t a real difference. Unfortunately that&#x27;s horseshit. I&#x27;m sorry, but V8 and SpiderMonkey are just not in the same league, though not because their implementors are less brilliant. They&#x27;re just attempting a much harder job, because JS is a much hairier language. Consequently their performance is an order of magnitude worse.<p>(Even regular non-JIT Lua is a lot faster than most other very-high-level languages, almost to the level of JS JIT compilers.)<p>LuaJIT&#x27;s C FFI is also just ... there&#x27;s no expression in English sufficiently emphatic to express how great it is. The expression I&#x27;d normally use translates literally as &quot;it&#x27;s a very child of ten thousand whores,&quot; which hopefully conveys some of the emphasis if not the content. Here&#x27;s the FFI binding for Yeso, the graphics library used for the above fractal demo: <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;kragen&#x2F;bubbleos&#x2F;-&#x2F;blob&#x2F;master&#x2F;yeso&#x2F;yeso.lua" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;kragen&#x2F;bubbleos&#x2F;-&#x2F;blob&#x2F;master&#x2F;yeso&#x2F;yeso.l...</a>. Yeah, just by pasting the relevant lines from a C header file into your Lua program, you can call C code from a shared library as if it were Lua code. It&#x27;s almost as easy as calling C code from C++!<p>After getting screwed over (along with everybody else) by the Python community&#x27;s gratuitous and ongoing breakage of backward compatibility, coupled with public shaming to persuade <i>more</i> people to break backward compatibility, the Lua community&#x27;s approach to backward compatibility is looking pretty appealing. The vibe is that old versions of the language live forever, and you should keep using them instead of upgrading, but new versions usually aren&#x27;t compatible. However, it&#x27;s much easier to make a Lua library compatible with every existing version of Lua 4 and Lua 5 than to make a Python library compatible with <i>any</i> version of both Python 2 and Python 3.<p>Being small, fast, and implemented purely in portable standard C makes it practical to run Lua even on larger microcontrollers like the ESP8266, even when they use weird CPU architectures. Even interactively. <a href="https:&#x2F;&#x2F;github.com&#x2F;nodemcu&#x2F;nodemcu-firmware">https:&#x2F;&#x2F;github.com&#x2F;nodemcu&#x2F;nodemcu-firmware</a><p>LuaJIT is much less portable than PUC Lua, and also more than twice the size, about 580kB on my machine. This is still orders of magnitude less than something like Python or the JRE.<p>Lua is a little more annoying than Python or node.js to develop interactively with, but it&#x27;s overall pretty comparable. For code I&#x27;m writing myself (as opposed to getting from a library) the Lua version usually ends up being just a little bit bigger than the Python or JS version. Lua is more bug-prone, though, due to a number of language design flaws.<p>Lua is a very newbie-friendly language, I think even more so than JS or current Python. It&#x27;s very successful in systems aimed at beginning programmers, like Minetest (Luanti), World of Warcraft, and LÖVE2D. The barrier to entry is very low; you don&#x27;t have to be learning the GUI of a new IDE at the same time that you&#x27;re learning the programming language and, possibly, how to program. The standard library is small rather than overwhelming. And the download for standalone Lua development is tiny.
评论 #42519415 未加载
aaroninsf5 个月前
Did they ever fix the 1-index thing?
pdimitar5 个月前
No transparent parallelism? And no, I don&#x27;t mean threads.<p>Underrated? Eh... it does stuff better than others but that doesn&#x27;t mean much.<p>We really don&#x27;t learn.
评论 #42519325 未加载
wruza5 个月前
Lua is not underrated. It’s how many now, still 4(?) different languages which continue to suicide after a few years, all with cringe [re]design decisions, half-assed mechanics and lack of convenience that authors refuse to address. I spent many years on it (embedding, metaprogramming, all the deep things) and it is one of my biggest regrets in the choice of tech. The amount of effort you’ll put into not sliding out of this crazy ride nullifies all the promises of easyness, which is limited to trivial things anyway and explodes with complexity in any non-trivial data exchange. Its only upside is low footprint, but I fail to see where it matters today (apart from nodemcu whose active users could probably fit in one closet).<p><a href="https:&#x2F;&#x2F;github.com&#x2F;nodemcu&#x2F;nodemcu-firmware">https:&#x2F;&#x2F;github.com&#x2F;nodemcu&#x2F;nodemcu-firmware</a><p><i>Based on Lua 5.1.4 or Lua 5.3 but without debug, io, os and (most of the) math modules</i><p>As expected, they didn’t bother to support all versions and probably were done with it after 5.4 announcement.
评论 #42519417 未加载
评论 #42519423 未加载
评论 #42519458 未加载
评论 #42520293 未加载
评论 #42521338 未加载
helpfulContrib5 个月前
I was infected by the Lua mind virus 15 years ago and I have not recovered.<p>I simply don&#x27;t see any reason not to use it .. <i>for everything</i>.<p>I&#x27;ve built games with it. I&#x27;ve built GUI&#x27;s with it. I&#x27;ve built scientific analysis tools with it. I&#x27;ve used it as a total solution for previously-impossible embedded problems. I&#x27;ve used it for desktop applications and mobile apps. I&#x27;ve automated entire production lines with it. It has <i>huge</i> appeal as a general purpose software development ecosystem - but those who know how to do this, tend to keep it to themselves for some reason.<p>It can do everything.<p>There&#x27;s just nothing I want to do with computers that I can&#x27;t, legitimately do, with Lua - or its VM. Or, LuaJIT. Or, all of the above and a bit of luarocks built in. Throw some luastatic in while we&#x27;re at it, bundle it all up as a .deb, and nobody needs to know a thing.<p>Its just so versatile. I hope someone builds an OS around it some day, making everything and anything the user wants to do, accessible through a Lua module, or some smart libffi wrappers around a handful of .so&#x27;s, somewhere ..<p>In my retirement, I&#x27;ll take antirez&#x27; LOAD81, turn it into a proper Lua editor, add integration with luarocks and luastatic and maybe a shit-tonne of <i>IPFS</i>, and then there won&#x27;t be any need, ever again, to deal with anything else.
评论 #42518485 未加载
评论 #42521708 未加载
protomolecule5 个月前
It&#x27;s my language of choice for letting users customize an app, but the last client wanted Python because many people are already familiar with it and &#x27;Scriptable with Python&#x27; looks better from the marketing point of view(
beanjuiceII5 个月前
nah, it&#x27;s overrated ackshulaly
jmnicolas5 个月前
Meh. I don&#x27;t get the love Lua gets on HN. At least version 5.1, I didn&#x27;t try the others.<p>No first class support for OOP, you got to use tables instead.<p>No &quot;continue&quot; keyword to go to the next iteration of a loop. So you have to use some ugly elseif.<p>No try catch!<p>It&#x27;s a dynamic language so everything goes. A function will return nil or a number or whatever you wish. A function can also returns any number of variables, so obviously some moron will abuse it: looking at you Blizzard intern (you must have been an intern right?) that thought returning 20 variables on the combat event log was a good idea. Ever heard of tables???<p>The LSP can&#x27;t do miracles when there are almost no rules so auto-completion is more miss than hit, which is quite shocking in 2024. The IA is helpful sometimes but create subtle bugs some other times. A simple uncaught typo will create a hard to find bug (yesterday copilot auto-completed myObject.Id instead of myObject.id, there went 20 minutes of my life trying to find why some code that was running solidly for weeks was now failing silently).<p>So all in all, Lua is fine to write small imperative scripts of a few hundred loc. Anything bigger and more complex you should run away IMHO.<p>I never realized C# was such a well designed language until I tried Lua.
评论 #42518589 未加载
评论 #42519133 未加载
评论 #42519708 未加载
TekMol5 个月前
When it comes to languages, I was enlightended when I changed from {}; languages to Python. I could never go back.
评论 #42517216 未加载
评论 #42518638 未加载
评论 #42518428 未加载
pentaphobe5 个月前
Out of curiosity: does this post read like LLM (generated or assisted) to anyone else?
评论 #42518983 未加载
评论 #42518321 未加载
评论 #42517974 未加载