Jump to content

Nimrod Programming/Compiled language

From Wikibooks, open books for an open world

What's a compiled language?

[edit | edit source]

Before knowing what that means we'll need a little insight on what happens inside a computer. Computers work with two numbers 0s and 1s, anything else is constructed using those. Now imagine for a moment you want to write an application, and small application can have thousands of those, so if we tried to write directly in binary (that's the name which receives those 0s and 1s) (indeed, possible) you should wish typing everything perfect because only one number not in place would make the application misbehave (if it worked at all), so writing in binary it's something not thought about. So if we don't write directly computer's language, how we do to talk to the computer? Well let's consider this: your friend receives a letter in English but he doesn't know English, let's say he's German (yes, a German who does not know English) what you would do? You could do two things: either rewrite it in German or translate the letter directly in front of him.

Interpret

[edit | edit source]

In computer science taking the letter and translating it directly to your friend it's known as interpreting. Just as you would do with your friend a program (called interpreter) translates those sentences to the computer and executes them, this is done when you need to execute the program. The languages which interpret are called interpreted languages.

Compile

[edit | edit source]

However, rewriting the letter it's known as compiling. The program which translates from the language you can understand (called source code) to the so called binary code or machine code is called compiler, what's more, languages which use a compiler are called compiled languages.

Interpret vs Compile

[edit | edit source]

So which it's better? None of those. "Why?" you may be asking, in computer science there's not always a "better", the fact that you choose one or another depends on what you want to achieve. Interpreted languages are generally slower when executed but in turn they don't need that phase of translating everything from source code to machine code (which can be really slow!) and they normally offer some features which make them easier.