This is a really neat bridge! I'd like to see more of this type of work. Language bridging. Imagine a Jupyter Notebook being able to use all different kinds of languages together in said notebook. Just an example use case, I'm sure there are plenty, plenty more.
Way back when I played minecraft, we used a mod called OpenComputers, which was basically a lua-based terminal inside minecraft. It had a package manager, python, and pastebin for managing code. It was really neat! Still think it's funny that it was Java -> Lua -> Python.
Ended up using that to "3d print" objects to make png murals using a python backend, some jad/sed/awk/grep, lua, and a python "frontend". The 3d printer allowed specifying color, but since you could also specify colors by x/y/z coords of other blocks, I decided to constrain the project to color definitions that way. Because masochism, probably. Wasn't easy, since block definitions were sometimes in java, hence jad. By FAR the jankiest project I've ever worked on, but damn did I learn a lot along the way, including some machine learning basics.
Posts like the OP's make fun projects like mine possible!
As a huge fan of Lua, but not Python, I'm not sure whether to be terrified or impressed by this. Probably a little bit of both.
Actually, I can already see ways this is going to be good for Lua adoption on some of my projects, but also simultaneously threatening, since it means a 'more widely accepted language' could predispose continuing in Lua.
Actually, this is going to be very weird, once word gets out that Pythons batteries are up for grabs in certain circles ..
I've been using this for over a year in a small personal project - embedding youtube-dl in another Lua program - and it's been nearly perfect, save for some issues passing objects and some clunky mechanics. Very happy with it overall!
This is sorta similar to rustpython_wasm[0] - I haven't been super focused on it recently, but I'd love to eventually have something as in-depth and well-designed as this. Currently it has all the necessary APIs (I think) to communicate however you want between JS and Python, but I'd like to have some sort of JSProxy object in Python so accessing JS APIs can look like it does in JS. Currently, you have to do something like:
This is super good, I used to work with Lua for high performance voice SBCs to be able to process SIP/SDP messages. That was the only language that we included in our engine because of its good and cheap parsing capabilities. I would love to give this a try.
A bit weird proposition, considering that Lua runs circles around Python in terms of execution speed: some of my Lua scripts finished faster that Python starts up, despite even doing file i/o.
On the other hand, just two days ago I had to implement my own string.split method to split on some delimiter. Lua is tiny and fast, but that's not without its downsides.
Thankfully the Penlight lib has many functions such as that. Lua's speed means that having library functions written in the language itself is alright for business-logic programs.
My main beef with Lua is the absence of ‘null’, which means I can't write middleware doing transformations on data without a schema—i.e. API requests and processing, for which Lua would be great otherwise.
Heh, someone shows up to remind me of ‘nil’ each time I say that.
Lua's ‘nil’ is not a value, it's a void in which all undefined variables swim. Specifically, if you assign nil to a table field, you can't know what fields the table has unless you have that schema beforehand.
There was even something in this vein on the front page.
Secondly, even if there's another, more special value, that can't be conflated with a string (Lua does support some kind of user-values that are distinct from any built-in types)—it still leaves a question of how different modules handle that. In fact, different modules like CJSON already do this—but what if I decode JSON with CJSON's null value and need to encode XML when the XML module has its own null value? I'd need to walk the data and convert from one to the other.
But by now why not just have this value in the language, since various modules need it anyway for interoperability with other systems?
I heard even that there were attempts at deciding on such a value for a new version of Lua, only with some bunk name like ‘undefined’, which is actually the opposite of what ‘null’ is.
> Sadly, Lunatic Python is very much outdated and won't work with either a current Python or Lua. [] This is an updated version of lunatic-python that works with Python 2.7-3.x and Lua 5.1-5.3 I tried contacting the original author of Lunatic Python, but got no response.
Hi,
Just curious to know if that project respond to a need. I think that interpreted languages don't have the need to those kind of crossovers functionnalities.
23 comments
[ 3.1 ms ] story [ 55.9 ms ] threadWay back when I played minecraft, we used a mod called OpenComputers, which was basically a lua-based terminal inside minecraft. It had a package manager, python, and pastebin for managing code. It was really neat! Still think it's funny that it was Java -> Lua -> Python.
Ended up using that to "3d print" objects to make png murals using a python backend, some jad/sed/awk/grep, lua, and a python "frontend". The 3d printer allowed specifying color, but since you could also specify colors by x/y/z coords of other blocks, I decided to constrain the project to color definitions that way. Because masochism, probably. Wasn't easy, since block definitions were sometimes in java, hence jad. By FAR the jankiest project I've ever worked on, but damn did I learn a lot along the way, including some machine learning basics.
Posts like the OP's make fun projects like mine possible!
Actually, I can already see ways this is going to be good for Lua adoption on some of my projects, but also simultaneously threatening, since it means a 'more widely accepted language' could predispose continuing in Lua.
Actually, this is going to be very weird, once word gets out that Pythons batteries are up for grabs in certain circles ..
https://github.com/brython-dev/brython
I especially like the fact that I can have the same language in the backend and the front-end and it doesn't have to be JS, which I hate with passion.
My main beef with Lua is the absence of ‘null’, which means I can't write middleware doing transformations on data without a schema—i.e. API requests and processing, for which Lua would be great otherwise.
Lua’s equivalent is `nil` - I assume that doesn’t do what you need? How would the behaviour of `null` differ from Lua’s `nil`?
Lua's ‘nil’ is not a value, it's a void in which all undefined variables swim. Specifically, if you assign nil to a table field, you can't know what fields the table has unless you have that schema beforehand.
and https://www.wired.com/2015/11/null/
There was even something in this vein on the front page.
Secondly, even if there's another, more special value, that can't be conflated with a string (Lua does support some kind of user-values that are distinct from any built-in types)—it still leaves a question of how different modules handle that. In fact, different modules like CJSON already do this—but what if I decode JSON with CJSON's null value and need to encode XML when the XML module has its own null value? I'd need to walk the data and convert from one to the other.
Well, some modules do support a common value denoting null: https://github.com/moteus/lua-null
But by now why not just have this value in the language, since various modules need it anyway for interoperability with other systems?
I heard even that there were attempts at deciding on such a value for a new version of Lua, only with some bunk name like ‘undefined’, which is actually the opposite of what ‘null’ is.
Fork https://github.com/bastibe/lunatic-python , with a commit in 2020, says:
> Sadly, Lunatic Python is very much outdated and won't work with either a current Python or Lua. [] This is an updated version of lunatic-python that works with Python 2.7-3.x and Lua 5.1-5.3 I tried contacting the original author of Lunatic Python, but got no response.
This fork has forks. https://pypi.org/project/lunatic-python-universal/ says:
> This package is a fork of the original from http://labix.org/lunatic-python, updated to support Python 3, and forked again from https://github.com/bastibe/lunatic-python to release to PyPi and support newer versions of Lua and macOS Homebrew-installed Lua.
http://lua-users.org/wiki/BindingCodeToLua also mentions https://pypi.org/project/lupa/ and https://pypi.org/project/ffilupa/ .