Вы находитесь на странице: 1из 5

Joel Vega 7/19/2010 6619-6844 Technical Definition: Compiler

A compiler is a computer program that is used to convert the written code, which the programmer writes, into binary code, that the computer understands. A compiler can also be defined as a routine for translating a program into machine-coded form (Oxford English Dictionary, 1989). A compiler is similar to the spell check in Microsoft Word. The compiler checks to see if the programmer has made any small mistakes that can be corrected easily. There are three main things that the compiler checks to make sure that a simple mistake has not been made: correct syntax, conflicting terms, and mistakes in logic. It is incorrect to state that the compiler looks for spelling and capitalization mistakes when referring to syntax, even though using a compiler is the easiest way for a programmer to check for spelling and capitalization. To explain, in programming language, the letters in the words in programming language can be capitalized at the programmers choosing. Almost all the words that are used in programming are simply variables, similar to math. In programming a word can represent a number, a group of words (Strings), or a Boolean (meaning simply true or false), among many other things. Because these words are variables for other things, the programmer has the power to choose what he wants a word to represent. With this power the programmer also has the ability to make up words since they are not actually words, but variables. For example, one can program the word thRee to represent 3; but words with different capitalizations are not the same, for example, three and tHree are not considered the same word. This is why it was stated that capitalization and spelling is not checked by the compiler. What the compiler actually checks is that whenever a programmer references to a word, the compiler checks to see if that word is created and is representing something. For example, if a programmer wants to add thRee and four, but the programmer never stated that thRee is representing 3 and four represents 4 then the compiler is going to display an error. So, the compiler doesnt check spelling and capitalization, but checks to see that all words used are accounted for. A compiler is very sensitive to conflicting terms. In programming the word int is a type that is used to refer to an integer. A type is the category that your word falls into (integer, String, Boolean, etc) (Oracle, 1995). If you label a word as an int then the compiler will know that the word is used to reference and integer, but what if the word that you choose to use is

int? In this situation the compiler will display an error because it will not be able to differentiate between your word and the type (Note: you can use iNt or any other variation since it is not the same word). Also, if you try to assign a value to a word that is for a different type then the compiler will also display an error. In other words, if my word is sentence and it is of type String, then the compiler will display an error if I try to give sentence a value of 1 because sentence is not an integer. In programming, the programmer must always declare what type a variable is before they start using that variable. As stated earlier, the main purpose of a compiler is to covert the code that is written by the programmer into a form of code that can be read by the machine that the programmer wishes to program. The way in which the compiler does this can get very technical because of the many steps that are needed. The code that the programmer writes is usually in words; by using words it makes it easier for another programmer to read and understand what is being presented to them. The final code that is read by the machine, however, is usually in Binary Code. As you can see in Figure 1 Binary Code consists of a series of 1s and 0s that represent characters. The way that the 1s and 0s are arranged and the amount of 1s and 0s determine what character they represent.

Figure 1

In Figure 2, you can see a brief description that shows the different steps that the compiler takes to convert the written code that the programmer writes to the Binary Code that the machine reads. By reading the Binary Code the machine can execute the commands that the programmer desires.

Figure 2

As you can see the compiler takes the original code that the programmer writes and transforms it to a different type of code, it then takes that code and converts it to another type of code, this continues until the code that is outputted is the desired code that the machine can read. To briefly explain what the functions of each of these sub-codes are, the Lexical Analyzer removes the spaces between the words and separates each word individually so that it can be analyzed. The Syntactic Analyzer organizes each word into it correct group that it belongs in based on the type that the word falls into. The Semantic Analyzer actually looks at each of the words and tries to interpret the meaning of the word; it also fills in missing information, if needed. The Code Generator actually transforms the word into the code that the machines can read. Finally, the optimizer determines if there is a more efficient way to execute the code. (Paul Anderson & Thomas W. Reps, 2010, 29-53) (R. Kiyohara, 2010, 254-260)

To conclude, nothing in computer programming is written in stone. All that was discussed above is an example of what a typical compiler does. What needs to be remembered is that a compiler is written by a computer programmer, so a compiler can only be as bad or as good as the programmer who wrote it is. There are some compilers that only check for mistakes in syntax and there are some compilers that look at the code in more detail to find more complex mistakes. There is one common factor between all compilers, however, and that is the fact that they all take the code that is generated by the programmer and convert it to a form that can be read by the machine that the programmer is trying to program.

References Anderson, P., & Reps, T. (2010). When good compilers go bad, or What you see is not what you execute. Embedded Systems Design, 23(1), 29-35. Retrieved from Academic Search Premier database.

Kiyohara, R., Mi, S., Tanaka, K., Terashima, Y., & Kambe, H. (2010). Study on Binary Code Synchronization in Consumer Devices. IEEE Transactions on Consumer Electronics, 56(1), 254260. Retrieved from Academic Search Premier database.

Oracle, 1995, Chapter 8 Continued: Performance Features and Tools, http://java.sun.com/developer/onlineTraining/Programming/JDCBook/perf2.html

Oxford English Dictionary, 1989, http://dictionary.oed.com/cgi/entry/50045560?single=1&query_type=word&queryword=compile r&first=1&max_to_show=10

Вам также может понравиться