2 posts
Posted 11 November 2013 - 05:15 PM
It's a big mystery for me, and even after watching tutorials from DireWolf20, I still want to know why do they use Lua for ComputerCraft? Surely, I can code with CC in another language I'm familiar with, say M68k Assembly, right?
I know, stupid question, but this question is for the purpose of developing a CC clone that uses a language other than Lua. Languages like C, Javascript, Dylan, Visual Basic, and its .NET successor.
Could they have made CC use Lua for quick compiling?
8543 posts
Posted 11 November 2013 - 08:07 PM
Split into new topic.
ComputerCraft uses Lua because it is
the perfect fit. It's a lightweight, interpreted language that is fairly powerful and quite adaptable. It is the only language you can use on ComputerCraft (barring a Lua compiler/interpreter that consumes another language), and it is, in my opinion, the best fit for what ComputerCraft is trying to accomplish. It would not be impossible to create a mod adding in-game computers which are programmed with a different language (see RP2, which had computers that used FORTH).
808 posts
Posted 12 November 2013 - 01:28 AM
Lua is easy to use. So very extremely easy to use in every way. From the perspective of newbie users, it's easy to pickup and learn the language. From the perspective of someone just trying to get something done in the game, it's quick to write a small script to automate something. From the perspective of the CC devs, it was easy to embed into java, because LuaJ already existed and it's easy for Lua to call Java and Java to call Lua. And of course on top of all that, Lua is a fairly powerful language.
521 posts
Location
Stockholm, Sweden
Posted 13 November 2013 - 04:16 PM
What I have heard (might be wrong) is that Lua got the price for the fastest object based language to this date. I am not that confident tho on this subject, so don't take my work for it.
808 posts
Posted 13 November 2013 - 05:31 PM
What I have heard (might be wrong) is that Lua got the price for the fastest object based language to this date. I am not that confident tho on this subject, so don't take my work for it.
Nope. By far that's Java or maybe C++. It is, however, among the fastest scripting languages. Also Lua is hardly object based. And finally, you might be thinking of LuaJIT, which competes quite well with Java and C++. But LuaJIT has to be compiled for specific platforms, so you can't get it working in a Java environment like ComputerCraft unless you write a native library wrapper for it, which isn't exactly easy considering the incompatibility between the way LuaJIT binaries are linked and the way Java loads and uses natives.
259 posts
Posted 13 November 2013 - 10:18 PM
What I have heard (might be wrong) is that Lua got the price for the fastest object based language to this date. I am not that confident tho on this subject, so don't take my work for it.
Nope. By far that's Java or maybe C++. It is, however, among the fastest scripting languages. Also Lua is hardly object based. And finally, you might be thinking of LuaJIT, which competes quite well with Java and C++. But LuaJIT has to be compiled for specific platforms, so you can't get it working in a Java environment like ComputerCraft unless you write a native library wrapper for it, which isn't exactly easy considering the incompatibility between the way LuaJIT binaries are linked and the way Java loads and uses natives.
"Lua has a quite efficient implementation. Independent benchmarks show Lua as one of the fastest languages in the realm of scripting (interpreted) languages." A language like Java, as Lyqyd stated, wouldn't fit ComputerCraft as well as Lua. I personally couldn't imagine ComputerCraft in any other language.
7508 posts
Location
Australia
Posted 14 November 2013 - 12:03 AM
First, that is exactly what Elvish said, its not the fastest language, but it the fastest scripting language. However these benchmarks are based off Lua for C not LuaJ which is the very inefficient and slow implementation of Lua in Java.
521 posts
Location
Stockholm, Sweden
Posted 14 November 2013 - 08:39 AM
These benchmarks are based off Lua for C not LuaJ which is the very inefficient and slow implementation of Lua in Java.
That clears some stuff up. Didn't think of that there's multiple versions/types of Lua.
1522 posts
Location
The Netherlands
Posted 15 November 2013 - 02:18 PM
I also want to mention that the sandboxing of Lua is not too hard. I mean really, Java or C++ are so big that you can hardly sandbox it without taking a few months of pure sandboxing. I would say that is too much work for a computer in MineCraft.
Also the thing is, Lua is quite easy to pick up. I started with it and got the basic concepts of programming thanks to it. If CC used Java for the language, I would already have clicked away the mod, just because I thought Java was very hard, especially for beginners.
However Lua is "old", it still gets used in
applications! Iirc, dan200 took that as main reason to have Lua into this mod, but dont quote me on that.
Currently Im learning Java, and it turns out that it is still hard after a long time of programming in Lua. I am not saying that Im a professional with Lua, but I do know quite a lot of the language. And I believe that you never can understand a language 100%, you always need help at some point.
I started rambling..
331 posts
Posted 16 November 2013 - 05:13 AM
Simle Answer: Lua is just easy to use
Longer Answer: lua is simple to learn with a small ( but not to small ) range of API's ( unlike java and php ) and once you get a programmers mindset you can do alot with little. Lua already had a file system and could fit in. there's alot more, and dan has his reasons
570 posts
Location
Germany
Posted 17 November 2013 - 04:39 PM
And I believe that you never can understand a language 100%, you always need help at some point.
Small correction: you can understand a language 100% if you made it yourself.
7508 posts
Location
Australia
Posted 17 November 2013 - 07:10 PM
Small correction: you can understand a language 100% if you made it yourself.
It's very rare that only one person makes a programming language, thus meaning that most people on the teams that have made the language still don't 100% understand the language.