Wednesday, December 07, 2016

What's great about Lua?

Lua is an amazing programming language implementation. I say implementation because it is not just the language itself but how it is implemented that is particularly impressive.

As a programming language, Lua can be characterised as a small but powerful language. The power comes from clever use of a few core meta-mechanisms as Lua authors like to put it. A nice introduction to some of these are in the recent talk by Roberto Lerusalimschy at the Lua Workshop 2016.

I used to think that Lua is a simple language; but appearances are deceptive. I now think of Lua as 'small' and 'powerful' language rather than a 'simple' language.

The language design is clever, but the implementation is what makes it great.

Firstly it is a very compact implementation, just a few C source files, and that's it. No dependencies other than an ANSI C compiler.

Secondly, despite the compact implementation, it features:

  • A byte-code compiler and Virtual Machine.
  • An incremental garbage collector.
  • Extremely fast parser and code generator.
  • And the language is delivered as a library with an extremely well designed C API, that makes it easy to embed Lua as well as extend it.
It is this combination of economical design and beautiful implementation that makes Lua great.

Lua 5.3 Bytecode Reference

Lua bytecodes are not officially documented as they are considered to be an implementation detail. The best attempt to document Lua bytecodes is the A No-Frills Introduction to Lua 5.1 VM Instructions by Kein-Hong Man. However this document is quite old now and does not reflect the changes made since Lua 5.2.

Some time ago I started an attempt to bring this document up-to-date for Lua 5.3. I recently managed to spend a few hours updating the new Lua 5.3 bytecode reference. This is still not complete but the most important bytecodes are covered.

I want to eventually produce a version that is like a specification, i.e., one that allows independent implementations to replicate the bytecode generation. My interest in this is due to my desire to create a new parser and code generator for Lua. 

Thursday, August 25, 2016

Unique problems of a start-up

Well recently I took the plunge and started my own tech start-up after years of thinking about it. So I have been battling the usual things that many start-ups face I guess.

Of great help are inspirational talks such as these.

First is the talk by creator of Ruby on Rails - David Heinemeier Hansson at Startup School 08 where he talks about how to create a successful start-up.

Next is this talk by Walter Bright where he talks about how he started the programming language D, and he describes the way he works.

My journey has only just started. I would love to discuss some of the issues that start-ups face and how I am trying to solve the ones I face.

Friday, August 19, 2016

I love the new Microsoft!

I have always been a Java person ... until now. With the new cross platform open source CLR (.Net) platform from Microsoft, I am doing exciting new work in C#!

I also love the Linux subsystem on Windows 10 - which I installed today. I was able to build my Lua derived scripting language Ravi using Linux tools right within Windows. I did not enable LLVM but that is next on my list to try. If this really works, then I can decommission my Linux Virtual Machine.

I also love that Microsoft's made the Visual Studio Community edition free - and this is the full version and not a cut-down version. And the new Visual Studio Code editor is great - checkout my Lua/Ravi 5.3 debugger extension for it!

All in all - great stuff, Microsoft!  

Friday, July 29, 2016

Never been as good as now for creating software

When I started building software 25 years ago, one had to pay for everything, even a basic C compiler was not free. There was no internet, no Linux, no OpenSource.

The computing world has really moved on.

Now when one starts a project there is a whole range of OpenSource building blocks one can choose from. And really cool stuff too. In no particular order here are some of the projects that have excited me in recent times:

One could go on. The wealth of knowledge that is now accessible to all is tremendous, and it is all there for anyone who is interested. 

I think this is our time - we who create software. The world is being changed forever as software will drive everything everywhere, and we, the software creators, are at the core of this revolution.

Wednesday, July 27, 2016

From Java to C#

I am using C# for the first time in a major new project. This has been made possible thanks to Microsoft's open sourcing C# and making it cross platform. I am using C# both on the client desktop as well as the server backend.

My initial impression is that as a language C# is much more productive than Java!

If only Microsoft had done this earlier - the programming landscape might have been quite different today. Java still has an advantage of a larger eco-system in the opensource world, especially when it comes to writing server applications. 

Saturday, October 31, 2015

Lua Workshop 2015

I presented Ravi at the Lua Workshop 2015 held at Stockholm. You see see the slides of my presentation here.

Saturday, August 22, 2015

An LLVM binding for Lua

I announced the development of Ravi back in January 2015. It started as an experiment - I was not certain whether Ravi could achieve the performance levels of LuaJIT, the reigning monarch for Lua JIT compilation.

I am pleased to report that Ravi is able to match LuaJIT's performance for a few selected benchmarks. More details are available here. While this is positive news, there is still much to do to make Ravi competitive in a variety of situations.

LuaJIT offers a powerful FFI interface for interfacing with external libraries and like. This is very convenient for sure, but the approach taken is not compatible with Lua. After some thought I decided that rather than creating an FFI interface for Ravi, a more general capability would be to allow both Lua and Ravi users to write JIT code using LLVM. Work on this has just started so there is not much to show yet, but I hope to make progress fairly quickly.

LLVM is a very low level api - lower level than C. This has its pluses and minuses. On the plus side the LLVM binding will allow Lua and Ravi users to exploit the full power of LLVM. On the minus side even writing trivial functions can be quite some effort.