Compilers and interpreters are programs that translate high-level programming languages or source code such as C++, Java, Pascal, Python, and Objective C into low-level languages such as machine code, and assembly language and vice versa. While both types of programs do basically the same thing, the way they work is different. Compilers will translate a whole program at once and create a file from your chosen programming language, which is executable by your operating system. Interpreters translate your chosen programming language line by line. It translates each line and runs those instructions before moving on to the next line. Usually, compilers are used for more advanced programming languages such as C++ and Pascal, while interpreters are used for more basic languages such as JavaScript and Basic.
Compilers turn source code into machine code and save an executable file as the result of this process. You can then open the executable file and your computer will run your program. Compilers produce programs that can run quickly and compilers also can spot syntax errors as they are compiling and translating data. Downsides can be a lengthy compile time and although compilers find errors, it still doesn’t mean your program will be completely free of errors. A compiler’s complexity depends on the syntax of the language you are compiling. A C compiler is much simpler than a compiler for C++ or C#.
Interpreters execute source code directly. They do this by executing written high-level languages line by line. The plus side to interpreters is that you could run programs without waiting for lengthy compile times to complete. The problem is that they only store the machine code in memory instead of a separate executable file like a compiler does. This makes distribution a problem because you would have to distribute your source code along with an interpreter that can convert your source code into machine code. The original reason interpreters were invented is because compilers were so slow. Nowadays, compilers are much faster and interpreters are mostly used for running scripted language and for learning purposes.
Interpreters and Compilers for BASIC, PASCAL, C, and C++ can easily be found with a simple Google search. Simply search, “interpreter or compiler (whichever you are looking for) for a programming language and your operating system.” There are tons of free interpreters and compilers out there for all of these languages. For a Mac you get a free program with your operating system called XCode. Although I haven’t used it yet I believe that it only compiles Objective C language. To use XCode you need a Mac with an Intel processor, Mac’s Snow Leopard operating system, and you need to be registered as an Apple developer, but this is easy to do. It’s just an online registration process and it’s free. You can download XCode from Apple’s website or install it from your operating system install disk.
A few places I found with many compilers and interpreters are:
Once you have your interpreter or compiler, all you need is a text editor to write your code. When your code is written, open your saved text file of your code and watch it come to life!
No comments:
Post a Comment