Re: Is Assembler Language essential in compiler construction?



Frankly, most university first courses on compilers don't spend much
time on the back end of compilers; there just isn't time. And the
assembly languages of most modern processors are just too complex. I
would like to see the Java virtual machine or some other used virtual
machine be the target language for a first course on compilers, if
that is not already too much information. Students would find this
more interesting and useful than a faked machine language and more
reasonable than a real assembly language.

I taught an undergraduate course on compiler construction where we
used JVM bytecode as the target instruction set. We then used the
Jasmin bytecode assembler to generate class files. Overall, I feel
that it was a great success. Because the JVM is at a higher level
(and concepts are similar to the Java language) and is stack oriented,
students were able to pick it up quickly. You can also apply register
allocation techniques to determine the minimal number of stack slots
required for local variables. Because most students do not go on to
do compiler work, the focus on the JVM allows them to get a better
understanding of the platform (JVM) they are working on---so it is a
win/win situation.

A slightly different option would be to compile to some intermediate
language used in a real compiler such that the students could use the
real compiler to finish the translation into machine code. This would
require a cooperative compiler with a reasonably simple intermediate
language.

This is also a great option. It is great if the compiler framework
allows optimizations to be coded up easily---this allows students to
get their hands dirty with high-level IR-oriented optimizations. LLVM
comes to mind.

The back end is where the real compiler work is done though, so a
second course, possibly at the graduate level, that dealt with
compiler back ends would be useful. Such a course could deal with
translating virtual machine code into real machine code. I recommend
compiling to a processor whose machine language is not too complex,
and is really used today, say for embedded applications.

I think a compiler book using these ideas would be very successful
especially if universities used it in their compiler courses. Wish I
had sufficient knowledge to write it but I only know front ends well.

The ideal scenario is probably one where the computer architecture,
programming language, and compiler construction courses worked
together to teach students a specific architecture assembly language,
how to deal with programming language theory (including lexing and
parsing), and programming language construction (focusing more on the
middle/back- end phases).

/Tim
.



Relevant Pages

  • Re: Java compiler courses
    ... Who cares what language the compiler is written in in ... exceptions I think the only people who really study compiler ... students later in will use their knowledge in projects using C. ... programming skills are an integral part of a CS ...
    (comp.compilers)
  • Re: "STL from the Ground Up"
    ... high-level intermediate language than can interoperate with many other ... If your language lacks expressive features then you cannot write code ... memory management in comparison. ... Mostly because type errors mean that the programmer and compiler disagree ...
    (comp.programming)
  • Re: A note on computing thugs and coding bums
    ... It would handle international characters if the execution character ... method I used in "Build Your Own .Net Language and Compiler". ... work areas and counting on Nul is an illusion. ...
    (comp.programming)
  • Re: access(FULLPATH, xxx);
    ... with "trial& error" to just silence the compiler. ... void *foo); ... given that the language in the specification _was_ abiguous and both ... documentation was paramount. ...
    (freebsd-questions)
  • Writing a Roguelike in D, C# and C++
    ... Since I have seen some interest on this newsgroup about which language ... The official compiler is dmd. ... The roguelike I am writing uses variable sized glyphs. ... trigger Hejlberg's garbage collector. ...
    (rec.games.roguelike.development)