[antlr-interest] philosophy about translation

Kay Roepke kroepke at classdump.org
Wed Oct 11 19:52:25 PDT 2006


On 12. Oct 2006, at 3:56 Uhr, Andy Tripp wrote:

> The problem is that people value program correctness over  
> readability. Crazy as it sounds, I prefer this program:
> System.out.println("hello, world")
> ...over this one...
> System.out.print("he" + 'l' + "l"); System.out.println("o");
>
> The first one is clean but incorrect, the second one is correct but  
> not clean.
> The first one will be much easier to maintain over time. Same for  
> million-line programs...I think it's better
> to have something that's well written than something that's  
> completely bug-free!

I don't see why the first one is incorrect, but ok, I buy it ;)
One thing I cannot on agree on, is that a translator is allowed to  
introduce subtle bugs in my code. I think there's a tradeoff between  
readability and correctness. Granted, I can live with border cases,  
where the vendor says "Listen, for constructs like malloc you have  
triple-check the translation, because we don't have malloc in Java  
and have to make assumptions." but these cases should be well defined  
and clearly stated. OTOH I assume you do that sort of thing with your  
customers.
That said, I value code cleanliness a lot, having worked on quite  
large projects, cleaned them up and seen them deteriorate again in  
the span of a couple of months. So I think I know what you mean.

>> This is not generally the case with  artificial languages.
>
> Generally, but then again, it's 10pm, and my officemate is looking  
> at a line of code like this:
> typedef char MYCHAR[25];
> ...which of course tells us replace any occurances of "MYCHAR" with  
> "char[25]".

Yes? That's the way typedefs work. Am I missing anything? How's that  
violating the grammar?

-k


More information about the antlr-interest mailing list