The Right Lang for the Job

Exploring the abbyss of non-mainstream programming languages

AwesomeScript: Lua + Awesome + Haxe == profit!

My third attempt at getting a project off the ground

Last updated on:

I got a nice idea that I want to implement

There are two parts as to why:

  • the resulting project would be quite unique and interesting
  • the end result might actually also be of practical use

The problem is that I probably won't be able to finish the project alone and I'm looking for anyone insterested in and capable of helping.

Let me first tell you what it's about.

Three well-established technologies in one package

An example of what I want to do that is relatively well-known would be OpenRESTY. It's a distribution of Nginx web server bundled with Lua implementation and Lua bindings to various APIs, allowing you to generate web pages dynamically without ever leaving Nginx. This is in contrast to other languages, which live behind Nginx, not inside of it.

Due to coroutines, lightning-fast JITted implementation, and mature Nginx codebase, OpenRESTY is impressively performant, especially against its interpreted/non-JITted competition.

I want to make a package that similarly integrates a mature C codebase and extensive Lua bindings. I want to add one more component to the mix on top of that, but the general idea of creating a distribution of other projects is the same.

Awesome window manager and Lua

Awesome is a small and fast window manager for Linux. It supports both tiling and floatiing modes, is written in C and extended with a Lua class library. The core is relatively small and it can use LuaJIT (instead of plain Lua) without problems. Awesome uses GLib and Cairo for some of its functionality. It also uses XCB for window management, so it's currently coupled to X.

The class library is actually a full-fledged windowing toolkit. Widgets are defined in Lua, taking advantage of Lua tables' flexibility, and drawn on Cairo surfaces. Awesome is fast, consumes very little memory, and has potential for as much eye-candy as you'd care to add.

Multi-target transpiler - Haxe

Haxe is a gradually typed language that compiles to 7 different platforms, including Lua. It's a simple language on the surface, with some similarity to ECMAScript, but includes AST-based macros and an interface for compiler plugins, which allow for endless customization. Moreover, the compiler is written in OCaml, which makes it both very fast and easy to modify.

What are the benefits of bundling them together?

Glad you asked! In my opinion, Awesome could benefit a lot from Haxe. Not only is Haxe capable of performing various optimizations that you wouldn't care to do by hand (loop unrolling, dead code elimination, tail call elimination, etc.), but it also provides IDE-class intelligent auto-complete, type information, and documentation.

Lua is a great language, but using it well requires just about as much self-discipline as using JavaScript well. That is to say: a lot! Haxe adds a layer of safety and compile-time guarantees on top of LuaJIT dynamic runtime.

Enough chit-chat! What is it you want to build?

In short: a desktop environment inspired by Smalltalk. An environment where you can inspect and modify the code of every widget on the fly. Smalltalk is unapologetically dynamic, but so is Lua. On the other hand, Smalltalk-like IDE functionality would be hard to replicate for Lua. With Haxe in the mix, though, we can get a long way towards that functionality without lifting a finger.

There are problems of course. Haxe is not designed to make its output reloadable, and enabling this would

Inspect widget, edit source (in Emacs)

  • coroutines-based async in Awesome