GNU’s definitely too messy for my taste

I’m pretty sure not to say something wrong when I say that the majority of the readers of this blog would agree that Open Source and Free Software development can produce better software by many different measures. Better overall quality is just theoretical; you have more portable code, more standard code, faster coder, less memory-hungry code and so on so forth. One of the measures you can figure out is code cleanliness, but even that is very subjective. So this is why I’m talking about taste.

So what’s the problem here? Well, while I think the end result of GNU software is generally very good, I find the general code very messed up and pretty much unreadable and unusable. I have criticised gnulib’s approach before regarding the way they duplicate the same code over and over, rather than provide a “portability” library to use where glibc is not used, and the system libraries don’t provide enough functionalities. Lately, I also noticed that they add tons of redundant autoconf checks to project running them, some of which have been broken from time to time, in different ways (I had to fix diffutils and m4 the other day because they had an automagic dependency over libsigsegv (and that changed its ABI on the tinderbox recently).

A couple of days ago I also had a bad face-to-face encounter with GNU coreutils code. The reason for that is that I’m working on an utility for a customer of mine, and I wanted to re-use the code from the fold command to split a text file into equally-sized lines (of course I could always use fold as a filter, but since the amount of work that I needed to do to get the proper parameters passed to that would be more than the generic work I needed to do my side, I simply wanted to integrate the code). License, here, wasn’t much of an issue to me, the utility I’m writing is not part of the business logic, so I have powers to make it available if the license of parts of the code asked for me to.

Unfortunately, a different problem came up: the code in fold.c is too messy to work with. The source file is not standalone, it depends on a huge tree of header files, each of which then depend on a pile of other sources; and this does not limit itself to the gnulib dependency. Nothing is clear in that code. There is a system.h header, that defines a very wide range of different functions: filesystem handling, integer types, allocation functions and so on so forth. This header in turn depends on over ten other different headers that provide different definitions and so on.

Just to make it worse, the headers define inline functions, that depend on other external functions from other source files; and all of those end up requiring a truckload of autoconf checks that sound, to a minimum, silly for something as basic as fold. I actually tried cleaning up the code, but, well, the work was tougher than reimplementing the folding code altogether.

At the end, I didn’t have to reimplement the algorithm though; the whole multibyte coding would have annoyed the hell out of me. I “folded back” (sorry for the pun) to using FreeBSD’s code. The fold.c file from FreeBSD’s source repository is self-contained, clean, straight through (although, to be honest, I find it lacks a couple of “static” keywords that could have slightly reduced its overhead). The license is also more permissive, as we know.

At the end, I’ll probably try to make the utility open-source anyway, using a similarly permissive license, given that’s what I took part of the code from.

I don’t doubt that GNU’s code might be better in some regards; for instance it’s almost certain that the GNU code builds on more platforms and with more variations than FreeBSD’s, but to do so, it really has to overcomplicate the code to a point that readability is gone for good. Similarly, the GNU utilities tend to have more user-friendly features, with further parameters, but these GNU extensions cause “lock-ins” that mean that standard support in their programs is lacking. This reflects down to many aspects of GNU software, their complexity, their over-engineering, their non-standard extensions. And this is probably one of the reasons why GNU is sometimes frowned upon by other (pragmatic) Free Software developers… and why some people would very much like to stop talking about GNU/Linux.

GNU guys, I understand your projects’ aim, but please, could you refocus? Could you reduce your complexity? Give us a libgnucompat… make it GPL if you don’t want to have it LGPL; but move away the code duplication; move away the complexity in build systems; the complexity of webs of source and header files. Make your code readable again, linear again, make your utilities the best people may come ask for. Please; pretty please.

21 thoughts on “GNU’s definitely too messy for my taste

  1. As always a very interesting post.A quick thought on the fold.c file though: Did you look at the one from NetBSD, which should be more portable than the FreeBSD one ( I don’t know how it compares against the GNU one though )I sometimes get the feeling that GNU is trying to lock people in with just GNU-software, both licensewise and codewise…

    Like

  2. Like anyone who’s ported code to Win32, I’ve had several occasions to look for standard functions not implemented in Microsoft’s C library. Every time, I’ve chosen NetBSD’s code over GNU’s. Look at getopt.c, just for one.

    Like

  3. RE: “…many aspects of GNU software, their complexity, their over-engineering, their non-standard extensions.”I ran into one of these recently in the command line to “gfortran” — “-omp” is being turned into “-o mp” by the parser (note the destruction of significant spaces). And they claim that is a GOOD THING ®I thought this sort of language-design error went out with Fortran 77, thirty years ago.

    Like

  4. ” … too messy for my tastes .”As compared to what? All the Apple and Microsoft proprietary source code you are able to browse through, expropriate, or fork?And you lay a blanket charge against ALL GNU code because fold.c wasn’t written to suit your “tastes”?On cue, your like-minded friends chime in with complaints about GNU wanting to “lock in” people with the GPL or the code, merely a slight variation of Ballmer’s “virus” accusations. Just how is it possible to “lock” someone into a code which they are NOT forced to use, they can change if they want, and can freely give it away to others legally? Oh, that’s right, the GPL won’t let you and your friends can’t EXPLOIT FOSS code and create a monetized lock-in the way Gates exploited the BSD tcp/ip stack — take, take, take, and give only the EULA in return.It also begs the question that if GNU source is so bad, why are you mining it to improve your work?

    Like

  5. And “GreyGeek” wins the troll-award for completely missing the point and showing up as a complete idiot.Especially considered that I probably write more FOSS code in a day than he/she has ever written in his life, standing to the way he/she writes.

    Like

  6. what do you expect? “GNU’s Not Unix”, and even to a mere user of their utilities it is evident that they have no understanding of what makes Unix so amazing: simplicity!

    Like

  7. Are you seriously implying that I’m asking others to do work for me when I don’t? Are you implying I’m not a FOSS coder? Get a clue before trolling without even understanding what is written. @fold.c@ itself isn’t particularly bad; the fact that it depends on a web of inconsequential headers such as system.h is.

    Like

  8. I wouldn’t be surprised if the lock-in aspect is somewhat intentional. But when I have to use equivalent utilities that don’t have the “non-standard” GNU features, I start edging towards ‘tantrum mode’. So at least the feature creep is adding value and not so much ‘because we can’.Regarding your other points, a lot of the GNU code is hardly ever touched anymore. To use your example of fold.c, according to the git repo, there were 3 updates in 2009, 6 in 2008, 3 in 2007, and 2 in 2006. When you work on code that infrequently, it is tempting to shoehorn in a fix and move on to the next thing. This is especially true for maintainers who come behind the original developer.So in reality, what you are asking for is a pretty significant rewrite of legacy code. Are you volunteering? If not, how serious are you about asking someone else to do something you won’t? This comes across as, “You FOSS people need to provide me better service for free,” and makes people like my buddy GreyGeek (from LT.com, and he _is_ a FOSS coder) kind of cranky.Later . . . Jim

    Like

  9. Very good example of what you are saying is GNU’s hello world program. It’s amazing how they overburdened those few lines. ;)

    Like

  10. Right! Recently started to pick up C coding again after 8 years, as i bumped into the suckless.org WM, browser and tools. And hey, i could read that stuff, work with it.Beeing very enthousiastic (writing some simple inotify stuff), i wanted to see the code for some very very simple GNU tools, and bumped into exactly the same. That must’ve been written with a big fat IDE, i believe as much in God as i believe in someone beeing able to read GNU code.And what was said before, GNU tools giving more as well as different options and -results is something i’ve seen a lot too. I do work on other UNIX platforms, that lock-in is immensly irritating! I rather miss functionality, then be stuck time and time again with incompatibility.

    Like

  11. Diego, you’re being a tad bit touchy about this. I’m speaking without knowing here, but I’m pretty sure JSS didn’t imply that you’re not contributing to FOSS. At least that’s not at all how he came off to me. His post may not have been the smoothest way to say it, but in essence he’s right.His point was rather to say that this problem is very much like many other FOSS problems. This mail [1] from the -dev mailing list, summarizes it much better than I could ever do. Basically, you’re reacting to what JJS wrote in the same way, that GreyGeek did when you wrote this post in the first place. Why GrayGeek responded in the fashion he did, I have no idea. But you obviously touched a nerve.You also attack GreyGeek in your reply to him (by saying that you have wrote more FOSS code today than he has ever done), without actually knowing who he is and what he is doing. And when JJS informs you that you’re wrong, you go on insult him too. These pretty strong signs of what I wrote above. I like you Diego, but that was not very classy.My point here however was not to criticize you. This is your blog and you are free to do whatever you like on it. It was rather to agree with what JJS said, but maybe in a less blunt way. This is an issue that itches very few people, in the words of the author of the earlier mentioned -dev mail. I know very little about the actual code, but I’m sorry to say that it seems to me that if you want this fixed, you’ll have to do it yourself. I doubt a blog entry will inspire anyone to do it, although it may be a good way of raising the issue.Also, ain’t it the charm of F/LOSS that you more or less can pick and choose, at least within some (often licensing it seems) restrictive borders? :)[1] http://archives.gentoo.org/

    Like

  12. Viktor, I am touchy when people pretend that I shouldn’t show the weaknesses of Free Software just because it’s Free Software.I _still_ maintain I probably wrote most FOSS code today than GreyGeek did in his life; I did google up his reference (given he didn’t bring a homepage link with him) and I couldn’t find anything related to code. I even checked his email address (that you cannot see, but I can through the admin interface) with Google Code Search… no result (“compare to mine”:http://google.com/codesearc… if you wish). May he have hidden his true identity? Could be, but it wouldn’t make sense, would it?Yes, I get upset when people pretend to move a _technical_ reasoning toward the position of an “enemy of Free Software”. Guess what, I’m the exact opposite. I haven’t started yesterday, I scratched my itches, and I do paid work on Free Software. And I use GPL as my license of choice most of the time.And really, do you think that most of GNU code is written to scratch an itch? In such a case, please do learn a bit more about GNU. They are far from an amateur project, they are quite well organised indeed.If you think I’m out of line to actually blame them publicly, part as a way to vent and part as a way to tell people to open their eyes and not just rest, thinking the battle is won, because there’s GNU, then I don’t have anything more to say to you, it would be a waste of my time, that I could employ in a better way: writing code.As for “fixing” the problem… I don’t intend on going on to refactor GNU’s code myself. If somebody from the core GNU projects started actually accepting these problems and would go to fix them, it’ll be definitely a good thing. My way to contribute to FLOSS and improve the situation is to _avoid repeating the same mistake_. It’s worth more.

    Like

  13. Diego,Google Code Search is far from perfect (from my point of view). I’ve just tested with my personal email address and found no result. I’ve also tested with my professional email address and found no result again. I’ve finally tested with my full name and found some results, but the main project I work on was not listed.Didier

    Like

  14. True, Google Code Search is not an omniscient god.But if I search either “your full name”:http://www.google.com/searc… or email address, on Google straight I find your website as top result in both cases.Let’s not be naïve here: if you have enough “creds”, either name or address, in either straight search engine or code search, will produce a very visible track. Sometimes even too visible, I heard saying.If your only contributions seem to be blog _comments_ and mailing list _replies_ to people who dare criticise the purity of projects, you *aren’t* a coder. You might call yourself a contributor, but even in such a case you’d just be kidding yourself.

    Like

  15. Could it be that the complexity is not a try to lock in, but rather something left from the time GNU started?Or just the result of people writing code quickly — or trying to make it more powerful than needed for a coder, but often very nice for an experienced (nonprogrammer) user?

    Like

  16. “And “GreyGeek” wins the troll-award for completely missing the point and showing up as a complete idiot.”Nope, you won an idiot award. The title of the article is damn trollish and the same about your attitude. The title suggest ‘all the GNU’s code is too messy for you’, but who cares? Why this bull showed at fsd? Bsd code is too messy for me and it sucks far more for me then for TDR, but who’s interested?

    Like

  17. Looks like there was some useful, constructive criticism here. It’s nice to rewrite code from time to time so that it’s easy to read.

    Like

  18. It’s strange, but this article says out loud what I have thought years ago, kept mum about, and forgot.I tried to port a simple GNU utility (I forgot which one) to MS Windows as I was under the assumption that it was just a small C program, which couldn’t be hard to port. That failed miserably when, as the article described, the GNU code depended on loads and loads of include files, which needed other includes and obscure items from the GNU C utils library. Thinking I might just rip out the cruft and get the C proggie working without all those baroque includes proved another disappointment, for precisely the reasons mentioned in the article: the code was far from clear. In summary, it was easier to look for an equivalent Windows program, which happened to be a proprietary one. Ever since I have silently steered clear of GNU code.I didn’t say anything about it at the time because I was a novice at C programming, and thought it was probably my own fault that I couldn’t understand / adapt the program in question within a reasonable amount of time. This article however brings it back, and I feel I have to agree with the article.Although GNU utilities are a significant net benefit, they do have serious drawbacks and the article highlights one of them.I found that it pays to take an opportunistic and consumerist attitude to software: FOSS and GNU when possible and/or convenient, free and proprietary where that’s more advantageous, proprietary and paid-for when necessary.FOSS’nes is just one of the attributes of software. An important one to be sure, but by no means the only one. This is one of the (several) areas in which e.g. GreyGeek and I differ.

    Like

  19. From a user standpoint I just want it to work. If I paid for it I expect itWith GNU it seems I have to check my compiler messages for those includes. Some one may have forgotten to add them.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s