Getting stale…
by Solar on Feb.25, 2010, under Uncategorized
I fear this is getting stale. It seems I am not a “born blogger”; too irregular are the times where subject, need, and time come together to form a new blog entry.
I will leave this online for some time in case things change, but be prepared for this blog to vanish in the long run.
Turnaround is fair play
by Solar on Aug.26, 2009, under Uncategorized
Don’t get any ideas, I haven’t forgotten the other system around just begging to be ridiculed: Windows. The problem here is, Windows quirks usually leave me speechless, which isn’t a desirable state for a blogger to be in.
Today I tarballed the working directory of PDCLib to do some editing while on the road. When I had a minute, I untarred the archive on a Windows machine, because I had some ideas regarding how to handle errno in a way that doesn’t stall the FPU when handling math.h code. (Yes, the C standard is stupid, too, in certain places. Even P.J. Plaugher admits as much.)
Problem is, all the references I use - the standard document, other PD sources - reside in a subdirectory I named “aux” (for “auxilliary”).
Can’t unpack that under Windows. It appears the file system reserved that name, for whatever reason, and flat-out chokes on anything named “aux”. It’s such an unusual name, too.
Speechless.
Less complainy, more codey
by Solar on Aug.19, 2009, under General Life
Right now I am focussing on my own development project, PDCLib, which had a dry spell for a couple of years, and is in dire need of the next release. So, no witty posts from me for a while, sorry.
“The 42 Flame”
by Solar on Jun.23, 2009, under Uncategorized
I originally intended to build this up slowly, over many posts. I should have known I wouldn’t find the time and patience to do this, either…
And when there was a thread at OSDev: What’s free? BSD vs. GPL, I found I had summarized many of my feelings in one single, if not that eloquent, post. The flame to answer the question of life, the universe, and everything. To bring it to a larger audience (and to get a new blog entry online), I copied it here.
I’ll probably extend some of what I say here in later posts, but for now, consider me on summer vacation.
Paxcoder wrote:
You say GPL wants us to “share-the-way-we-tell-you-to-or-don’t-distribute”, but I’m asking: what’s the problem in that kind of sharing?
I’ve got a problem with how the GPL folks took the software market, which had commercial software, shareware, freeware, public domain, and half a dozen other licensing shemes, and effectively turned it into a duopol: Either you are GPL, or you are evil - or at the very least a misled unbeliever that has to be evangelized.
I come from the Amiga community. During its heyday, some of the best software utilities I’ve ever used were shareware. Some crippled with a key to unlock the licensed-only functions, some uncrippled and relying on the honesty of the user to earn the programmer’s living. No-one had any problem with that. Some re-wrote the functionality and released it for free, and people could decide if the shareware was that much better that it was worth paying for.
Today, “not free” has become a stigma, and quite a large portion of the computer folks shun such software on principles. Now to each his own, but I really despise the mud-throwing going on when someone exercises his freedom and choses not to apply the GPL to his work.
“Make your software free and live off the support”, they say. BS, says I. I’m a software engineer, not a consultant, not technical help-desk staff. I don’t write my tools in a way that needs much support, and I write my documentation to be part of the product because that’s the way it should be done. Hey, the car is free, but I charge you 10k bucks for the key, he he. NOT.
Either your product is a basic building block of software. In that case, any legalese, no matter how well-intended, is a PITA. Or your product is a shining application that’s 80% there - do you want to get some money so you can spend your time improving it? Or do you like having to go to your 9-to-5 job paying the rent and having to improve it in your spare time better spent with your family and friends?
It doesn’t matter if that 9-to-5 job is related to your project (e.g., supporting MySQL installs for clients if you’re on the MySQL team), or completely unrelated: You spend that time working for a client, and not on your project. There might be synergies, there might be not, but in the end it’s not up to you. You’re still payed for labor, not for your creation.
In the beginning, people putting their code under some kind of free license - usually PD, or something akin to the BSD - wanted others to use their code, so that software would become better, and cheaper. Today, there’s a feeling that everybody not-GPL’ed is out to rip you off. And that’s coming from the country claiming that free markets are the solution to everything, because they enforce competition.
Well, the Linux camp is happily living in the GPL ecosphere. Microsoft has everything they want, and if not, they get it written by their code monkey hordes. The ones that get hurt, because they cannot use GPL’ed stuff without losing their business case and cannot buy all the commercial licenses and patents without going broke outright, are the small players, those who might have the great ideas but can’t get to the market because the GPL / commercial duopol has killed competition real well.
And it’s not only the GPL, there’s a number of other moves made into a similar direction that give the “big picture”. Do you think it’s by accident that the man-hours being poured into Linux hardware drivers don’t benefit any other operating system, because they play smoke and mirrors with the kernel ABI and keep drivers tightly integrated with the kernel proper? I remember the early 90’s, when talk about Linux made it through the Usenet like fire, and everyone - the Amiga users, the Apple users, the Acorn users - was so happy that there finally was someone making open hardware drivers for everyone, to level the playing field and let OS’s be judged by merits, and not by driver support?
Boy, but we were so screwed. Being from the Amiga camp, I can remember feeling worse disappointments, but not often…
Don’t tell me there wouldn’t be a need for the next Amiga, Apple, or Be. Don’t tell me software has much evolved in the last few years, once the plethora of competitors was boiled down to Windows and Linux, with MacOS sitting by the side not being able to make up its mind whether to continue being the alibi for Microsoft to point to in antitrust suits while boosting MS Office sales, or being the geek machine.
Then there’s the never-ending propaganda from the Church Of R.M.S., and the aggro you get whenever you dare to disagree with them.
All of that made it clear to me that I’d never release my software to the GPL. For me, it’s either free (as in, do what thou wilst, a.k.a. public domain), or mine (proprietary license), but none of this “it’s free, but only as we say” crap.
I once considered a “free, but not for inclusion in GPL’ed software” license, but then decided that would do the GPL too much of an honor. Scorn and contempt is best shown by disregard.
Pain isn’t always in code
by Solar on May.13, 2009, under Negix Rants
“Sciatic pain syndrome”. Three simple words, but I tell you, they can turn your world into a swamp of misery. Just like the code we have to endure sometimes. So bear with me if this post isn’t the same quality as the others.
These days I had to refactor some code to make it thread-safe. Oh, it had POSIX Threads Library (pthread) mutexes in it allright, added by the original coder. Since the code was C++, and having to manually release a mutex is cumbersome if you can have destructors, he added a wrapper class for the mutexes.
But later on, some other developer discovered that some code tried to re-lock a mutex already locked by the thread. (The bane of historically-grown software that gets extended beyond its initial conception.) As the default behaviour of pthread mutexes in this case is to deadlock (to save the additional clock-cycles required to test for the condition), this developer added a bool isLocked to the class. Needless to say, querying / setting the boolean and locking / unlocking the thread isn’t an atomic operation, so what we’ve got was a nice little race condition.
Hey, no problemo, the pthread library offers a way to add error-checking to a mutex, which would be the solution to our problem.
The problem being the completely braindead way pthread mutexes are initialized.
Behold, a default pthread mutex, defined at global scope:
pthread_mutex_t default_mutex = PTHREAD_MUTEX_INITIALIZER;
There you go, a mutex, initialized with default attributes and ready to use. Now, how about having some error-checking to go with it?
Erm… please allow me to write this without error handling, it’s long enough as it is:
pthread_mutex_t errorchecking_mutex;
pthread_once_t mutex_init_once = PTHREAD_ONCE_INIT;
void init_mutex()
{
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init( &mutexattr );
pthread_mutexattr_settype( &mutexattr, PTHREAD_MUTEX_ERRORCHECK );
pthread_mutex_init( &errorchecking_mutex, &mutexattr );
pthread_mutexattr_destroy( &mutexattr );
}
void init()
{
pthread_once( &mutex_init_once, mutex_init );
// ...
}
Ye flipping gods. I can understand that a mutex might be a difficult data structure that cannot be set up by OR-ing together some values as most other APIs do, but this is insane. You have to set up, init, and modify an “attribute object”, which is then passed (by reference, why?) to the init routine for the mutex. I added the destroy() function allthough the documentation doesn’t say I have to, but given the nature of POSIX documentation, who knows whether I would leak memory if I didn’t. It smells like it, anyway. And of course I have to protext the whole shebang against concurrent initialization, because I can’t do it statically, and as this is a library I don’t have control over int main() to do it there.
I cannot help but stare in awe at this example of… I don’t even know what it’s an example for, but I am awed nevertheless.
And here I am at a word count of almost 500, and I haven’t even told you about the odyssey of piecing together the code above from the manpages (pthread_mutex_lock() mentioning PTHREAD_MUTEX_ERRORCHECK but not having a reference to pthread_mutex_init() not having a reference to pthread_mutexattr_init() not having a reference to pthread_mutexattr_settype())…
You, Sir, are a social problem!
by Solar on Apr.21, 2009, under Negix Rants
So what was that “social problem” bit about, a few days ago?
Well, to really appreciate what a bunch of arrogant twits the guys from the Church of GNU really are, you have to look no further than their very own website, gnu.org. Among other jewels (some of which I will comment on later), there is this brilliant piece of “why Open Source misses the point of Free Software”, by none less than the great Richard M. Stallman, saviour of the software world. (*cough*)
It goes on to some length about why only Free Software is good software, and why software being free is more important than software that is actually and helpfully working, which is what sets Free Software apart from Open Source software, which considers practicality of software to be its primary function. A Bad Thing, says Stallman. You don’t believe me? I quote, emphasis mine:
Open source is a development methodology; free software is a social movement. For the free software movement, free software is an ethical imperative, because only free software respects the users’ freedom. By contrast, the philosophy of open source considers issues in terms of how to make software “better”—in a practical sense only. It says that non-free software is a suboptimal solution. For the free software movement, however, non-free software is a social problem, and moving to free software is the solution.
Bottom line, you might have produced the finest, most helpful piece of software on the planet, a software that will cure cancer and solve world hunger. Let’s say you give it away including its source code, but in turn demand that the governments of the world pay your rent and groceries, so you can continue your work on an undepletable, clean energy source without having to bother with a nine-to-five job to make a living. The Church of GNU will consider you “a social problem”, because you did not “respect the freedom of the users”.
I am at a loss for words right now, will continue later…
True, False, FileNotFound…
by Solar on Apr.15, 2009, under POSIX Fun
Hilarious. Too great a comment not to make an article of it.
As comment to my previous article, GlassX made a reference to The Daily WTF, where Alex Papadimoulis made a tongue-in-cheek comment on the following code snippet:
enum Bool
{
True,
False,
FileNotFound
};
Even better than the initial laugh, however, was the ensuing comments:
Anonymous: The more subtle WTF is that, by default, True is 0 and False is 1. Which is completely bass-ackwards.
rikkus: UNIX would beg to differ:
> [ -d / ]; echo $?
0
> [ -f / ]; echo $?
1
Maurits: I take it you’re assuming that UNIX is not completely bass-ackwards?
Game, Set, and Match.
write() and ssize_t
by Solar on Apr.12, 2009, under Negix Rants
I know this isn’t going to shed light on the “social problem issue” I mentioned in my last post. That subject has been postponed, as I am currently working on PDCLib. That project is actually where I first got into close contact with the greatness of POSIX programming and initiated my boiling disappointment with this “standard”.
Take the output of man 2 write, for example. Just look at the synopsis for a moment:
ssize_t write(int fd, const void *buf, size_t count);
Notice something? Hint: There’s one ’s’ too many. We’ll come to that.
The function write() is supposed to write a number of bytes - specified by the parameter count - to a file handle. As count is of type size_t (an unsigned type), that could be anywhere from 0 to SIZE_MAX bytes. Most importantly, it could be more than INT_MAX bytes. No harm done so far.
Let’s have a look at the return code of the function.
On success, the number of bytes written is returned (zero indicates nothing was written). On error, -1 is returned, and errno is set appropriately.
OK… wait. D’uh? Did you see that? I put in an unsigned value, and get as return that value on success… or a -1 on error. How can that be?
Easy: They invented a cool new data type, ssize_t. If you dig through “man unistd.h” to “man types.h”, you will eventually find it defined as a type used “for a count of bytes or an error indication”, conventiently named in such a way that it’s easily confused with the real thing (size_t).
So here is a magic type which can store the value range of a size_t and a -1. Sadly, it can’t, as you could easily determine with five lines of C code and a sizeof(): ssize_t and size_t have the same size. Means, there is no difference in the returned value between a max-sized buffer and an error condition.
We could discuss the probability now of someone wanting to write SIZE_MAX of data to a file handle at once. The point is, write() does allow to do so, without a note of warning that you will get a -1 as return from the function no matter what. This might never lead to errors in the wild, which might be the reason why the POSIX people felt they could get away with it (”WONTFIX - works for me”). But proper domain testing will stumble over this. I can only assume the POSIX people have never heard of domain testing…
The other camp…
by Solar on Mar.30, 2009, under Negix Rants
Just to make sure the audience does not get the wrong impression from my first rant, settles down for a merry round of Linux / GPL roasting, and gets surprised when the temperature under their seats rises sharply: My scorn will be dished out indiscriminately between the Linux and the Windows camp - or, rather, between the Open Source and the Corporate camp, lest we forget Microsoft’s cuddly bedmate, Apple.
After all, the software force-fed to the more unfortunate computer users who can’t figure out the digital torture chamber that is Linux, isn’t any better than the Open Source creations. And to add insult to injury, they are charging those poor people for that crap, then charge them again when they want the upgrade in hopes it holds what the previous version promised. (Ha!).
We might not have the proper words for it, but it will surely make several well-off managers from the business enjoy a rather well-heated afterlife.
I grant you that Open Source software comes for free, as in free beer. That is, if you do not count in the hours it took to get it to work, and the years you will die earlier for the experience you went through. If the GPL evangelists had left it at “for free”, I might actually grant them the moral high ground they claim so complacently. But once they started that FLOSS rain dance about “free as in free speech”, things started to go rapidly downhill for what might have been the user’s last hope of a better tomorrow. (Note to self, don’t get sidetracked, that is for a later post…)
Today, we (meaning you and me, the poor sods having to use these boxen) are stuck smack in the middle between the ‘Corps who are out for profit maximization, and the evangelists of the Church of GNU who tell you that every single professional programmer in the world is a social problem.
You don’t believe the social problem thing? Just you wait for my next post, I have proof. {{X Files jingle}}
“Negix”?
by Solar on Mar.17, 2009, under Negix Rants
You might wonder about the name of this Blog, “Negix - Things not POSIX”. Let me shed some light on this.
Back in its time, Unix was a powerful operating system, which brought many signifcant advances to the field of operating systems. The one major shortcoming of Unix was that it didn’t take a bow and itself off the stage when it was time to do so (which, IMHO, was sometime during the 80ies). Instead, they invented POSIX, formed the FSF, came up with the sick joke that is the GPL, and eventually, twisted Linux into one of the top three worst things ever to happen to computer users. (The other two being, of course, the Microsoft monopoly and software patents.)
And while my anger at this whole screwed-up affair is usually just simmering on “medium” setting, sometimes I feel like I have to vent it or explode. Thus came the desire to set up a “relief-valve”, so to speak. And because I didn’t want to pollute the TLA namespace any further, I came up with “Negix”, a nice sum-up of my animosity towards the whole shebang that’s the new crusader religion among people who should be intelligent enough to know better.
I’ll follow up on this rant with specifics once I can put them into words that won’t get me into (too much) trouble.