Computer Science/Code generation

Advertisement


Question
Good day please what is the concept of code generation,intermediate representation,intermediate code generation,object code generation and implementation of code generation.

Answer
It sounds like you're talking about some of the steps to compiling.

Check out the wikipedia article http://en.wikipedia.org/wiki/Compiler for a more thorough understanding of the compilation process.

In a nutshell, you start with a basic text file in your target programming language (for example, C).  Generation of the initial code is usually done by a person, although there are tools that are designed to generate code from higher level designs, such as UML, or even convert from higher level languages (see http://developers.facebook.com/news.php?story=358&blog=1).

Following code generation, a compiler will usually make several passes (depending on the compiler).  Each of these passes does a certain step.  

In your case, each of the things you asked about represents a pass by the compiler.  Intermediate Representation is the first pass, and optimizes your code by replacing variables with their appropriate values and removing non-functional methods.  The compiler then generates an intermediate code in a lower-level language (usually Assembly) from your optimized higher level language.  The assembly code is then compiled into a binary "Object" file, which is done during the object code generation stage.

So, the pattern is: Human generates C code.  Compiler optimizes C code. Compiler generates assembly code from optimized C code.  Assembly turns the generated assembly code into object files (binary) in the native format of the processor you're using.

Also, please clarify what you mean by "implementation of code generation".

Thanks.

Computer Science

All Answers


Answers by Expert:


Ask Experts

Volunteer


John OConnor

Expertise

Specific and general questions about computer science, including data structures, file systems, computer programming languages, regular expressions, and Software Engineering. I can answer general and specific questions about Linux. I can answer general and specific questions about the Android operating system. I cannot answer questions about specific problems with Microsoft(R) Windows(R) or Apple(R) Mac(R)

Experience

I've programming computers since 1993, and have a Bachelors of Science in Computer Science. I have 3 years of experience as a professional Software Engineer, and 5 years before that as a professional web developer. Since 2008, I've been the lead engineer at OC-Technology and RAD Software systems, developing mobile applications for various architectures, including the Android Operating System.

Organizations
Linux Users Group at LAX (LiLAX), Open Source Education Institute (founder), Northrop Grumman Linux Users Group (NoGLUG).

Education/Credentials
Bachelors of Science in Computer Science, California State University, San Bernardino.

Awards and Honors
Multiple Commendations from Northrop Grumman Mission and Space Systems,

©2012 About.com, a part of The New York Times Company. All rights reserved.