LUA?
LUA?
Is there any plan to implement LUA in PB? I'm looking for a scripting language that can be hooked to PB for game purposes, and it seems the best option to me. I know there is an existing library somewhere, but having it in the standard library would be more consistent (ie. better implementation).
- the.weavster
- Addict
- Posts: 1577
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
Re: LUA?
I agree that a scripting language would be a great addition but I've advocated MicroPython seeing as Python is the #1 programming language these days.
Re: LUA?
does anyone have experience embedding MicroPython ?the.weavster wrote: Mon Jan 27, 2025 9:34 pm I agree that a scripting language would be a great addition but I've advocated MicroPython seeing as Python is the #1 programming language these days.
with msys2 installed I was able to build the MicroPython interpreter using the following steps
I created a folder named "mupython"
launch mingw64.exe
cd mupyton
git clone https://github.com/micropython/micropython
cd mupyton/micropython/ports/windows
make submodules
make
micropython.exe is in mupyton\micropython\ports\windows\build-standard
but what I am really interested in is using MicroPython in PB
Re: LUA?
I'm certainly of the view that a JIT compiler could be extremely powerful, but would that mean the compiler's execution within an existing compiled PB executable would require the 'end user' of the object code to have a PB licence installed?idle wrote: Tue Jan 28, 2025 1:46 am I'd prefer a PBJit compiler, none of that interpreted stuff needed.
Re: LUA?
ok, to make a static libmicropython is as simple as make lib
then if I copy the static lib into a temp folder and
ar x libmicropython.a
gcc -static -shared -o libmicropython.dll *.o -lbcrypt
I get libmicropython.dll
you may download the static lib and dll from https://u.pcloud.link/publink/show?code ... 17kYll0fuy
then if I copy the static lib into a temp folder and
ar x libmicropython.a
gcc -static -shared -o libmicropython.dll *.o -lbcrypt
I get libmicropython.dll
you may download the static lib and dll from https://u.pcloud.link/publink/show?code ... 17kYll0fuy
Re: LUA?
I experimented for many years with Lua and PB and would say NO.
First of all it can easily be made into an open-source (User) Library handling the frequent problems and version changes. PB team should focus on the main body of the language, the simple and basic libraries + Ogre which is already a ton of work. Also as others pointed out other languages are frequently favored over Lua - for example Python.
Lua lacks "batteries" that are implemented in Python for example; all Lua "batteries" (libraries) like network are 3rd party, have often compatibility broken problems on big lua version changes, and may not be platform independent + redundant or blocking (compared to PB network library).
Lua is a little picky on it's implementation style. It's either 100% embedded or 100% extension. Meaning either it's 100% static lib compiled and ALL dll's/.so's that are loaded as plugins/extensions MUST also be static library linked or there will be problems; or 100% extension aka using the dll/so with ALL additional plugins/extensions also 100% compiled with dll extension mode.
This sounds easy but here is the catch: for Windows the developer recommends to use the extension (dll) version, but for Linux the recommendation is to use the static lua lib. This is not as easy as it sounds, creating a working static Lua lib is surprisingly hard (for me, on Windows, using it in PureBasic)
Long story short: better make an (open source!) User lib that handles versions, static/dynamic switch.
Things can get complicated when different Lua version have to work together (interpreter, compiled-source and execution may be each of different version and/or static/dynamic)
I am currently writing some "replacement" for Lua tables. It's just a "blackboard" inspired, Lua inspired key-value storage with optional destructor callbacks etc. It will perform faster for many internal things but for now of course there's no interpreter, byte-code execution or "eval" command yet. I'd like to write something like a GOAP planner and perhaps even something like STRIPS/PDDL interpreter, and for that to make sense one needs a useful "blackboard" and Lua is too unstable (because of the aformentionned problems) or has lesser "low level support" e.g. you can't access a table via it's pointer, always have to go via the stack and eval to access data.
Where it would make perhaps sense to implement Lua: in the 3D library, even though it may overload it then. Reason: CEGUI support for Lua, and mapping & handling 3D library objects like meshes etc with Lua would be a lot of fun, except when you don't need it then it's only bloating the DLL even more.
First of all it can easily be made into an open-source (User) Library handling the frequent problems and version changes. PB team should focus on the main body of the language, the simple and basic libraries + Ogre which is already a ton of work. Also as others pointed out other languages are frequently favored over Lua - for example Python.
Lua lacks "batteries" that are implemented in Python for example; all Lua "batteries" (libraries) like network are 3rd party, have often compatibility broken problems on big lua version changes, and may not be platform independent + redundant or blocking (compared to PB network library).
Lua is a little picky on it's implementation style. It's either 100% embedded or 100% extension. Meaning either it's 100% static lib compiled and ALL dll's/.so's that are loaded as plugins/extensions MUST also be static library linked or there will be problems; or 100% extension aka using the dll/so with ALL additional plugins/extensions also 100% compiled with dll extension mode.
This sounds easy but here is the catch: for Windows the developer recommends to use the extension (dll) version, but for Linux the recommendation is to use the static lua lib. This is not as easy as it sounds, creating a working static Lua lib is surprisingly hard (for me, on Windows, using it in PureBasic)
Long story short: better make an (open source!) User lib that handles versions, static/dynamic switch.
Things can get complicated when different Lua version have to work together (interpreter, compiled-source and execution may be each of different version and/or static/dynamic)
I am currently writing some "replacement" for Lua tables. It's just a "blackboard" inspired, Lua inspired key-value storage with optional destructor callbacks etc. It will perform faster for many internal things but for now of course there's no interpreter, byte-code execution or "eval" command yet. I'd like to write something like a GOAP planner and perhaps even something like STRIPS/PDDL interpreter, and for that to make sense one needs a useful "blackboard" and Lua is too unstable (because of the aformentionned problems) or has lesser "low level support" e.g. you can't access a table via it's pointer, always have to go via the stack and eval to access data.
Where it would make perhaps sense to implement Lua: in the 3D library, even though it may overload it then. Reason: CEGUI support for Lua, and mapping & handling 3D library objects like meshes etc with Lua would be a lot of fun, except when you don't need it then it's only bloating the DLL even more.
Re: LUA?
if you have msys2 installed you basically just run make, or you could just compile all the c files using gcc and then ar rcs liblua.a *.obenubi wrote: Tue Jan 28, 2025 3:52 pm ...
This sounds easy but here is the catch: for Windows the developer recommends to use the extension (dll) version, but for Linux the recommendation is to use the static lua lib. This is not as easy as it sounds, creating a working static Lua lib is surprisingly hard (for me, on Windows, using it in PureBasic)
if you have MSVC installed you could run the following from the console, changing the paths as needed
"D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
cd "lua-5.4.7\src"
cl /MD /O2 /c /GS- /DLUA_BUILD_AS_DLL *.c
ren lua.obj lua.o
ren luac.obj luac.o
link /DLL /IMPLIB:lua-5.4.7.lib /OUT:lua-5.4.7.dll *.obj
link /OUT:lua.exe lua.o lua-5.4.7.lib
lib /OUT:lua-5.4.7-static.lib *.obj
link /OUT:luac.exe luac.o lua-5.4.7-static.lib
Re: LUA?
I wouldn't think so if it only created a dll and it was statically linked into the program.PBJim wrote: Tue Jan 28, 2025 1:46 pmI'm certainly of the view that a JIT compiler could be extremely powerful, but would that mean the compiler's execution within an existing compiled PB executable would require the 'end user' of the object code to have a PB licence installed?idle wrote: Tue Jan 28, 2025 1:46 am I'd prefer a PBJit compiler, none of that interpreted stuff needed.
A number of years ago I made an experimental pb jit compiler with llvm in pb so its doable it was very limited but as an exercise it worked.
Re: LUA?
I'm just trying to visualise how that would operate. Would that require the PB compiler, and say, GCC or appropriate, installing on the executing machine — i.e. the machine with the runtime compiled PB executable?idle wrote: Tue Jan 28, 2025 8:20 pm I wouldn't think so if it only created a dll and it was statically linked into the program.
A number of years ago I made an experimental pb jit compiler with llvm in pb so its doable it was very limited but as an exercise it worked.
And just as a wild idea, is the following sort of thing conceivable, or intended along these lines?
Code: Select all
mycode.s = "OpenConsole()" + #CRLF$
mycode.s + "PrintN(" + chr(34) + "Hello world" + chr(34)) + #CRLF$
mycode.s + "Delay(1000)" + #CRLF$
Jit(mycode.s, etc. etc.)
Last edited by PBJim on Tue Jan 28, 2025 10:09 pm, edited 3 times in total.