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

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

问题描述

我正在一个在DSP上运行Linux的嵌入式系统。现在我们想让它的一些部分可脚本化,我们正在寻找一个很好的嵌入式脚本语言。这些脚本应该很好地整合我们现有的C ++代码库,小而快。



我知道Lua是这样的问题的行业选择。我们可能会和Lua一起去,因为它是真实的,被证明是稳定的等等。然而,作为一种编程语言,它有一些相当古怪的角落。



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



编辑:



大约一年后。



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



表现非常出色,真的。即使相当复杂的操作,涉及通过长阵列搜索或花哨的字符串操作,表现令人惊讶。我们基本上没有遇到过Lua相关的性能问题。



与C函数的接口是非常简单的,工作得很好。这让我们无痛地增长了脚本系统。



最后,我们惊讶于Lua被证明是多么灵活。我们的Lua解释器必须在具有非标准内存分配器的系统上运行,并且不支持双重数据类型。在一个头文件中有两个记录在案的地方,我们必须修改,以使Lua在该系统上工作。它非常适合嵌入!

解决方案

既然你说嵌入式系统和小而快, 我会说你是正确的,Lua是第一,如果不是唯一的选择。但我不再同意编程语言有古怪的角落。首先,卢卡书编程简直是灿烂的,我读过的最好的书之一。其次,一些古怪的角落来自于语言是非常正交和干净的,从长远来说,这是一种资产,而不是缺点。我发现JavaScript比较糟糕。如果您阅读Javascript的好的部分,作者将解释为什么语言中的一些构造是设计错误,以及为什么要避免新的操作符。在Lua中并不是这样,坏的部分已经被删除了,例如,这个古怪的高价值东西被版本5.x中的标准语法范围所取代。



我的看法其实是Lua是一种与大多数其他语言相比远的更小的语言的语言!我们在商业项目中使用它,我们对此感到非常满意。


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.

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?

EDIT:

This is about a year later.

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.

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.

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

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!

解决方案

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.

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天全站免登陆