LAPHLibs gets a makeoverPosted: June 18, 2015
Quite a while ago (it looks like about 3 years), I create the LAPHLibs repository. It was an outgrowth of various projects I was doing, and an experiment in open licensing. The repo is full of routines varying from hash functions to bit banging. Not a ‘library’ as such, but just a curation of things that are all pure LuaJIT code based.
Well, after I spun it out, I didn’t show it much love. I made a couple of updates here and there as I found fixes while using the routines in other projects. Recently though, I found that this is the most linked to project of all my github based projects. As such, I thought it might be useful to give it a makeover because having all that bad code out there doesn’t really speak well of the Lua language, nor my learnings of it over the past few years.
So, I recently spent a few hours cleaning things up. Most of the changes are documented in the new CHANGELOG.md file.
If you are one of the ten people who so happens to read this blog, and are a user of bits and pieces from that library, you might want to take a look.
One of the biggest sins that I fixed is the fact that in a lot of cases, I was polluting the global namespace with my functions. It was inconsistent. Some functions were global, some local, sometimes even in the same file! Now everything is local, and there are proper exports.
I also got rid of a few things, like the implementation of strtoul(). The native tonumber() function is much more correct, and deals with all cases I had implemented.
There are a few places where I was doing idiomatic classes, and I cleaned those up by adding proper looking ‘constructors’.
Overall, the set of routines stands a little taller than it did before. I can’t say when’s the next time I’ll do another overhaul. I did want to play around a bit more with the bit banging stuff, and perhaps I can add a little bit more from projects I’ve done recently, like the schedlua scheduler and the like.
Bottom line, sometimes it’s actually worth revisiting old code, if for no other reason than to recognize the sins of your past and correct them if possible.