Speed vs Readability (was: Re: [antlr-interest] syntactic predicates and exceptions)

Chris Black chris at lotuscat.com
Thu Oct 20 10:02:10 PDT 2005


I've been following this thread with interest and have decided to 
finally chime in (and change the subject header to something more 
indicative of the discussion). Some of my main reasons for using ANTLR 
rather than hand-coded parsers are speed and maintainability/readability 
of the GRAMMAR files (not the generated code). That the generated code 
is readable is nice, and certainly a bonus when it comes time to debug, 
but here are my thoughts on the matter:
Go for speed of the core engine first. The code generator can always be 
adjusted to add readability later (by adding comments or generating 
better formatted/readable code).

Chris

Micheal J wrote:

>>Nigel Sheridan-Smith wrote:
>>    
>>
>>>the readability of the code (and hence the ease of debugging and 
>>>tracing) will be reduced.
>>>
>>>      
>>>
>>Don't underestimate this point. The readability is one of the main 
>>selling points of antlr. At least that is how I get away with 
>>using it 
>>in a yacc shop.
>>    
>>
>
>Actually, the selling point is that it generates code that resembles what a
>person might write while developing a hand-crafted parser. Getting rid of
>exceptions for backtracking takes ANTLR closer to that ideal.  ;-)
>
>Seriously, I have hand-crafted and also generated code that eschew the use
>of exceptions for all but *truly* exceptional events and yes, the speed
>boost is substantial and, I've had no problems come debug time. I don't
>remember ever wishing it was more like ANTLR's default code output. I do
>remember the satisfaction of seeing my language processors execute more
>quickly than they would have otherwise ;-)
>
>Cheers,
>
>Micheal
>
>  
>



More information about the antlr-interest mailing list