views:

45

answers:

1

I got in this argument at work. My coworker told that just something that generates machine code is a compiler. Then (after I mentioned the Google Closure Compiler) he changed his mind: apparently, for him, a compiler is something that generates optimized source code in any language (which doesn't make sense, since optimization is an optional step for a compiler.) According to him, a program that generates, for instance, Objective-C code is a source transformer, not a compiler.

And from what i know, a program that gets source code in one language, and transforms it into any language, not just machine code, is a compiler. So, source-code transformer == compiler.

So, what is a compiler?

A: 

I build tools that can transform code from one language to another among other tasks.

The definition we use is that when you "transform" from one langauge to the same language, what you are doing is building an optimizer. The "Closure compiler" from this point of view is misnamed.

When you transform from one language to another, and the concepts used on both of the translation are roughly at the same level (assignment statements, if-then-else, explicit procedures, etc. typical of most languages), you are performing an translation (e.g, COBOL to Java).

When you transform from one language to another, but you generate lower level language constructs on the target end (e.g., PASCAL to machine instructions, APL [a matrix language] to scalar C code), you are compiling.

The boundaries between these isn't always neat. If you transform from APL matrix operations into APL scalar operations, you are going from the same language to another, therefore "optimization", but also from high level concepts to lower level one, therefore "compiling". From my point of view, change-of-abstraction level trumps same-langauge-target, so I'd call APL-matrix to APL-scalars "compiling".

What you will find in practice when translating between langauges is that sometimes you can do it using the same level of abstaction, and sometimes you can't (or don't want to). So the real truth is that every translation tends to change abstraction levels somewhat from higher to lower. How much of a compiler you have depends on the degree to which the abstaction level changes.

Our engine does all of these by what you would call source code transformation.

Ira Baxter