## Idea

Write as much of Sumatra as possible in Lua

## Why

1. Writing Sumatra becomes harder and harder due to long compilation times

2. Writing in Lua would be faster thanks to garbage collection, closures and
other higher-level functionality

3. As a result of 1, testing different approaches (e.g. to layout system) is
too expensive so we don't do it. With lua we could hopefully test various
things by writing small scripts

4. We're writing half-assed functionality that Lua would give us for free.

Layout definitions that we parse from text (EbookWinDesc.txt) could be lua
script.

Settings file could be de(serialized) lua data.

MuiCss.h is a semi-dynamic system that would naturally could be done via lua
objects.

5. With lua it would be possible to add new code to running app, without the
long re-compilation needed with C.

## How

The ultimate goal would be to have lua be the driver and call C functions
(as opposed to C code calling Lua scripts).

The road from here to that will be long. Here's a possible approach:
- validate writing UI code with luajit is sensible by writing sample apps.
  In those apps recreate some of the Sumatra functionality.
- write luajit FFI bindings to libraries we use
- integrate luajit and replace some small functionality with lua code
  (e.g. parsing layout definitions)
- everything else

Such project would require lots of effort and would take a long time but I'm
very interested in exploring this approach.

## References

LuaJit
. http://luajit.org/
. Because it's faster than Lua and has great FFI which allows calling Windows
  APIs

MoonScript
 . http://moonscript.org
 . Because it's much better syntax than Lua (inspired by CoffeeScript) and
   it's fully interoperable with Lua (it compiles to Lua)

Various win32 API bindings
 https://code.google.com/p/lua-files/source/browse/#hg%2Fwinapi
 https://github.com/Wiladams/LJIT2Win32
 https://github.com/Wiladams/TINN
