Skip to content

Latest commit

 

History

History
112 lines (87 loc) · 7.85 KB

github.md

File metadata and controls

112 lines (87 loc) · 7.85 KB

Introduction

Luapower is a modular and portable LuaJIT toolkit for Windows and Linux, with everything from native OS API bindings to portable sockets, threads, windows, graphics, etc. It comes with documentation, binaries and the ability to create single-executable apps (desktop or command-line).

Its website luapower.com was taken offline in 2024 after 14 years of operation. Nevertheless, all the code and docs are still on github and everything works as before (lupaower was designed to not have to depend on any website at all). Note that the documentation for each project is not in README.md as expected but in <module_name>.md because all the files from all the modules are supposed to be dumped together in the same directory - see this, so make sure to click on <module_name>.md to see what the module is about. But note that the docs are not written in Github's flavor of Markdown but in Pandoc Markdown, so things may look scrambled on github occasonally (esp. tables). The best way to view the docs is to open them in your code editor (that's how they were meant to be used in the first place so that they are also easy to write and amend).

Features

  • LOW-TECH: based on http, zip, and git
  • PORTABLE: no install, no deploy, just run
  • MODULAR: each module is a separate git project
  • ON GITHUB: fork/pull-request-based collaboration
  • NO DIRECTORIES: all modules in a single directory
  • BINARIES for all platforms: get code running in minutes
  • SOURCES & BUILD SCRIPTS: upgrade it yourself, don't wait for others
  • PACKAGE DATABASE: self-maintaining, auto-generated
  • DOCUMENTED: online browsing or offline grepping; powered by pandoc
  • FREE: no-strings attached

Get Started, the download-and-unzip way

  1. download luajit
  2. choose & download wanted packages and their dependencies
  3. unzip all over the same directory
  4. (optional) rebuild binaries
  5. run a demo: luajit ..._demo.lua

This will give you an instantly portable luajit distro that will work reagardless of where you run it from. The luajit binary is in bin/<your-platform>/ (cross-platform shell wrappers are in the root dir).

Get Started, the git-clone way

Alternatively you can go the git way with multigit which allows you to:

  • clone/build everything in one shot,
  • keep your modules up-to-date by pulling,
  • create your own modules and publish them.

More to read

Modules

Here's some of the modules, in no particular order (there are many more in there):

  • winapi, a binding of Windows API, including windows, common controls and dialogs, message loop and system APIs.
  • cairo, a binding of the cairo 2D vector graphics library.
  • sock, a coroutine-based socket library with IOCP, epoll and kqueue.
  • http, a HTTP protocol library that is independent of the socket library used for I/O.
    • http_client with TLS, compression, persistent connections, pipelining, multiple client IPs, resource limits, auto-redirects, auto-retries, cookie jars, multi-level debugging, caching, cdata-buffer-based I/O. In short, your dream library for web scraping.
    • http_server with TLS, compression, persistent connections, pipelining, resource limits, multi-level debugging, buffer-based I/O.
  • fs, a portable filesystem library that supports UTF-8 filenames, symlinks, hardlinks, pipes and mmapping on Windows, Linux and Mac.
  • coro, adds symmetric coroutines to Lua and modifies standard coroutines to not break inside scheduled coroutine environments.
  • resolver, a DNS resolver that queries multiple servers in parallel and uses the result that comes first.
  • glue, an "assorted lengths of wire" library for Lua.
  • oo, an object system with virtual properties and method overriding hooks.
  • dynasm, a modified version of DynASM that allows generating, compiling, and running x86 and x86-64 assembly code directly from Lua.
  • objc, a full-featured Objective-C and Cocoa bridge for LuaJIT.
  • nw, a cross-platform library (Windows, Linux, Mac) for working with windows, graphics and input (like SDL but in Lua).
  • ui, an extensible UI toolkit written in Lua with widgets, layouts, styles and animations (leverages my Terra work).
  • path2d, a fast, full-featured 2D geometry library written in Lua which includes construction, drawing, measuring, hit testing and editing of 2D paths.
  • bmp, a Windows BMP file loading and saving module that handles all BMP file header versions, color depths and pixel formats.
  • tweening, an animation library inspired by GSAP.
  • thread, a cross-platform threads and thread primitives for Lua.
  • webb, a procedural web framework for Lua, which besides being something totally incomprehensible to the web kids today, makes building web apps fun again, with very low amounts of code, no tooling and no offline processing ("building" as the kids call it).
  • mustache, a full-spec mustache parser and bytecode-based renderer that produces the exact same output as mustache.js.
  • bundle, a small toolkit for bundling together LuaJIT, Lua modules, and other static assets into a single fat executable.

Terra libraries

Related to LuaJIT is Terra, a low-level programming language that is meta-programmed in Lua. Although it's a LLVM frontend, Terra's metaprograming features allow you to "lift it up" from its basic C semantics to C++ level capabilities and beyond, so you can code at different levels of abstraction as your problem demands without sacrificing performance, which is arguably the holy grail of all programming. Here's some of the more advanced modules written in Terra that are part of luapower:

  • terra.layer, a HTML-like box-model layouting and rendering engine with a C API.
  • terra.tr, a Unicode text layouting and rendering engine with a C API.
  • terra.binder, Terra build system, C header generator and LuaJIT ffi binding generator.

I've since started my own Terra fork called miniterra.

JS libraries

x-widgets was a collection of model-driven live-editable web components in pure JavaScript, including a fast editable virtual grid component with 3-way-binding and master-detail linking, useful for writing backoffice-type business apps.

It was abandoned in favor of canvas-ui. I've written about it here.

WebGL2 libraries

There's also a 3D math library for WebGL and a tiny WebGL2 wrapper in there but the documentation on that is sparse.