Comment by transpute
1 year ago
If you like Lua, see Terra, https://terralang.org/
> Terra is a low-level system programming language that is embedded in and meta-programmed by the Lua programming language.. Like C/C++, Terra is a statically-typed, compiled language with manual memory management. But unlike C/C++, it is designed from the beginning to be meta-programmed from Lua.. In Terra, we just gave in to the trend of making the meta-language of C/C++ more powerful and replaced it with a real programming language, Lua.. Terra programs use the same LLVM backend that Apple uses for its C compilers. This means that Terra code performs similarly to equivalent C code.
From Pat Hanrahan's research group at Stanford, https://amturing.acm.org/award_winners/hanrahan_4652251.cfm
Hanrahan and his students developed Brook, a language for GPUs that eventually led to NVIDIA’s CUDA. The prevalence and variety of shading languages ultimately required the GPU hardware designers to develop more flexible architectures. These architectures, in turn, allowed the GPUs to be used in a variety of computing contexts, including running algorithms for high performance computing applications, and training machine learning algorithms on massive datasets for artificial intelligence applications.
"I am here to warn you, traveler, that Terra sits on a throne of lies. I was foolish. I was taken in by their audacious claims and fake jewels. It is only when I finally sat down to dine with them that I realized I was surrounded by nothing but cheap plastic and slightly burnt toast."
Source: https://erikmcclure.com/blog/a-rant-on-terra/
https://news.ycombinator.com/item?id=27337278
> Please note: The entire "windows" portion of that article has largely been resolved at this point, because I fixed it myself.
Both Terra and Extempore [1] implement the same basic idea, which is provide a way to generate performant machine code on the fly but keeping a language surface that feels like you are working with a dynamic language (Lua or Scheme correspondingly). I think Scopes [2] could be mentioned here too. The concept is really cool and different from JIT compiling in that the developer is given the tools to generate machine code, as opposed to some "magic" JIT compiling happening opaquely behind the scenes.
That being said, I don't think either of these languages is practical for real world projects for several reasons: lack of (or low quality) documentation, bus factor (lack of developers), tiny communities, lack of tools, lack of libraries, etc etc etc.
--
1: https://extemporelang.github.io/
2: https://sr.ht/~duangle/scopes/
> I don't think either of these languages is practical for real world projects
Maybe not yet, but prior work by this research team eventually lead to CUDA. Terra may be useful as a productivity DSL for some high-performance computations, e.g. listed in their papers:
2021 HN thread, https://news.ycombinator.com/item?id=27334065
> Terra is a workhorse and it gets the job done.. Having first-class code generation capabilities has been really nice, especially with built-in support for things like parsing C header files, vectorization, and CUDA code generation. The language is stable and generally doesn't have many surprises. Unlike, say, C++ or Rust, there aren't as many corners to hide odd behaviors.
> Terra programs use the same LLVM backend that Apple uses for its C compilers.
Can it use anything else (as an option), e.g. Lua? That would be useful during development/debugging thanks to faster iteration and memory safety.
LLVM would not be easily replaced, https://chriscummins.cc/2019/llvm-cost/
> 1.2k developers have produced a 6.9M line code base with an estimated price tag of $530M.
Although it's true that replacing LLVM like-for-like would indeed be expensive, I feel like you missed GP's point. To make the easier to debug, what you want is to replace LLVM with something simple, like a plain interpreter. And writing one (or adapting one) would be nothing like this cost.
3 replies →
that's a fallacy that was ignored when starting llvm and looking at the already existing gcc.
y'all realize that this thing (terra) was a phd project that is (for a long time) fully abandoned by the guy that did the phd (zach) right?
> Terra programs use the same LLVM backend that Apple uses for its C compilers
lol is this a flex? or is it just dated? everyone uses LLVM for all of their compilers.
Fortunately, open-source projects can have more than one contributor. 2024 commit log includes:
I'm well aware but consider what it means that the guy that created it has walked away from it
11 replies →