Is there a compendium of virtual machines and languages derived or inspired by Lua? By derived, I mean usage beyond embedding and extending with modules. I'm wanting to research the Lua technology tree, and am looking for our combined knowledge of what already exists.
Current List:
Bright - A C-like Lua Derivative http://bluedino.net/luapix/Bright.pdf
Agena - An Algol68/SQL like Lua Derivative http://agena.sourceforge.net/
LuaJIT - A (very impressive) JIT for Lua http://luajit.org
MetaLua - An ML-style language extension http://metalua.luaforge.net/
There's a good list of Lua implementations on the lua users wiki, including compilers/interpreters, languages implemented in lua and languages based on lua.
Luaforge might also be a good resource.
Squirrel -- high level imperative/OO programming language
GSL Shell -- interactive CLI with easy access to the GNU Scientific Library (GSL)
Objective Lua -- almost pure superset of Lua that welds the Objective C object orientation system and syntax on top of the classic Lua language
Jill -- Java Implementation of Lua Language
Dao -- OO programming language with soft (or optional) typing, BNF-like macro system
MoonScript -- CoffeeScript inspired language that compiles into lua
It's just an implementation, not a list, but there's Lua-ML. There's an application paper and a technology paper.
The code is a little out of date; apparently the nightly build at http://www.cminusminus.org/ is broken.
Related
I was just wondering if there is any future plan for Lua to allow users to return userdata type when overloading comparison operators, such as >, <, ==. Currently, all comparison operators defaults to boolean type and in my opinion this prevents many shortcut expressions especially when trying to design code for scientific purposes, such as matrix1<matrix2 and you want to return a matrix.
It is possible to overcome this by designing matrix3=matrix1:less(matrix2); however, many engineers and scientists dont enjoy this type of syntax and prefer the simple way: matrix3=matrix1<matrix2.
C++ allows and as I know Python allows this kind of flexibility. I was just wondering whether this is how not Lua has been designed from the very beginning or it was just for some reason a preference and therefore in the future versions it is possible for Lua to allow this flexibility.
I'm not lua author, but can guarantee that >, < and == in lua will return boolean even in future.
As you have mentioned, C++ and Python allows this. Python is close to C++ as Lua is close to C, I mean some kind of philosophy. So for those who like C++ described thing is lack of feature in Lua, while for C programmers it is the freaking part of OOP languages.
Just imaging that someone will read your program :)
matrix3 = matrix1 < matrix2
What? < operator builds matrix instead of comparison?
matrix3 = m1 > m2
matrix3 = m1 == m1
matrix3 = m1 ~= m2
If language supports such things just kill it with fire (as of C philosophy point)
Lua is the only one I know scripting language with perfect designed abstractions, I mean, though Lua has metatables and metamethods, programmer still can read code and understand what is going on here.
My point is that well designed language must rescue programmers from themselves.
On page 57 of the book "Programming Erlang" by Joe Armstrong (2007) 'lists:map/2' is mentioned in the following way:
Virtually all the modules that I write use functions like
lists:map/2 —this is so common that I almost consider map
to be part of the Erlang language. Calling functions such
as map and filter and partition in the module lists is extremely
common.
The usage of the word 'almost' got me confused about what the difference between Erlang as a whole and the Erlang language might be, and if there even is a difference at all. Is my confusion based on semantics of the word 'language'? It seems to me as if a standard module floats around the borders of what does and does not belong to the actual language it's implemented in. What are the differences between a programming language at it's core and the standard libraries implemented in them?
I'm aware of the fact that this is quite the newby question, but in my experience jumping to my own conclusions can lead to bad things. I was hoping someone could clarify this somewhat.
Consider this simple program:
1> List = [1, 2, 3, 4, 5].
[1,2,3,4,5]
2> Fun = fun(X) -> X*2 end.
#Fun<erl_eval.6.50752066>
3> lists:map(Fun, List).
[2,4,6,8,10]
4> [Fun(X) || X <- List].
[2,4,6,8,10]
Both produce the same output, however the first one list:map/2 is a library function, and the second one is a language construct at its core, called list comprehension. The first one is implemented in Erlang (accidentally also using list comprehension), the second one is parsed by Erlang. The library function can be optimized only as much as the compiler is able to optimize its implementation in Erlang. However, the list comprehension may be optimized as far as being written in assembler in the Beam VM and called from the resulted beam file for maximum performance.
Some language constructs look like they are part of the language, whereas in fact they are implemented in the library, for example spawn/3. When it's used in the code it looks like a keyword, but in Erlang it's not one of the reserved words. Because of that, Erlang compiler will automatically add the erlang module in front of it and call erlang:spawn/3, which is a library function. Those functions are called BIFs (Build-In Functions).
In general, what belongs to the language itself is what that language's compiler can parse and translate to the executable code (or in other words, what's defined by the language's grammar). Everything else is a library. Libraries are usually written in the language for which they are designed, but it doesn't necessarily have to be the case, e.g. some of Erlang library functions are written using C as Erlang NIFs.
In Java, when I do following left shift operation, I get a negative result due to integer / long overflow:
0xAAAAAAAA << 7 gives me -183251938048
But, In Lua since everything is a Lua number which is 52 bit float; I am not able to trigger overflow upon left shift:
bit_lshift(0xAAAAAAAA,7) gives me 1431655680
How do I simulate 32bit signed integer in Lua??
You write some C functions that handle this and then export them to Lua.
Though generally, Lua code shouldn't be touching things this low-level.
You are looking for bit manipulating libraries in Lua. One such library is bitop from the author of LuaJIT, which directly contains it without the need for installation. You can also install it in standard Lua.
Another library is the bit32 library, which is contained in Lua 5.2.
Both libraries let you manipulate 32-bit numbers. For example with bitop:
local bit = require 'bit
print(bit.lshift(0xAAAAAAAA, 7)) --> 1431655680
I do not know how you got the negative number, since 1431655680 is what I get by doing (0xAAAAAAAA<<7)&0xFFFFFFFF in C (and also doing that in a "programming calculator").
I hope I'm not seen as trolling for saying this, but the best way to simulate Java from Lua would be to use Java from Lua.
If you need to emulate Java, chances are that your Lua is already embedded in it. Just expose Java's binary operations to the Lua program, so it can use them.
I heavily use strings in a project so what i am looking for is a fast library for handling them.I think the Boyer-Moore Algorithm is the best.
Is there a free solution for that ?
You can consider the following resources implementing Boyer–Moore algorithm:
Boyer-Moore Horspool in Delphi 2010
Boyer-Moore-Horspool text searching
Search Components - Version 2.1
Boyer-moore, de la recherche efficace
Last Edit:
The StringSimilarity package of theunknownones project is a good source for fuzzy and phonetic string comparison algorithms:
DamerauLevenshtein
Koelner Phonetik
SoundEx
Metaphone
DoubleMetaphone
NGram
Dice
JaroWinkler
NeedlemanWunch
SmithWatermanGotoh
MongeElkan
CAUTION: Answering to the comment rather than to the question itself
There is (or, rather, was, because it has been abandoned currently) a Delphi unit (namely!) FastStrings which implements Boyer–Moore string search algorithm by heavy use of inline assembler. Is is one you are looking for?
As side note: project homepage is defunct now as long as author's e-mail, so i'm finding reuse (and modification and, naturally, any further development) of this code rather problematic given how restrictive are licensing terms.
Is there a way to do logic programming (think of Prolog) in Lua?
In particular: is there any Lua module for logic programming (miniKanren implemenatation will be the best, but it isn't strictly required)? Because I couldn't find any [1]. And if not, are there any known (preferably tried) ways how to do logic programming in Lua?
Also: is there anybody who has tried to do something like logic programming in Lua?
[1] So far I've found only blog post mentioning the possibility of writing one in Metalua, but I would rather see one compatible with the standard Lua.
There is a forward-chaining inference engine in Lua called lua-faces. In addition to MiniKanRen, there are several other logic programming systems in JavaScript that could be automatically translated into Lua using Castl.
I also wrote a translator that converts a subset of Lua into Prolog. Given this input:
function print_each(The_list)
for _, Item in pairs(The_list) do
print(Item)
end
end
it will produce this output in Prolog:
print_each(The_list) :-
forall(member(Item,The_list),(
writeln(Item)
)).
Would ASP be helpful? https://potassco.org/
Check section 3.1.14 of the manual https://github.com/potassco/guide/releases/download/v2.1.0/guide.pdf
Logic programming is a paradigm and thus is just a form of specific syntax where you state some facts and base result on logical equation of those facts, while facts themselves could be results of other equations.
Lua is not specifically designed for this, but you can easily simulate this behavior by defining all logic programming operators as functions - i.e. function and(...) that would return true only if all its arguments true, etc., and making defining your "facts" as a table with lazy evaluation provided by metatable.