scripting language timings for libgit2

Was curious if I really need to use C to write this fast git prompt thing. libgit2 has bindings for many languages, but scripting startup time can really suck. Here’s a quick test of how fast a program can be that does nothing but open the repo (on Linux, local disk).

  • C: 1ms
  • Python 2.7: 17ms
  • Python 2.7 with -S flag: 4ms
  • Lua 5.1: 2ms

No surprise Python is so slow; even the null program is 14ms or so, a weakness of stock Python. Surprisingly there is no Perl binding listed; that’d be another option for fast startup. There is one for Parrot. Also Go, which could be a suitable modern upgrade for C.

Lua’s a fun little language, I should switch my development efforts there just so I have humane strings. Can always port back to C later.

All this testing is a huge PITA because the last stable release of libgit2 is 11 months old (0.17.0) and since then they’ve changed the API in all sorts of places. My C and Python tests area against the HEAD of the github repo. Lua is against 0.17.0. This lack of stability makes me question whether libgit2 is really the right choice for something as ubiquitous and lowlevel as a shell prompt. They aren’t kidding when they say it’s alpha software, I guess.

Doesn’t help that I was in dynamic linker hell, btw. On Linux it seems to cache things pretty aggressively; I had to manually run “ldconfig” as root to get it to switch from one version of libgit to another. I used to be good at this sort of nonsense but it’s been years since I’ve worked in such primitive environments.

So, quick conclusion: Lua would work for development.