6 ms·
If you like Lua, see Terra, https://terralang.org/ https://terralang.org/ > Terra is a low-level system programming language that is embedded in and meta-progr
by transpute 2y ago
If you like Lua, see Terra, https://terralang.org/ 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 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.
Papers: https://terralang.org/publications.html https://terralang.org/publications.html
- trott 2y ago> 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.
- transpute 2y agoLLVM would not be easily replaced, https://chriscummins.cc/2019/llvm-cost/ https://chriscummins.cc/2019/llvm-cost/ > 1.2k developers have produced a 6.9M line code base with an estimated price tag of $530M.
- ajb 2y agoAlthough 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.
- transpute 2y agoAny precedent example for an LLVM-hosted language? There are benefits from being on the same toolchain as popular languages.
- dvtkrlbs 2y agoRust is experimenting with a codegen tool called cranelift which powers wasmtime. The plan is to use it for debug builds. There is also a backend implementation in the works using gcc jit and a dotnet backend as well
- brabel 2y agoZig is actually trying to get rid of LLVM for default builds, though they intend to keep it as one of the "backends" for the forseeable future. The problem is that LLVM is very slow (as it applies lots of optimisations) and heavy, and that makes a compiler slow even in debug mode. D has 3 backends, LLVM is used by the LDC compiler. Then there's DMD which is the official compiler (and frontend for all three), and GDC which uses GCC backend. D code typically compiles quite a bit faster on DMD, but the code is more highly optimised with LLVM or GCC, of course. It's a great tradeoff specially since all compilers use the DMD frontend so it's almost guaranteeed that there's no differences in behaviour between them.
- 1oooqooq 2y agothat's a fallacy that was ignored when starting llvm and looking at the already existing gcc.
- emmanueloga_ 2y agoBoth 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/ https://extemporelang.github.io/ 2: https://sr.ht/~duangle/scopes/ https://sr.ht/~duangle/scopes/
- transpute 2y ago> 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: our DSL for stencil computations runs 2.3x faster than hand-written C our serialization library is 11 times faster than Kryo our dynamic assembler is 3–20 times faster than Google’s Chrome assembler 2021 HN thread, https://news.ycombinator.com/item?id=27334065 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.
- brabel 2y ago"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://erikmcclure.com/blog/a-rant-on-terra/
- transpute 2y agohttps://news.ycombinator.com/item?id=27337278 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.
- almostgotcaught 2y agoy'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.
- transpute 2y agoFortunately, open-source projects can have more than one contributor. 2024 commit log includes: Bump CI to macOS 13 Add AVX512 support Update LuaJIT Document AMD, Intel, Nvidia GPU support Add support for LLVM18 Support SPIR-V code generation
- almostgotcaught 2y agoI'm well aware but consider what it means that the guy that created it has walked away from it
- PicassoCTs 2y agoPeople change, interests wander. The guy who made brainfuck wrote parts of the sauerbraten engine. Is that a betrayal of brainfuckery?
- transpute 2y agoIf the project is actively maintained after 10 years, it means he created a sustainable foundation. If you're aware of specific open issues with the project, identified by the founder or others, please share details.
- almostgotcaught 2y agodo you understand that "use one language to emit another language that is then immediately compiled" is literally like hundreds of languages now? numba/cupy/pytorch/jax/julia/etc/etc/etc. they all implement both a high level IR that can be transformed via the high level language (python) and a JIT/compiler/whatever. so like why would i ever use this thing terra+lua+"5 guys maintaining it in a basement somewhere" thing?