RE: Xcb luajit bindings exist?

  • From: William Adams <william_a_adams@xxxxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Mon, 24 Aug 2015 04:26:01 +0000


Am I alone in thinking that HTTP (or any protocol) should be a pure Lua
library with no dependencies that should work over user-provided read()
and write() functions (plus utilities like compress(), decompress(), md5()
etc) ?


If that user provided read/write is backed by a scheduler, and a bunch of

other stuff, then yes possibly.




I think what you're really after is a 'stream' more than anything else. And
then

streams should be composable, as streams tend to be. I did it this way in TINN

where you have a basic 'stream' interface, which covers (readbytes,
read[inttypes],

read[string of specified length], read[stream]) and the equivalents for write.
Whether

those streams are sync, async, compressed, encrypted, in memory, to file
descriptors,

whatever, the higher level http routines don't really care. Just as long as
those routines exist.




I also believe that http 1.1 and http 2.0 should be treated separately, at
least at the

stream level.



Yes, I would think that a supplied read() and write() can handle all the
networking stuff behind the scenes, even including the multiplexed
connections (not that I think it would be easy, but possible).






Raise your hand if you're sharing my aversion to frameworks and
kitchen-sink libraries :)

\
\0
|\
||





I think the challenge you have in this space is getting the simplest, most
elegant,

composable design possible. Without an ability to compose (streams for example)

it's really hard to avoid the kitchen sink.




From my experiences, you need a minimum of a scheduler to handle your various
IO

coroutines. Of course you'll need to create special versions of your IO
routines to

match with your scheduler. Is that a kitchen-sink framework? You need to add
at minimum a

signaling facility to your scheduler, and probably timers (if you want your io
to timeout).




Beyond that, you don't need much more.




schedlua - https://github.com/wiladams/schedlua




Is an attempt at a fairly composable, minimalist scheduler, that can deal with
async io, such

as networking. Perhaps something along those lines is what might be interesting

as a non-kitchen sink approach. Basically only use what you want, starting
with a

signaling feature, and async sockets, which are totally optional.




And what does all this have to do with LuaJIT?




Mostly it's straight up Lua. The only LuaJITness of it is the ease with which
parts of the

native OS can be incorporated using FFI. LJSyscall makes a lot of this almost
mindlessly

easy.

Other related posts: