lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Very interesting discussion, indeed :)

When I started with Lua, I made a parallel with the BASIC (the one from 80', the real one, not VB with is far away vs original BASIC concept) : Lua syntax is simple and accessible (for basic tasks), learning curve is very fast and even non programmer can progress easily.

But I faced rapidly 2 pitfalls :
- the 1st one is strings manipulation : sooner, you need to master RegEx to do even simple tasks with strings and I think it's a showstopper for beginners. Lua is missing simple but powerful string manipulation functions as the Basic has.
- the documentation. https://www.lua.org/manual/ is good ... but when you already knows a bit the language ... again, it's perhaps due to missing of non RegEx strings manipulation function.

Now, I have a quite "advanced" Lua usage : I love its lightness, how its (almost) easy to create a symbiosis between C (for low level / complex / resources consuming ... parts) and Lua (end user scripting). But the lack of affordable documentation or tutorials makes things sometime difficult. Coming to my mind :
* How to integrate Lua in a multi-threaded application when you don't want/can't recompile Lua ?
* How to launch Lua function again in multi-threaded application (passing function reference b/w context) ?
* How to retrieve data inside nested tables ?
* ...

Finally, I succeeded and I'm "proud" of results : https://github.com/destroyedlolo/Selene and https://github.com/destroyedlolo/Marcel which are matching my objectives.
As you can see, I'm sticking with 5.1 ... because luaL_register() has been deprecated and I was unable to find a clear way to migrate code like 

static const struct luaL_reg SelSurfaceLib [] = {
{"BlittingFlagsConst", BlittingFlagsConst},
... ,
{"CircleQuarterConst", CircleQuarterConst},
{"create", createsurface},
{NULL, NULL}
};

static const struct luaL_reg SelSurfaceM [] = {
{"Release", SurfaceRelease},
{"destroy", SurfaceRelease}, /* Alias */
...
{"restore", SurfaceRestore},
{NULL, NULL}
};

void _include_SelSurface( lua_State *L ){
luaL_newmetatable(L, "SelSurface");
lua_pushstring(L, "__index");
lua_pushvalue(L, -2);
lua_settable(L, -3); /* metatable.__index = metatable */
luaL_register(L, NULL, SelSurfaceM);
luaL_register(L,"SelSurface", SelSurfaceLib);
}

to newer Lua :(

Thanks

Laurent





Le Vendredi 17 mars 2017 9h45, Enrico Colombini <erix@erix.it> a écrit :


On 17-Mar-17 09:20, Dirk Laurie wrote:

> The main selling point of Basic was that its interpreter was small
> enough to fit into an 8K ROM.


Another point, not often considered, was its conceptual simplicity:
anybody could understand how to use it, so anybodyd did.

Other languages offer more power at the price of either complexity of
technical details (e.g. the C family) or deeper conceptual thinking
(e.g. the Lisp family, including Lua) and they have libraries to be
studied. They tend to be hard to master for non-technical people.

Lua makes a great effort to be simple on the surface (and it easily
beats most other languages here), but making full use of its non-trivial
power requires structured thinking.

BASIC could be reasonably understood by non-programmers, so many people
wrote programs in their domain of expertise. They were unrefined and
naive programs, but they often worked fine because the authors knew
their trade well.

Today's languages require professional programmers... and we often have
communication problems between the subject expert and the technical
expert. Assuming they are both actually expert, of course ;-)

--
  Enrico