Friday, March 4, 2011

The Compiler and the Interpreter

There once was a compiler that use to make programs for a guy living in Baltimore. The little compiler was used in order to translate source code into object code. This code is much easier for the computer to read and run the programs for the guy living in Baltimore. Object code is then translated down to machine language using a tool called a assembler. The assembler and the compiler were very good friends who knew each other from back in the day. They use to play basketball together in High School. Sometimes instead of using the compiler, the guy living in Baltimore would use an interpreter. This interpreter would take high level instructions and simplify it into a code which it could run. The compiler was used to translate the code directly into machine language. The three tools worked together for the guy living in Baltimore, translating the source code into formats that the computer could run. The guy in Baltimore continued to make money off the three tools and gave them very little gratitude for the hard work they did for him. One day the Compiler turned to the Interpreter and said "You and I should have a contest." The Interpreter got a puzzled look on his face and said "What kind of contest?" The Compiler replied "It will be a glorious contest to see who can make a faster program." The two shook hands and said "Good luck". The contest had begun. The Interpreter worked his hardest to make the source code into his executable form of language. He thought for sure that he would be able to beat the Compiler. Meanwhile back at the bat cave, the compiler was working hard translating his source code directly into machine code. The assembler watched as the Compiler translated his source code as fast and accurately as he could, waiting to offer assistance at any time the Compiler asked. The time had come for the two to run their programs and see whose was faster. The interpreter said "Ha, I've got this in the bag Compiler." The compiler looked deep in the interpreters eyes and replied "Not today Interpreter." The tension in the room was so thick you could have cut it with a knife. The Compilers program was far superior to the Interpreters. The Interpreter looked on at his certain defeat. The code was printed directly in machine form which made it run much faster than anything the Interpreter could produce. The interpreter said "I thought slow and steady won the race?" "Unless you are a Compiler, in which case you can translate code directly into machine form and seize the day." said the Compiler. The two shook hands and the Interpreter thanked the compiler for coming up with such a clever contest. Even thought the Compiler had beaten the Interpreter in their contest, the two stayed friends, and saw it as nothing more than a simple contest. And together the two made programs for the guy who lived in Baltimore.