Lua 作为嵌入式语言的替代品? [英] Alternatives to Lua as an embedded language?

查看:31
本文介绍了Lua 作为嵌入式语言的替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究在 DSP 上运行 Linux 的嵌入式系统.现在我们想让它的某些部分可以编写脚本,并且我们正在寻找一种很好的可嵌入脚本语言.这些脚本应该与我们现有的 C++ 代码库很好地集成在一起,而且要小而快.

I am working on an embedded system running Linux on a DSP. Now we want to make some parts of it scriptable and we are looking for a nice embeddable scripting language. These scripts should integrate nicely with our existing C++ code base, be small and fast.

我知道 Lua 是解决此类问题的行业选择.我们可能会选择 Lua,因为它经过验证并被证明是稳定的等等.然而,作为一种编程语言,它有一些相当古怪的角落.

I understand that Lua is the industry choice for problems like this. We will probably go with Lua because it is tried-and-true and proven to be stable and so on. However, as a programming language it has some rather quirky corners.

那么,可嵌入语言有哪些替代方案?

So, what alternatives are out there for embeddable languages?

这是大约一年后.

我们实际上在我们的嵌入式系统上使用了 Lua,它的表现非常出色.随着时间的推移,我们为项目的越来越多的部分添加了越来越多的脚本支持,这确实有助于实现它.

We actually used Lua on our embedded system and it performs marvelously well. Over time, we added more and more scripting support to more and more parts of the project and that really helped to bring it along.

性能非常出色,真的.即使涉及搜索长数组或花哨的字符串操作的相当复杂的操作也表现得非常好.我们基本上从来没有遇到过 Lua 相关的性能问题.

Performance is outstanding, really. Even rather complex operations that involve searching through long arrays or fancy string operations perform surprisingly well. We basically never ran into Lua related performance problems at all.

与 C 函数的接口非常简单,而且效果很好.这使我们能够轻松地扩展脚本系统.

Interfacing with C functions is very straightforward and works really well. This allowed us to grow the scripting system painlessly.

最后,我们对 Lua 的灵活性感到震惊.我们的 Lua 解释器必须在具有非标准内存分配器且不支持双数据类型的系统上运行.在一个头文件中有两个记录良好的地方,我们必须修改才能使 Lua 在该系统上运行.它真的很适合嵌入!

Finally, we were astounded at how flexible Lua proved to be. Our Lua interpreter has to run on a system with a nonstandard memory allocator and without support for the double data type. There are two well-documented places in one header file we had to modify to make Lua work on that system. It is really well suited for embedding!

推荐答案

既然你说嵌入式系统"、小而快"和很好地集成",我会说你是对的,Lua 是第一,如果不是唯一的选择.但我不再同意编程语言有古怪的角落".首先,Lua 编程这本书简直太棒了,是我读过的最好的书之一.其次,一些古怪的角落"来自这样一个事实,即语言非常正交和干净,从长远来看,这是一种资产,而不是缺点.我发现例如 JavaScript 更糟糕.如果您阅读Javascript the good parts",作者详细解释了为什么语言中的某些构造是设计错误以及为什么应该避免使用 new 运算符.在 Lua 中并非如此,坏的部分已被删除,例如古怪的 upvalue 内容在 5.x 版中被标准句法范围所取代.

Since you say "embedded system" and "small and fast" and "integrate nicely" I would say you are correct that Lua is the number one if not the only choice. But I no longer agree that the programming language has "quirky corners". Firstly, the book Programming in Lua is simply splendid, one of the best books I have ever read. Secondly, some of the "quirky corners" come from the fact that the language is very orthogonal and clean, which in the long run is an asset, not a drawback. I find for example JavaScript much worse. If you read "Javascript the good parts" the author explains in length why some constructs in the language are design mistakes and why one should avoid the new operator. Not so in Lua, the bad parts have been removed, for example the quirky upvalue stuff was replaced with standard syntactic scoping in version 5.x.

我的观点实际上是 Lua 是一种与大多数其他语言相比古怪角落的语言!我们在商业项目中使用它,我们对它非常满意.

My view is actually that Lua is a language with far less quirky corners than most other languages! We use it in a commercial project and we are more than happy with it.

这篇关于Lua 作为嵌入式语言的替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆