create your own

Compilers and Intepreters

73
rate or flag this page

By AlexK2009


Barron's AP Computer Science, Levels A and AB Barron's AP Computer Science, Levels A and AB
Price: $9.82
List Price: $16.99
Computer Science Illuminated, Fourth Edition Computer Science Illuminated, Fourth Edition
Price: $64.98
List Price: $104.95
How Computers Work (9th Edition) How Computers Work (9th Edition)
Price: $21.82
List Price: $34.99
Computer Science: An Overview (10th Edition) Computer Science: An Overview (10th Edition)
Price: $51.75
List Price: $105.00

In my hub  on the development of programming languages I noted that a programming language is  a formal language  for communicating with a computer  without the ambiguity of human languages. One obvious point not stressed is that a computer language has to be executed by a computer or design of the language  degenerates into a futile intellectual exercise.  This requires a program to translate the language into instructions the machine can understand.   The earliest translation programs were called assemblers,  but hardly anyone codes in assembler  these days. Nowadays the translator for a programming language called (say) X is written in another language Y and developed  till it can translate   a version of the translator written in the language X.   This elegant circle with the snake eating its own tail then continues.  Here I discuss compilers, interpreters and the requirements for  a language to be a programming language.


Compilers: Principles, Techniques, and Tools (2nd Edition) Compilers: Principles, Techniques, and Tools (2nd Edition)
Price: $84.99
List Price: $106.00
Writing Compilers and Interpreters: A Software Engineering Approach Writing Compilers and Interpreters: A Software Engineering Approach
Price: $47.85
List Price: $70.00
Crafting A Compiler Crafting A Compiler
Price: $74.95
List Price: $103.00
Compiler Construction: Principles and Practice Compiler Construction: Principles and Practice
Price: $101.55
List Price: $157.95

compilers versus interpreters

    The two types of translator I am aware of are called  Compilers and interpreters.  An intepreter reads a program as written by the human developer ( or occasionally by  another  programme) into  low level instructions  that the  machine cans understand. A compiler  converts  the program into a stored sequence of machine instructions,  normally stored as  a file,  that are run by a program, often part of the operating system  and often started by a human. The process of creating this executable  may have a number of sub stages which  I will not deal with here.

An interpreter is flexible, it  can be used to produce code that it later runs but there is a  performance cost because of the need to translate  the program on the fly each time the programme runs.  However the performance cost can be very small. Intepreted languages   include what are called scripting languages, examples are Perl,  Python, Groovy and Ruby. They are useful for rapid development of small programs and are also sometimes called lightweight languages.

A  compiler  generally  produces an executable that runs  the same program  faster than  a scripting language and  it is harder to examine the compiled program and modify it, which may have advantages for intellectual property protection.

Compilers are harder to write than interpreters  but can include   checks to prevent the most common programming errors. Compiled languages include Java, C, C++ and C#.  An interesting twist on compilation is the virtual machine, a program that  simulates a computer within a computer, and for which a programming language is written. The most famous example of a virtual  machine oriented language is Java which runs on the (surprise) Java Virtual Machine (JVM) , though many other languages have now been (re)written for the Java Virtual machine.   Virtual machines were used for early experiments in simulated evolution.

What make a programming language a programming language

Markup languages are text markup systems that  can be thought of as proto languages. A markup language will “decorate” text with directives that, for example, say how the text should be formatted. For example  in HTML the statement  <b>Hello</b>   tells your web browser to render the word “hello” in bold text.  Markup languages include XML, HTML, SGML and Latex, a text markup language especially useful for typesetting mathematics and with extensive cross referencing and indexing facilities.

Markup languages  are not programming languages because they lack  certain features. They do not allow creation of subroutines, encapsulate bits of code that can be reused in many places, have no capacity for looping ( doing the same thing several times) or non determinism ( if X is true then do Y) and they do not have input output capacities .  I consider these to be the minimal requirements for a programming language.

Print   —   Rate it:  up  down  flag this hub

Comments

RSS for comments on this Hub

Helen Cater profile image

Helen Cater  says:
2 months ago

Great hub. Not sure I understood all of it, but you have given me a little more knowledge on this subject.

AlexK2009 profile image

AlexK2009  says:
2 months ago

Thanks. Glad to know it helped

msorensson profile image

msorensson  says:
2 months ago

Informative! Thank you Alex.

At least I confirmed my previous [intuitive] knowledge of compilers and interpreters and you put it in an understandable language.

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working