News for hackers. Stuff that matters.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by nilsbunger on Tuesday March 07, 2023 @11:21AM (#35057168)
Lua has been used a lot for that kind of embedding in the past. I think because it's easy to move data between Lua and C? Python would certainly be a big step up but I don't know how hard that kind of integration is.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by Waterluvian on Tuesday March 07, 2023 @11:27AM (#35057242)
Lua is a great language for game scripting. Perhaps that’s a better option.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by 0xffff2 on Tuesday March 07, 2023 @12:38PM (#35058350)
Why is it such a great language? As a developer entirely divorced from the gaming industry aside from occasionally dabbling in modding, lua has always seemed completely inscrutable to me when I have encountered it.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by Tyr42 on Tuesday March 07, 2023 @02:07PM (#35059692)
The C API is pretty straightforward and has a stack object to avoid lots of reference counting you would need with Python's c API.

It's also a tiny codebase which is easy to vendor and ship.

Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by agentultra on Tuesday March 07, 2023 @02:07PM (#35059695)
Its obscenely easy/consistent memory layout. It makes embedding it into another application straight-forward and easy to manage. Extending the host interface to the embedded scripts is very simple because of this. It's also serialize-able to a degree.

Python is also a decent glue language but creating a Python interpreter is a bunch more work and the API is a bit harder to work with.

Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by guipsp on Tuesday March 07, 2023 @02:10PM (#35059744)
LuaJIT is insanely good
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by schemescape on Tuesday March 07, 2023 @02:24PM (#35059922)
It’s a tiny but capable language that’s easy to embed, and can be surprisingly fast with LuaJIT.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by elfprince13 on Tuesday March 07, 2023 @02:25PM (#35059933)
I think the main attractions are that it has pretty minimal syntax + core libraries, does a good job binding to C FFIs, and the interpreter is fast.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by kzrdude on Tuesday March 07, 2023 @05:03PM (#35061914)
They have a clean API for embedding. All Lua interpreter state is kept in a struct that you alloc. If you alloc two distinct structs, you have two completely independent Lua vms and you can run them on independent threads if you want to no problem, and so on. (Few language runtimes are clean in this way.)
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by cozzyd on Wednesday March 08, 2023 @01:06AM (#35065799)
yes, python is basically impossible to embed in a multithreaded app.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by outworlder on Tuesday March 07, 2023 @05:22PM (#35062103)
Inscrutable?

The language is _tiny_ (and kept that way on purpose)

Aside from stuff like metatables(which may require you to play around for a bit to understand their value), you can pick it up in a couple of hours. I'm not even kidding. So much so that you see people modifying code without even looking at documentation.

https://www.lua.org/manual/5.4/

https://learnxinyminutes.com/docs/lua/

Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by v3ss0n on Tuesday March 07, 2023 @12:54PM (#35058586)
Lua is most hated lang
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by w0m on Tuesday March 07, 2023 @01:56PM (#35059513)
It seems reasonable in my ~300 line neovim config :D

and yes; i know that's a ridiculous example that's not really comparable for anything significant.

Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by zemo on Tuesday March 07, 2023 @02:45PM (#35060184)
do you work in games
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by outworlder on Tuesday March 07, 2023 @05:23PM (#35062110)
> Lua is most hated lang

Impossible. Most developers outside the games industry don't even know it exists.

... and if they knew about it, they would use it much more.

Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by bsder on Tuesday March 07, 2023 @05:27PM (#35062159)
Sorry, Lua is not simply not a great language.

The first problem is "Which Lua?" Lua, by itself, is almost completely useless. You first need to compile/install a bunch of things in order to make Lua useful. This has the Perl problem that everybody uses a different dialect of Lua.

The second part is that the Lua constructs for programming in the large are very weak. I believe that Adobe had a postmortem about this (Lightroom, I think?)

And then there is the language, itself. For me, the 1-based indexing is death in this day and age. Sorry. Zero-based is the dominant ecosystem and not fitting into that is simply not acceptable.

Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w... by tomodachi94 on Tuesday March 07, 2023 @06:32PM (#35062932)
> You first need to compile/install a bunch of things in order to make Lua useful.

How is this any different from pretty much any language out there? From a quick eyeball of RustPython's Cargo.toml[1], there are about 70 different dependencies which all need to be compiled. I haven't worked too much with Autoconf, but I am pretty sure CPython has quite a few dependencies.

[1]: https://github.com/RustPython/RustPython/blob/main/Cargo.tom...

> The second part is that the Lua constructs for programming in the large are very weak.

This is deliberate because it forces you to use the tools you are given instead of reimplementing features that can already be implemented by using other primitives in Lua.

> I believe that Adobe had a postmortem about this (Lightroom, I think?)

I can't find this article. Has anyone else had any luck?