8 ms·
Pallene: A statically typed companion language for Lua [pdf]
- catwell 8y agoA few details: - Pallene is a friendly fork of Titan [1]. The reason for the fork is that the authors of Titan are iterating fast and adding many experimental features to it. The research group at PUC Rio needed a more stable code base and language definition. Improvements from Pallene will be merged back into Titan, which is probably what actual programmers should use in the long run (as of now neither is ready for production). - There was a presentation of Pallene at Lua Workshop earlier this month. Slides and video should be available at [2] at some point. [1] http://titan-lang.org http://titan-lang.org [2] https://www.lua.org/wshop18.html#Ligneul https://www.lua.org/wshop18.html#Ligneul
- etiene 8y agoThe talk was great! I'm incredibly impressed with the benchmarks. Here is a quick link to Pallene's github repo as well, since it's a bit hidden in the paper: https://github.com/pallene-lang/pallene https://github.com/pallene-lang/pallene
- hugomg 8y agoGabriel's slides are already available here: https://gligneul.github.io/luaworkshop2018/ https://gligneul.github.io/luaworkshop2018/
- hugomg 8y agoI'm first author of the linked paper and am working on Pallene for my PhD. Feel free to ask any questions here!
- marktangotango 8y agoSand boxing is what really sets lua apart imo. Will custom allocators and dynamic code loading be supported? Will generated code implement the debug hook counters?
- hugomg 8y agoPallene has been designed to seamlessly interoperate with Lua, not to replace it. So you can still use Lua when you need dynamic code loading or magic debug hooks. Roughly speaking, from the point of view of Lua, Pallene is a system language like C. It is good for performance and calling C system libraries, but isn't particularly suited for dynamic code loading and sandboxing via interpreter hooks.
- nikki93 8y ago(Maybe trivially answerable by looking through the resources, sorry!) -- will Pallene still support `eval`-like behavior (like with Lua's `load` function(s))?
- hugomg 8y agoDon't worry, that is still a fine question. Pallene programs are still able to use Lua's "load" to eval dynamically-typed Lua code. But it is less likely that we would implement a function to load Pallene source code at run-time, for the same reasons why it isn't common to dynamically load C source code: Pallene takes longer to compile than Lua, and dynamically-loaded code usually isn't as performance-sentitive anyway.
- nikki93 8y agoCool makes sense. Could actually still be awesome to have a Lua lib or some other runtime lib that can translate Pallene or some other type-annotated Lua format to plain Lua, just for typechecking and ability to use autocomplete etc.
- corysama 8y agoWould it be a mischaracterization to say that the generated C is basically the source of the Lua interpreter + the statically compilable functions from the Pallene program?
- hugomg 8y agoFrom the point of view of Lua, Pallene works the same as C If you want to produce a standalone executable, at the end of the day this executable will contain a copy of the Lua VM. If you want to produce a library that can be "require"-ed from Lua, then you will produce a ".so" shared object file with just the Pallene functions in it.
- fithisux 8y agoI do not understand why Pallene is necessary if performance is the problem. Just use LuaJIT. I suspect something else is happening here and possibly it has to do with autocompletion/intellisense.
- hugomg 8y agoPallene is indeed approaching this problem more for performance than for autocompletion. (For just autocompletion it would be more appropriate to use a typesystem that is closer to full Lua, like Typed Lua) For us, the main motivations for the Pallene approach are performance predictability and implementation complexity. To get maximum performance with a JIT you need to write your code in a way that ensures that the control flow always stays inside the compiled parts of the code. If you are accidentally "too dynamic" then the JIT will fall back to the general bytecode interpreter, with an order of magnitude slowdown. The Pallene type system should ensure that if your code typechecks then it can be compiled to something reasonably efficient. The type system also lets us use a simpler ahead-of-time compiler instead of a just-in-time one. JIT compilers are notoriously tricky to implement, which in turn means that it is more difficult to evolve them together with the language, or to port them to additional platforms.
- catwell 8y agoI strongly second that. We are more and more former users of LuaJIT who either don't use LuaJIT anymore, or think it is not a good long-term solution, because of those two issues (and absence of support of recent Lua versions). In addition to that, people working on Titan say it could become an alternative to C for people who write applications in PUC Lua + C: - It has an FFI so it can be used to implement bindings. - It can also be used to extract performance-sensitive code from Lua into a compiled language. - It should support newer Lua versions, being developed by people from PUC / close to PUC. Yay, 64 bit integers and bitwise operators!
- hugomg 8y agoYup, this is the idea. :) If you don't mind, I'm curious about what applications you currently use Lua for.
- eslaught 8y agoFor those of us who are only half paying attention, how does this compare to Terra[1]? Are you using something (e.g. LLVM) for code generation? Can you generate binaries that are independent of the Lua runtime? [1]: http://terralang.org/ http://terralang.org/
- nerpderp83 8y agoThey emit C and call out to the system C compiler. They bypass the normal Lua extension mechanism for performance.
- hugomg 8y agoTerra uses Lua as a metaprogramming language, while Pallene/Titan use Lua as a scripting language. Terra is designed for high performance numerical computing. As you mentioned, it has no garbage collector, uses C-like datatypes and its executables are completely detached from the Lua runtime. Pallene, on the other hand, is all about being able to seamlessly interoperate with Lua at run-time. It is possible to directly manipulate Lua tables and functions from a Pallene program. From the point of view of Lua, Pallene modules can be loaded as a C extension module would, except that Pallene is designed to integrate even better with Lua (sharing its garbage collector and having better C API performance). As the other commenter pointed out, we are currently compiling down to C. However, it is possible that we could switch to LLVM IR in the future.
- eggy 8y agoI had submitted this to HN because I was trying to evaluate using Terra instead of Zig [1] as my C replacement language. I had already become familiar with a particular dual-language environment called Extempore, [2] for livecoding that has a scheme language, and a c-like, s-expression-based language called xtlang that is compiled. You can mix the two in the same programming session, and it really works for me. And then I came upon Pallene. I like the idea of having a scripting language like Lua, but the clarity of a typed, compiled, non-GC language instead of C or the templates of C++. Terra ticks those boxes. The mix of Lua and Terra seems to be very flexible too from my early explorations. Is Pallene within an order of magnitude of the speed of Terra given no special tricks are needed to pull off a task. Are there any "bad" things Terra does that Pallene keeps within the better side of Lua. I guess I am asking if Pallene is a better fit for a dual-language system based on Lua than Terra other than maximum numerical computing performance. Thanks! [1] ziglang.org [2] https://extemporelang.github.io/
- oscargrouch 8y agoIf someone is curious as i was, here's a little bit more context: Github Repo - https://github.com/pallene-lang/pallene https://github.com/pallene-lang/pallene More about the language - https://github.com/pallene-lang/pallene/blob/master/doc/manual.md https://github.com/pallene-lang/pallene/blob/master/doc/manu...
- Jyaif 8y agoI have only one question: is it 0-based?
- eggy 8y agoI was so focused on the technical that in pronouncing Pallene as "Pauline" to myself, I finally paused and made the connection LuaJit <- Mike Pall, so Pall...ene. Watch it's probably right in the PDF, and I just read over the connection!
- muthdra 8y agoHey, bro. Lua was my first programming language. I started making PSP homebrews before I learned it was actually made here in Brazil. How is compilation-time execution handled in Pallene? Does it have templating or maybe can it run its functions during compilation with a special token (so it doesn't need a metaprogramming language)?