lua-users home
lua-l archive

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


Evan DeMond wrote:
On Wed, Oct 22, 2008 at 12:24 PM, Ryan Knotts <jknotts@gmail.com <mailto:jknotts@gmail.com>> wrote:

    Maybe I am not thinking this out correctly but here is my thought
    process. I plan on having some modules that use LuaSocket so I figured
    that if I could I wanted to just use LuaSockets for everything. This
    is to cut down on the bloat of including 2 socket libraries (the C
    library and LuaSockets) so I was hoping that for my straight C code I
    could take advantage or somehow call the LuaSockets C functions and
    for my Lua modules use the same library but make the appropriate Lua
    calls. I just dont want to include more libraries than I need to.

I think LuaSocket just uses the same library that you would if you were writing your own socket calls. I'm not 100% sure, but I don't think this should increase your memory footprint. Even if it did, it shouldn't increase it significantly at all, so don't worry about optimizing away that amount of "bloat" if it inconveniences you.

First sentence is not quite correct. LuaSocket has got a multi-platform compatibility layer done in usocket.c and wsocket.c, so it may seem convenient as it embodies a lot of developer effort. But, is it really necessary to drop down to C? Unless there is some critical performance requirement, I think it's easier to just stay in Lua. Computers nowadays have oddles of performance. After all, http, ftp and smtp are all written as Lua modules in the same LuaSocket, so you can also add your own module running over the sockets module. I remember what Donald Knuth said about optimization...

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia