Reinventing the wheel
Sometimes things are good enough. Sometimes you can work around the problems and make do. Sometimes you have to start from scratch.
Last week I was tapping away in SciTE, trying to overlook its obvious shortcomings as a text editor, as I always do, since it's the best that I can find. I was writing a program to tunnel telnet over HTTP, because neither protocol on their own was good enough for what I was doing. I was writing it in Python, which doesn't offend me as much as some languages, but it's still not perfect. I tried using socket libraries, but none of them fit my exact requirements, so I decided to write my own abstraction, despite the obvious design flaws in sockets that I would have to work around. After a while, I was happy that my program did what I needed, and decided it was time to make it run in the background as a proper daemon process. I then began my hunt for python daemon libraries - and it turned out that although there were many, they were either buggy, unfinished, or missing crucial features. Eventually I found one that looked reasonable enough to use, with only a couple of obscure bugs. Only there was no documentation.
If you have ever written a plugin or library that completely lacks documentation, I hate you.
What is the point of you spending hours working away on something, just to release it to the world in a state where someone will need a thorough understanding of the problem to go through your code line by line to figure out how to use it? What is the point of writing thousands of lines of code without leaving any comments? What is the point of you? Nothing. Stop wasting my time and get the hell off my planet. Sociopath.
It is at times like this that I often think it would be a good idea to write my own. From the past bitter experiences that are the many half-finished projects which litter my hard drives, I know this isn't always the right thing to do. Reinventing the wheel leads to anger, anger leads to hate, hate leads to not getting your code finished by the deadline. So this is something I generally try to avoid these days.
But despite my best intentions, it still seems that almost every non-trivial project I work on needs a semi-abandoned yet somehow best-of-class plugin or library where the developer has spent the past 17 months filling their blog with useless posts about how the next version will be way more awesome, which is why they can't be bothered to fix any of the bugs. Almost every non-trivial project I work on therefore involves writing an abstraction layer between my code and their dross, letting me work around the bugs I discover and fill the rest of the file with comments to the effect that if there is a god out there somewhere, please will they smite the developer who has inflicted this living hell on me, so that someone else spots an opportunity to develop a marginally better library that I can write a new abstraction layer for, and fill with some new and more inventive insults.
Sometimes things are good enough. Sometimes you can work around the problems. Like this time; I left it as it was, and ran it using upstart
. That'll do, pig.
So if I solved that one, the reason for this post? Today I tried to get PIL to draw a rectangle with a 4px outline.
Well, actually I was trying to get it to draw a placeholder image, a simple rectangle with diagonal lines from the corners. I wanted it to use 1px lines, but since I didn't want it to look ugly and PIL can't draw anti-aliased diagonal lines, I had to supersample, meaning wider lines. With such a well-established and mature library such as PIL, you can reasonably expect these sort of common requirements to be met, and the diagonal lines were indeed a couple of lines using reasonably sensible arguments. But for some reason the developers clearly decided that setting a width on the outline of a rectangle was something that nobody would ever want to do.
Do I sigh as normal, leave a comment or two in my code, and work around it by drawing several lines or one rectangle inside another? No. Enough is enough. Developers of the world should be able to expect two similar functions in a library to accept similar arguments, particularly when it comes to setting the width of the lines on a rectangle. It is time to draw a line. Hur hur.
I therefore announce with much pride and delight, that I have decided to write my own version of PIL. One which doesn't suck.
My image library will have a sensible and consistent approach regarding line width, and will anti-alias your diagonal lines for you, if you want. While on the subject of images, I've never liked the common image formats, so my imaging library will use its own format, which is specifically designed not to suck. Of course though, there seems little point writing it in an imperfect language such as Python, so I will be writing my own programming language too. Since there are no decent text editors available, I'll also write a new one of those.
While I'm at it, I figure I may as well come up with replacements for HTTP, telnet, sockets, and every other nonsense aspect of these terrible modern-day operating systems, so I can rewrite my program from last week in a more sensible way. In fact, I will use my new programming language to develop a new operating system, which will be better, faster, stronger. Although for a long time I've thought that machine code is terribly inefficient, so I think I may need to develop my own CPU too. I can probably do something to improve GPUs at the same time, so in fact, I'll be developing my own computer architecture to make sure that my image library will always be operating at peak efficiency.
Actually, I've always suspected semiconductors are a crap way to do microelectronics. I should probably start there.
Comments
We're going to Thailand!!
Can you make PythonMagick work, while you're at it?
I gave up on PythonMagick, it was even worse than PIL! Seems there's very little in the way of open source imaging libraries which doesn't suck.
Got screwed again the other day by a jQuery colour selector plugin. Works fine until you scroll the page. Have these scum never heard of testing?
Today I may bake a pie.
Leave a comment
- Add a comment - it's quick, easy and anonymous