[antlr-interest] philosophy about translation

Andy Tripp antlr at jazillian.com
Wed Oct 11 18:56:20 PDT 2006


>
> Ok, so a sort of semantic predicates in grammars, only that it is not  
> in a grammar, but in hand-written code. Of course, it is using some  
> sort of grammar anyway, because your rule engine still uses a kind of  
> language.


Yes, but a simple one: the "v" and "x" placeholders are all there is to 
it. Everything else
is matched literally. So far simpler (and more limited) than ANTLR or 
even regular expressions.

>
> I totally agree with you on that point. Having a tool available is so  
> much better in any craft. It's hard to understand why some people  
> cannot see the value of that. I mean having a compiler still doesn't  
> write programs for you, but it saves you from all the nitty gritty  
> details you don't want to bother with. Funnily enough, in other areas  
> they do accept that: see garbage collection for one thing. Nowadays  
> everyone jumps onto that train. It ain't perfect in many cases, but  
> it will help you to get your work done sooner. Same applies to your  
> project. And incidentally the same applies to IDE's, too. At least  
> that's slowly changing. I don't want to go back to vi to edit my  
> projects. Too. Much. Hassle.
>
> Kudos for trying to change that!

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'm not an expert in linguistics, far from it, so I can't really  
>>> say  anything for NLP.
>>
>>
>> Yea, me neither. I was pretty shocked at how different the NLP  
>> approaches are from "compiler" approaches.
>> Seemed like zero overlap. I'm still pretty shocked at how bad NLP  
>> seems to be, but I guess I have just
>> one data point: babelfish.
>
>
> I think the real problem with NLP vs. most artificial languages is:  
> You do not need to declare objects before usage in natural languages.  
> We don't go around pre-declaring everything we want to talk or write  
> about. Also, natural languages are much more ambiguous and highly  
> context sensitive. Furthermore, the semantics of a word or phrase can  
> depend highly of intonation if you are dealing with speech. And last  
> but not least, natural language can grossly violate grammatical rules  
> and still be understood. 

It's even worse than that. There may not exist a "correct" solution 
("who does the 'he' refer to in some sentence...no
way to know for sure"). And there can be exceptions that no one would 
ever think of until they hit them
("the White House" is still "the White House" in Spanish, not "Casa 
Blanca", and to know that you need to now political-type things!).
Not to mention wackyness like "Go" is a valid sentence, with an implied 
"You" as the verb.
Or "this is a sentence, but the period goes OUTSIDE the quotes".

> 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]".
The good news is that it turns out we already saw that once, and handle 
it :)

Andy

>
> -k
>
>



More information about the antlr-interest mailing list