lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

From the top comment on Hacker News discussion :
> At first I was confused because the pitch seemed to be mainly about writing fast code with Lua.
> If that's what they're going for, then a comparison with LuaJIT is sorely missing.
> But it appears that what they're actually pitching is a simple and flexible code generation environment.
> It's a way to generate statically-typed code at runtime that targets LLVM but looks nicer than this:

So, as I understand it, programming in "Terra" environment means really writing a LLVM-based compiler, only instead of LLVM you use Terra (which, reportedly, seems to actually translate to LLVM underneath?), and instead of C++ you use Lua. And instead of explicit calls to LLVM API, you have some syntactic sugar called "Terra".

In other words, let's have a small story:
    Imagine you were just struck by a strong desire to write a Fortran to LLVM compiler. Yeah, that would be totally fun! So how can you do this? So, reading the LLVM manual, it seems that LLVM is just a regular C++ library! A C++ library that behaves like a compiler, in that you can feed it with some low-level assembly-like input, and it spits out binary executables for your chosen platform. Be it x86, ARM, or even the raw Turing machine, probably. Heaven on earth!
    "But, but, but, I do soooo love Lua, can I pretty please use Lua? Instead of this stupid convoluted kitchen-sink and more, shoot me in my foot please C++ thing?" Sure, you probably could; you might try to write some Lua bindings for LLVM, maybe using SWIG. Or, better, search Github for some Lua/LuaJIT bindings to LLVM. So, this way, you could use Lua, leveraging LLVM, to write a Fortran compiler. Pure awesomeness and pink unicorns farting rainbows!
    Now, where does Terra enter this story? Here, exactly here! Because, instead of calling LLVM API functions, you can apparently call Terra API functions, which do more or less the same. Uh, oh, sorry; not exactly API functions: API functions disguised as language-level syntax. Or Lua-extending DSL if you like. Kinda like LINQ is a syntax extension in C#. Or XML can be embedded in Adobe Flex. Or I believe some DSL stuff in Ruby, don't know for sure. Or like Anything-Really-Anything and more can be embedded in Tex/LaTeX.

Or, I may be totally missing the point ;) But I tried :) maybe at least I'll provoke some better worded and less chaotic rebuttal.
Sorry if this description above sounds diminutive or something, that wasn't intended. I just tried to write a story in a somewhat lighthearted way, that could hopefully do more good than harm.

Cheers and good luck!
/Mateusz Czapliński.

On Tue, May 14, 2013 at 4:02 PM, Gabriel Duarte <> wrote:

Gabriel Duarte
Linux User #471185
Rio de Janeiro / RJ