Bluejack ([info]bluujack) wrote,
@ 2009-03-07 20:34:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Beware. Extra geeky.
I really should have separate blogs for separate subjects, I think. This is totally unrelated to anything most people who occasionally read this blog have any interest in, I'm sure.

But I need to vent.

I have a hunch that there's a single, evil mind behind three of the most venerable tools in the GNU family: Make, Flex, and Bison. (Curse you, Richard Stallman!) Certainly, all three of them share this in common:

* They have lots of documentation, none of which ever answers the question you're trying to find.
* They require the brain to think non-linearly, and to make non-obvious leaps of faith.

Since these are programming tools we're talking about, you will need to make a lot of non-obvious leaps of faith that result in very obvious thumps on the ground before you finally happen upon the correct answer.

In particular, I am currently trying to build something using Flex and Bison (AKA, lex and yacc), which involves using the "start condition" feature. These are poorly explained in the documentation, and do not provide get-you-going examples. Worst of all, the examples they do provide do not demonstrate the correct mechanism for marrying Flex, Bison, and start conditions.

So, I spent three hours attempting to figure out how to parse and pass a quoted string containing escape characters from flex to bison.

By the time I got it figured out, I had resorted to all sorts of hideous global variables to maintain state across multiple regular expression matches within the various rules of the start condition.

Lex and yacc are widely regarded as the tools to use when writing a compiler, but they feel like the kind of gruesomely hackish software a junior high school student might use to throw together a tetris demo. Obviously, a fiendishly clever kid, but I'm afraid we just can't give you more than a C, for this one. Maybe a C++.



(6 comments) - (Post a new comment)


[info]bluujack
2009-03-08 04:48 am UTC (link)
FYI: That last line was meant to be gratuitously clever and should in no way be taken as casting aspersions on the C language (which is practically my second tongue) or the C++ language (which I *do* basically loathe, but realize that my prejudice is not entirely warranted).

(Reply to this) (Thread)

Geekmate on the C++ joke
(Anonymous)
2009-03-08 06:01 am UTC (link)
Bluntmon,

This be Doug.

I was just exchanged pleasantries with a friend about a geeky C++ joke I came across in The Computer Contradictionary by Stan Kelly-Bootle. Chris Hecker is the main programmer of Spore and one of my patrons.

Here is the email thread, so read it backwards.
---
Chris Hecker wrote:

Ah, found it:

http://books.google.com/books?id=tZKCZje8178C&printsec=frontcover&dq=computer+contradictionary#PPA33,M1

So, the original letter I wrote him had that, and then it had another snark in it, because he was talking about OOP and mentioning Bjarne Stroustrup and Bertrand Meyer, and I mentioned a concept and then said something like, "I'm not sure where this concept originated, whether it was BS or BM, but anyway..." Best programming/scat joke ever.

Chris

Doug Sharp wrote:
> You didn't know???
>
> Second edition 1995:
> "Thus, following Christopher Hecker, we can define class Language and
> overload the prefix and postfix Language::operator++:
> Language& Language::operator++()
> {
> BetterSelf();
> return(*this);
> }
> Inline Language& Language::operator++(int dumm) {
> Return(++(*this));
> }
> Language C, X;
> X= C++; // X is enhanced C and Bjarne's your Uncle!
>
> Hecker has therefore proposed, without hopes of general acceptance,
> that the language be called C.operator++(dummy)."
>
> About 1/3 of Bootle's C++ entry is your little jape.
>
> Smash the state!
>
> Doug
>
>> -----Original Message-----
>> From: Chris Hecker [mailto:XXX]
>> Sent: Sunday, January 18, 2009 3:00 PM
>> To: Doug Sharp
>> Subject: Re: Thanks again
>>
>> > I was reading Stan Kelly-Bootles Computer Contradictionary and
>> came > across your leetle ++C joke. Teefrigginghee.
>>
>> No way, is it in there? I used to have the original copy of the Unix
>> Review, but I can't find it. I love SKB.
>>
>> Chris
>>
>> Doug Sharp wrote:
>>> Chris,
>>>
>>> I was reading Stan Kelly-Bootles Computer Contradictionary and came
>>> across your leetle ++C joke. Teefrigginghee.
>>>
>>> Thanks,
>>>
>>> Doug
>>>
>

(Reply to this) (Parent)(Thread)

Re: Geekmate on the C++ joke
[info]bluujack
2009-03-08 08:41 am UTC (link)
Ha! Fun stuff.

I also was grooving on the C+-, next entry in the contradictionary.

(Reply to this) (Parent)


[info]poon
2009-03-08 05:51 am UTC (link)
I think the O'Reilly book on Make is also perhaps the worst O'Reilly book ever produced. Perhaps they just read the documentation and thought, "Hey! I can totally turn this into a book!".

(The flex/bison "book" is no better).

Perhaps they're intended more as a hazing ritual for compiler authors.

(Reply to this) (Thread)


[info]jackwilliambell
2009-03-08 05:49 pm UTC (link)
Is there a good book on Make anywhere? I use the damn thing all the time in my job and there *still* are days where I spend eight hours straight trying to get something to work right which is only slightly different from something else which does work right.

I've talked before about my love/hate relationship with GNU Make.

(Reply to this) (Parent)(Thread)


[info]bluujack
2009-03-08 06:54 pm UTC (link)
Another thing these three tools have in common is that they contain considerable amount of implicit logic. Great shortcuts if you're the guy who wrote the tool. A minefield for everyone else.

In Make, for example, I had a very sophisticated makefile that I was very proud of; it handled support for two different languages (C, Java); it handled builds across N directories of arbitrary depth; it handled builds for library objects, applications, and supported both static and dynamic linking of said applications.

And then, after I completely forgot the details, I made a change somewhere, and it stopped working.

Why? Because it had only ever worked by accident. The rules I thought were doing a core part of the job were not doing the job at all: implicit rules were. When I added some tweak to something, that I thought was just an option to the explicit rule, it blocked the ability of the implicit rule to do its job.

Bison and Flex are much the same: they're doing all kinds of nifty work for you, which means you actually have no idea what they're doing or whether it's going to actually work. And these tools are just about as undebuggable as Make.

(Not that I like ant or maven any better, to tell you the truth. Maven is just as implicit as make, only it has a philosophy behind it: "convention over configuration". Pshaw. And Ant might as well be perl.)

(Reply to this) (Parent)


(6 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…