Computer Languages: Compile, Interpret, Intermediate, Assembly, Machine
All computer languages are not the same. They do not work the same.
- If you developed a new programming language, what features would include, remove?
- Compiled languages vs interpreted vs intermediate
- Compiled
- Compilers process source code and usually produce machine language
- A linker then adds the library information and sets actual addresses in code
- Normal process is:
- edit
- compile
- link
- run
- early C cheated a little. It created assembly language instead of machine language, so its process was:
- edit
- compile
- assemble
- link
- run
- Compiled languages tend to execute more instructions in less time (run faster)
- Compiled lanuguages tend to be difficult to debug (require learning and using a debugger or staring at source code)
- Compiled languages tend to be strictly typed, tend to require declaration of variables
- Some examples: Fortran, COBOL, C, C++, PL/1
- Interpreted
- Interpereted languages compile/translate one line at a time into machine language and then execute them
- Speed is lost when a loop occurs and the interpreter has to reprocesss line(s)
- Some interpreters cache the translated lines to reuse when possible
- Interpreted languages tend to be loosely typed
- They are usually easier to debug since your code is run interactively, you can stop and look at values, even change them sometimes and continue -- essentially an interpreter is a on demand compiler running inside a debugging environment
- Some examples: BASIC (many of them), APL, Python (mostly), PHP, Ruby
- Intermediate
- Some compilers translate to an intermediate language (usually one that cannot run natively any where)
- You then execute the intermediate code in a interpreter
- This means the compiler produces the same code regardless of machine/OS
- It also means that an interpreter has to be written for every machine/OS combo (easier than writing a compiler)
- The first example of this that I know of is the UCSD Pascal Pcode
- Java is another common example. The interpreter is the JVM (Java Virtual Machine) that runs your code
- Unfortunately, JVMs vary between machine/OS combos and do not produce uniform/identical results. Math and logic are fine but things like guis differ. Because of these differences it is possible to produce code that works on one platform but not on another
- Assembly - Symbolic language that translates 1 to 1 to machine language
- Machine - the binary instructions the machine understands
- Compiled