RFC: Modules in separate directories vs single directory


  • Based on the feedback that I received recently and in the past about the luapower directory layout, it seems that there's a preference for having packages in separate directories, as opposed to having them in a shared directory as it is now. So I figured I'd analyze the pros and cons of each model, and maybe start a discussion around that.

    Before I start, note that the way luapower is designed with its specified directory layout and everything, it would be easy to support a separate directory model without having to give up on any of the advantages of the current model, except maybe for some added runtime complexity.

    Separate directories

    Pros

    • not having to download/learn/use multigit
    • not having to use git either, using the filesystem as the package manager instead
      • easy to see which files belong to which packages
      • remove package is as easy as rm -rf packages/foo

    Cons

    • needs a custom require() loader, which also needs to patch ffi.load()
    • needs to scan the entire directory tree, for modules that don't match the package name (very rare but might happen)
    • dependencies of shared libs need to be known in advance and preloaded (this one is particularly ugly); possible solutions: a) parse the PE/ELF/MACH file formats, or b) maintain manifest files in the package directory (or parse the WHAT files)
    • using git directly is a tad more tedious: cd packages/foo; git pull; cd ../.. instead of mgit foo pull

    Single directory

    Pros

    • no need for a custom loader to find and load modules
    • adding a luapower tree to an existing luajit installation is as easy as adding a search pattern to package.(c)path
    • no need for hacks to load dependencies of dynamic libraries

    Cons

    • depends on git and multigit for package managerment ops (add/remove/pull/push)
    • .git directories add ~250M to the disk space requirements

    Thoughts?


  • 1
    Posts
    570
    Views
    Log in to reply

Internal error.

Oops! Looks like something went wrong!