Lua Server Pages

Lua Server Pages, a Lua scripting engine plug-in that blows away any other approach to embedded web development, offers a dramatic short cut to traditional C server pages. The Lua Server Pages plug-in (included in the Barracuda Application Server) makes developing applications extremely fast, simple, and safe. Notably, it isn't limited to developing web applications, but can also be used to provide high-level socket APIs that make developing secure socket applications very easy. We also provide HTTP client libraries, SMTP (mail) libraries, etc. In fact, we estimate that up to 80% of a modern embedded system could be implemented using Lua Server Pages, ensuring dramatically reduced development time.

How Lua Works

Lua is a scripting language and includes a compiler that compiles the scripts on the fly to a register-based instruction set. The instruction set is then executed by the virtual machine. The Lua compiler and the virtual machine are implemented in C code and can run in virtually any device with sufficient memory. The Barracuda Application Server, the Lua Server Pages plug-in, and all plug-ins required by the Lua Server Pages use roughly 600 kbytes of ROM. We recommend a minimum of 500 kbytes RAM for running your scripts.

Lua is the only module in the Barracuda Application Server not developed by Real Time Logic. Lua is licensed under the terms of the MIT license and can therefore be used in any commercial product without any restrictions. See the Lua license for more information.

Why Lua?

Customers Discover the Benefits of Lua Server Pages

We have customers using the Lua Server Pages plug-in in everything from deeply embedded monolithic systems, such as in Xilinx FPGAs, to high-level host systems, including Linux and Windows. The Lua virtual machine can be compiled for any microprocessor architecture, including CPUs embedded inside FPGAs such as an 80MHz ARM processor that is sufficient to run the Lua virtual machine. The web page you are reading now is managed by Lua Server Pages and runs on an embedded device.

Customer Testimonial:

"It was great that you drove the point across regarding the benefits of using Lua. I think that most embedded people, such as myself, would initially gravitate towards C code and CSP because it's a familiar environment and disregard Lua without realizing the huge benefits that can be gained with only a little bit of an upfront cost of having to learn the Lua language. BTW, you definitely made us think about Lua a whole lot more and not just as a server-side scripting language but as a scripting language that we could potentially use throughout our entire project." - Honeywell employee attending our three day training.

Lua Server Pages Advantages for Embedded Web Development

Lua is not your average scripting language. Lua is small, fast, portable, and embeddable. These cornerstones of the language make it well-suited for embedded devices, web applications, and protocol stacks.

Lua Book
The Lua Book
  • Lua Server Pages are designed to be embedded.
  • Lua Server Pages use one of the fastest scripting languages available.
  • Lua Server Pages are small.
  • Lua Server Pages are easy to learn.
  • Lua Server Pages are designed to help you cut development cost and time to market.

See our whitepaper Lua fast-tracks embedded web application development for more information on how Lua simplifies and speeds up the development process.

Lua Server Pages Development Process

The Lua Server Pages development cycle is a straight-forward, three-step process. Recompiling a modified Lua Server Page and executing the Lua Server Page is as simple as refreshing the browser window. When the browser sends the request, the server loads, compiles, and executes the new script. The figure to the right illustrates this process.

The Lua Server Pages plug-in comprises the Lua engine and interface logic to the Barracuda Application Server's C API. The interface logic is referred to as a "Lua binding" and makes it possible for Lua scripts to call C functions. We provide bindings to most of the C APIs in the Barracuda Application Server, including plug-ins such as the WebDAV Server. The Lua Server Pages plug-in is designed to be extended and lets you add your own device management APIs. We also provide an online C parser that automatically generates Lua bindings for your C device management APIs.

Lua Server Pages require that you provide some start-up code in C, but no C code is required when assembling web-server components. All components, including opening server listen ports, managing SSL certificates and so on, can be dynamically managed from within a Lua script. Lua also makes it possible to dynamically add and remove server components in a running system. For example, you can dynamically change the listen port numbers without restarting the server.

Refresh Browser

Lua Server Pages Development Process