Komputeko programming and bugs
I am working on a rewrite of Komputeko.net. The current website is written in PHP, mostly barely correct, if even, code, hard to maintain, hard to extend, but hey, it works! I am writing the rewrite in Go, and it serves me well. I put the code online on Github (Komputeko on Github) and today I got rid of a very stupid bug in my code base.
The case is that I found a lot of duplicates in the results shown on the screen. To find the source of the bug, I checked if something in sorting went wrong; nope, sorting is not perfect as it is now, but it is surprisingly fast and it didn't magically add entries. So I started to measure the difference in input and output at several points, to find out that I checked for the appearance of the keyword and at every appearance, which can be several, I added that row to the result. In the end it seems I managed to blow up the used database this way in some orders of magnitude, at least more than 10 times! Adding a little flag so I add the result only once instead of every time for results found quickly solved this.
I needed an other commit to fix the bug I introduced here that involved not resetting the flag for every pass of the for loop...
Then when profiling the code (manually, one time I would have to use the Go tool for it, but my code is quite small so this is pretty efficient manually at the moment) it turns out that the bottle neck is in the HTML rendering. Of course I should move this all to the template anyway, but it's good to be reminded of this "hard way".
Anyway, the code is up on Github, so I welcome all feedback!
(The code doesn't have a license yet, a cardinal sin. I tend to use CC0 but I'm not sure yet if the owner of Komputeko agrees with that, so for now if you want to reuse, shoot me a mail, you will definitely get my permission, and the license will come later on.)