4 ms·
Less than 500 lines of code. More than 500 lines of compiler errors if you get a character wrong somewhere. ;)
by confuzatron 17y ago
Less than 500 lines of code. More than 500 lines of compiler errors if you get a character wrong somewhere. ;)
- dirtyaura 17y agoYes. However, in my experience, on a small team, benefits of readable code by using templates to implement DSLs in C++ still outweighs burden of prosaic error messages. You quite quickly learn to pattern match error messages to find the real problem. We might be bitten this later when new guys and gals join the team. Code is very readable for being C++, but newbies might have hard first few weeks with these error messages.
- confuzatron 17y agoYeah, really it's a more general problem with the extreme expressiveness of C++ meaning that the compiler is less able to give a helpful error message than in other languages I've used. It seems that you can do anything in C++, but step out of line and you'll have trouble deciphering where you went wrong.
- wheels 17y agoNah, it's actually more of a GCC problem than a C++ problem. Intel's compiler produces surprisingly sane error messages.
- confuzatron 17y agoI can confirm it is also an MSVC problem.
- zokier 17y agollvm/clang is supposed to have nice error messages
- eru 17y ago> extreme expressiveness of C++ You probably mean that the boundary between meaningful C++ programs and typos is not very well defined?
- confuzatron 17y agoExactly. Very well put.
- sreque 17y agoIf 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(*).
- growingconcern 17y agoIt's not that hard parsing template compiler errors (though I am looking forward to better errors in C++0x). Are you saying this is a good reason not to use templates at all? With a little practice they start to make sense. I'm sure for novice programmers the first time they see 500+ error messages stemming from a missed semi colon or curly brace (in regular code) it can be pretty bewildering too, but just like with template error messages you just ignore virtually all of it.