In clearing out some old WordPress posts, I came across some code from 2009 for slightly simplifying the use of MySQL parameterized queries in PHP. A blog post is a ridiculous place to leave reusable code, so I created the mysqli_improved repository on GitHub.

The code is so simple and honestly incomplete that I almost published it as a gist. But gists are only one step away from long-forgotten blog posts: gists do not encourage improvement upon the original author’s idea. Granted, GitHub Gists are forkable and treated as repositories, but the code in a gist is typically not a ready-to-use library (admittedly, my mysqli_improved project is gist-like). An open source code repository is the best place to store library code you believe in. People will watch your repository if they find value in what you’ve made, fork it if they can improve upon it, and hopefully create a pull request if they believe their contributions work for a general case.

This is not to say that code has no place in a blog, or that gists are useless. Both tools have their place. I’ve gained much knowledge from tutorials and code examples posted in blogs. Articles give you the opportunity to explain things about your code that aren’t readily apparent to outsiders. Gists have a similar spirit: they provide example implementations of useful features, and are a handy way to share code when you don’t have the time or will to build out a reusable library. Do you have some one-off code that others might find helpful? Toss it in a gist. Did you have a really tough time figuring out how to write that code? Write up a tutorial. Do you see a future where many developers are using what you’ve written because it’s generally useful for many applications? Perfect, make a repository under an open source license.

While, again, my mysqli_improved repository is not great, I chose to publish it and see if there is any interest from the community. I almost threw it away. It’s just not that interesting any more. I’ve long since moved on to other programming languages and don’t frequently access a database without an ORM. However, I knew what would happen if I trashed the code: no one would care. I didn’t know what would happen if I kept it around a bit longer in a public code repository.

My concern is that plenty of other people may have had the same fleeting thoughts and made a different decision. How much interesting and useful knowledge is discarded by people who no longer need it, and how much is rotting in obscurity in old unmaintained websites? My plan going forward is to expose whatever I can as a reusable open source library, to give the knowledge the best chance of thriving and evolving in the projects and minds of others.