[antlr-interest] More, Status of C++ backend?

Maurizio de Pascale mdepascale at dii.unisi.it
Thu Jan 3 02:59:38 PST 2008


Jim Idle wrote:
>   
>> -----Original Message-----
>> From: Gavin Lambert [mailto:antlr at mirality.co.nz]
>> Sent: Wednesday, January 02, 2008 2:49 PM
>> To: Jim Idle; antlr-interest at antlr.org
>> Subject: Re: [antlr-interest] More, Status of C++ backend?
>>
>> At 05:22 3/01/2008, Jim Idle wrote:
>>  >Yeah - I see that argument too, however I think it will end up
>>  >being slower just for the sake of making it use "proper
>>  >classes", so I would not use it and just go with the C runtime.
>>
>> There's nothing inherently slow about C++ over C, it's just that
>> you have to be aware that the compiler can inject extra code
>> "behind your back" :)
>>     
>
> Well, there is extra setup for exception handling and so on - hence all 
> the goings on with Embedded C++ specs. It never turns out as lean as C 
> and most programmers screw it up royally ;-P
>
>   
It depends on the compiler and hardware. zero cost C++ exception 
handling is possible.
However, moving error reporting/handling from additional 
arguments/return codes to exceptions can even make code faster on most 
compilers, and certainly makes code more readable.
As an example, a main using the C runtime is ten times longer of the 
same main in Java.

My suggestion is that the right road (ideally of course, I know the C 
runtime is already in place) would be to have the runtime written in C++ 
(as close as possible to the java counterpart) and provide (also) a C 
API for C users.


my two cents,
Maurizio de Pascale
mdepascale at dii.unisi.it



More information about the antlr-interest mailing list