4 ms·
If you've ever tried starting a debugger in a program that uses the Boost Lambda library you might disagree. My program was only a few hundred lines long, a toy
by sreque 17y ago
If you've ever tried starting a debugger in a program that uses the Boost Lambda library you might disagree. My program was only a few hundred lines long, a toy, but I for the first time had to turn pagination on in gdb to view my program's stacktrace because the it filled two entire screens! Even worse, compile times on my program were ridiculously high and I was wasting a ton of my time in long compile-run feedback cycles. Eventually I threw my hands up in disgust and started hand-rolling my own structs. Compile times dropped to under a second and I was able to easily spot my mistakes in the debugger.
What was I doing? I was just writing a simple program to try to understand Boost's spirit parser, somewhat of a monstrosity in its own right, and thought I'd use the lambda library along with it. While we're on the subject of crazy DSL's in C++ templates, I ended up concluding that Flex together with Bison or Lemon are much more pleasant to use than Spirit if you don't need a full recursive descent parser.
Using C++ templates to implement crazy meta-languages might seem like a cool idea, and it is, but in practice I've found it to mostly be a waste of time and very unproductive.
- dirtyaura 17y agoWe have noticed that debugger is not a very good debugging tool for our apps: interactive games with lots of events, animation, multiple threads etc. Stepping through in debugger has turned out to be waste of time. What has worked? It's much better to produce detailed logs of some of the subsystems and analyze them. This way you get much better understanding of the big picture of what is happening. Why? In UI code (or event-driven code in general) state changes that cause bugs happen over time, not inside one step of an event loop. You just can't get the big picture of event-driven code with a debugger, which is optimized for going up and down callstack. We have build a custom tracing library (and yes, it uses a lot of MACROs) that allows us to do select what is traced in a very granular level. I can proudly say that it's wonderful tool, every UI platform should ship with something like that. By the way, tracing is also better for debugging parsers, their behavior often have similarities to event-driven systems But you are right about compile times. Those get worse with templates.
- bad_user 17y agoBtw, I've had great experiences with Antlr (instead of Yacc) and can use Java/C/C# as targets, although you might have problems redesigning your grammars to be LL(*).
- loup-vaillant 17y agoAll this can be traces back to a root problem: using, maybe even needing, C++. Solution: don't use C++, or run away. (And spread the word[1]) I am dead serious: I don't follow my own advice, and that makes me miserable at work. [1]: http://yosefk.com/c++fqa/ http://yosefk.com/c++fqa/ (I actually learned quite a few things there)
- _delirium 17y agoI second the recommendation of Yosef K's FQA. It's not just an anti-C++ rant, but a pretty detailed explanation of a lot of C++'s features, interactions between features, and corner cases (and how those will bite you in the ass).