Skip to main content
Engineering LibreTexts

The Toolchain

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Chapter 7. The Toolchain

    Compiled v Interpreted Programs

    Compiled Programs

    So far we have discussed how a program is loaded into virtual memory, started as a process kept track of by the operating system and interacts with via system calls.

    A program that can be loaded directly into memory needs to be in a straight binary format. The process of converting source code, written in a language such as C, to a binary file ready to be executed is called compiling. Not surprisingly, the process is done by a compiler; the most widespread example being gcc.

    Interpreted programs

    Compiled programs have some disadvantages for modern software development. Every time a developer makes a change, the compiler must be invoked to recreate the executable file. It is a logical extension to design a compiled program that can read another program listing and execute the code line by line.

    We call this type of compiled program a interpreter because it interprets each line of the input file and executes it as code. This way the program does not need to be compiled, and any changes will be seen the next time the interpreter runs the code.

    For their convenience, interpreted programs usually run slower than a compiled counterpart. The overhead in the program reading and interpreting the code each time is only encountered once for a compiled program, whilst an interpreted program encounters it each time it is run.

    But interpreted languages have many positive aspects. Many interpreted languages actually run in a virtual machine that is abstracted from the underlying hardware. Python and Perl 6 are languages that implement a virtual machine that interpreted code runs on.

    Virtual Machines

    A compiled program is completely dependent on the hardware of the machine it is compiled for, since it must be able to simply be copied to memory and executed. A virtual machine is an abstraction of hardware into software.

    For example, Java is a hybrid language that is partly compiled and partly interpreted. Java code is complied into a program that runs inside a Java Virtual Machine or more commonly referred to as a JVM. This means that a compiled program can run on any hardware that has a JVM written for it; so called write one, run anywhere.

    The Toolchain is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?