11 ms·
For some time, I happen to use a machine with very very meh CPU performance. Turns out, popular scripting languages are slow, except for Lua. (And maybe also Pe
by aasasd 7y ago
For some time, I happen to use a machine with very very meh CPU performance. Turns out, popular scripting languages are slow, except for Lua. (And maybe also Perl, didn't check yet.) I thought that JS has fast start-up, but some Lua scripts of mine that do file IO are finished in less time than Node's ‘hello world’.
I now wish people used Lua everywhere instead of JS, Python or Ruby. Some are doing desktop programming in JS, for personal productivity software, like Alfred alternatives Zazu and Cerebro. Eeeeh nah, productivity software needs to be fast. Would be lots better to do that in Lua. And it's certainly a better idea for editor plugins than using Python.
Fennel transpiles code to Lua so fast that it's feasible for scripting, even on my machine.
I believe also that Lua might be able to do true parallelism, via libraries. (Haven't tried yet, though.)
- minxomat 7y agoI build Lua programs in prod. I use fennel or moonscript as the frontend, and everything runs on openresty (cli tools using resty and servers using the full stack). Parallelism is enabled by a data flow architecture on top on nginx workers (compare TPL Dataflow in C# or Intel TBB in C++). Concurrency is enabled using coroutines (nginx threads). It's virtually impossible to write blocking code and that's without any async or other bs in sight. It's really fcking fast. Like, some parts of the overall arch are rust, but in the real, io bound world there's virtually no speed difference. Of course safety is good. But you get types and other neat zero cost abstractions for Lua using Haxe. This Dataflow architecture also benefits from openresty built in concurrency safe queues, maps etc with atomic commit and cross worker access. Everything feels so damn effortless. I didn't have to do any work on making it scale. Just tweak the number of workers knob and boom, almost linear benefit. That's for rust and Lua, both awesome at parallelism in this case. Anyway, even though I never write pure Lua, I still think it should have won against python (man did we try, even riding that ML wave). I'm in love, but me is not many.
- rcarmo 7y agoWhat sort of queueing mechanism do you use? I’ve bee trying to get into OpenResty but there are few documented examples of that kind of thing, and anything that does Dataflow is interesting to me.
- minxomat 7y agoBidirectional queues are built-ins in openresty[1]. The scheduler is project-specific and uses that. [1] - https://openresty-reference.readthedocs.io/en/latest/Lua_Nginx_API/#ngxshareddictlpush https://openresty-reference.readthedocs.io/en/latest/Lua_Ngi...
- bjoli 7y agoI have been using guile on my rock pi to do multithreaded things (using guile fibers, which works over pthreads). It is not a big project, only an IRC bot. Heavily over-engineered with the goal of being able to process more IRC messages from more sources than anyone will ever need. It isnt usable yet, but it can handle all traffic a raspberry pi 4 can deliver which is close to 60 mB/s spread over 100 simulated channels. Currently each channel bot just tried to find the largest integer posted , so there are no IO bottlenecks. Startup is instant once compiled, and compilation usually takes less than 0.5s depending on how much I changed.