Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terra lang and Lua

I was reading on terralang site about terra language as

"a new low-level system programming language that is designed to interoperate seamlessly with the Lua programming language..."

Zach DeVito (the main author) write about the use of terra :

A scripting-language with high-performance extensions.....

An embedded JIT-compiler for building languages.....

A stand-alone low-level language....

But (may be my fault) I don't understand if terra is:

  1. a luaJit competitor
  2. a better system to interface with c library
  3. something better than luaJit using llvm

Can someone help me to better understand what is going on terralang project ?

Thanks

like image 722
msalese Avatar asked Jun 05 '14 09:06

msalese


1 Answers

But (may be my fault) I don't understand if terra is: a luaJit competitor

It is not. It is built on top of LuaJIT and LLVM. LuaJIT is written by Mike Pall and LLVM is written by Apple and the community. It can do two things.

1) It adds extra language syntax (dubbed Terra) to your Lua code. In this way, you can mix Lua code with hard core low level code with great ease.

2) It allows you to generate fast code at runtime. Great if you want to create new languages, compilers or generate fast machine code without all the work normally associated with this.

a better system to interface with c library

Yes and No. If all you want to do is call existing C or other native libraries from Lua, I recommend using LuaJIT as is. Mike Pall has done a fantastic job at this and a lot of the C integration magic comes from LuaJITs FFI. But if you need to create new "C like" code mixed together with your Lua program, Terra is nice. You have a dynamic language / status language hybrid.

something better than luaJit using llvm

No, Lua code is still evaluated using LuaJIT and Terra code uses LLVM.

Summary

Terra is fantastic, I can really recommend it.

like image 178
Jack Wester Avatar answered Sep 27 '22 21:09

Jack Wester