This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Aquilamo's profile picture

[Question]Other programming languages?

Started by Aquilamo, 28 December 2012 - 12:04 AM
Aquilamo #1
Posted 28 December 2012 - 01:04 AM
Would it be easier to create an entire new mod or write an interpreter in Lua?
I'm sure I heard somewhere that there was no plan to add other programming languages, so I won't mention it.

Would running an interpreter written in Lua work properly on a ComputerCraft computer?

If an interpreter written in Lua would be too laggy, then I would probably create a new mod. Apart from knowing how to program, is there any good piece of advice anybody could give me? Anything that could help?
RunasSudo-AWOLindefinitely #2
Posted 28 December 2012 - 01:49 AM
An XYZ interpreter running on a LUA interpreter running on a Java VM? It might work, but it would be mighty slow. It'd be simpler just to use plain LUA.
theoriginalbit #3
Posted 28 December 2012 - 01:56 AM
An XYZ interpreter running on a LUA interpreter running on a Java VM? It might work, but it would be mighty slow. It'd be simpler just to use plain LUA.

It also may get very difficult to interpret particular statements from the language, especially if Lua doesn't have an equivalent statement.
RunasSudo-AWOLindefinitely #4
Posted 28 December 2012 - 02:01 AM
An XYZ interpreter running on a LUA interpreter running on a Java VM? It might work, but it would be mighty slow. It'd be simpler just to use plain LUA.

It also may get very difficult to interpret particular statements from the language, especially if Lua doesn't have an equivalent statement.
I was thinking along the lines of writing a Java VM in LUA or something, not just

if command == "System.out.println" then print(vars) end
theoriginalbit #5
Posted 28 December 2012 - 02:04 AM
I wasn't talking about loadstring either. but how would you interpret if they made say a C interpreter (since they didnt specify) and the user does some operator overloading, or new type defining and some type checking that Lua doesn't have, since it has fairly primitive types. I have more examples, but these are just a few.
RunasSudo-AWOLindefinitely #6
Posted 28 December 2012 - 02:11 AM
I wasn't talking about loadstring either. but how would you interpret if they made say a C interpreter (since they didnt specify) and the user does some operator overloading, or new type defining and some type checking that Lua doesn't have, since it has fairly primitive types. I have more examples, but these are just a few.
I was thinking along the lines of "okay, so we're gonna implement our own stack, and our own memory management, and we're gonna read some bytecode and interpret all of the opcodes in there to run the program". "Operator overloading? What's that? You mean like aload_0?"
Sammich Lord #7
Posted 28 December 2012 - 02:12 AM
It is completly possible to write a interperter or even your own language.

f = fs.open("file", "r")
local fl = f.readLine()
while fl do
  if fl == "BOOM" then
    print("boom")
  end
  fl = f.readLine()
end
f.close()
You get the basic idea.
Aquilamo #8
Posted 28 December 2012 - 02:55 AM
I was thinking about making an interpreter for Python, but I'm still not sure how object-orientated interpreters really work.
(and how you could have an interpreter written in a lower abstraction level language)
Besides, there's still the issue of whether it would be better to create an entire new mod or running an interpreter on a ComputerCraft computer.
Sammich Lord #9
Posted 28 December 2012 - 02:57 AM
I was thinking about making an interpreter for Python, but I'm still not sure how object-orientated interpreters really work.
(and how you could have an interpreter written in a lower abstraction level language)
Besides, there's still the issue of whether it would be better to create an entire new mod or running an interpreter on a ComputerCraft computer.
It will be by far easier to create a new mod IF there was a Java implementation of Python. Or if you could find a Python interpreter in Lua then you can modify that. But making a interpreter from scratch for another language is going to be difficult.
Aquilamo #10
Posted 28 December 2012 - 03:16 AM
There's an implementation of Python in Java, called Jython. It's open source, so I'm sure having a look at it could help me. I'll probably do a new mod then.
Is there any public information about how ComputerCraft works?

Thanks a lot for helping me so far.
MysticT #11
Posted 28 December 2012 - 03:43 AM
Is there any public information about how ComputerCraft works?
No, there isn't. And even if there were, it wouldn't help you, since it's heavily based on how lua works, using coroutines for each computer.
Writing an entirely new mod would make it easier to write the interpreter (you can use an existing one), but you have to make the mod, including the blocks, items, etc. and all the network handling.
Conclusion: just stick to lua :P/>
Aquilamo #12
Posted 28 December 2012 - 03:54 AM
I won't :D/>. The main reason why I want to use Python is because I prefer Python ;)/>. I also want to get much better at object-orientated, and what would be a better way than playing? I have a feeling the network handling is gonna be a huge pain though…