Saturday, January 29, 2011

Project 5 - Interpreters and a compilers

Project 5 - Interpreters and a compilers

Compilers and Interpreters

Programmers are very quick to determine that they like things done in a very specific way. This common programmer trait has led to many different options for Interpreters and Compilers for all of the popular languages on the market. This blob posting explains what a Compiler is, What an Interpreter is, and lists a popular Interpreter and Compiler option or two for each of the major languages.

Compilers

At its very simplest, in computer programming, a Compiler is an intermediary application that takes a file from a higher level programming language, and translates the code into machine language. A compiler also performs logical and procedural hygiene, ensuring that there are no programmatic "grammar errors". A key aspect of a compiler is that it is not a real time process. A high level language will result in a file that the compiler translates into another executable file. A file is executable when it is in a low level format that a specific micro-processor platform can correctly interpret. This is one of the things that allows one root set of software, written in a high level language, can be used with minor changes on a number of different platforms. For instance, a game can be written for Apple IOS, and then re-compiled with some minor (compared to the effort necessary to rewrite the code from scratch) effort.

Compilers present a computer with high performance executable code, as opposed to a framework where an application is being interpreted a line at a time. Having a compiler act as the spell checker; grammar checker; and logic checker also ensures fewer programming errors in an application.

Interpreters give advantage to those who can’t wait to see the results of their code being run. It translates from high level code to machine code on the fly, instead of waiting a period of time for a file outputted from a high level program to be transformed into usable code. Code written for use with an interpreter is also more platform independent, meaning that there is no need to re-write the code to support hardware feature sets that differ from the original platform.

Interpreters

Interpreters on the other hand, are all about real time translation of higher level languages into machine code. Interpreters, a line at a time, will parse code that has been written in real time. The interpreter does not maintain a record of what was processed before, nor what is coming next. Like a goldfish, even if it is processing a loop of code (do this activity a thousand times in a row), it sees each iteration of a task as if it were being run for the first time.

Resources for finding Interpreters and Compilers in some popular languages


BASIC
Interpreter
Compiler
Note: Another great resource for free BASIC interpreters and compilers is http://www.thefreecountry.com/compilers/basic.shtml

PASCAL
Interpreter
Getting a PASCAL interpreter in this day and age is going to be a challange. You’ll either need to compile one from source code - http://homepages.cwi.nl/~steven/pascal/ , or you will need to use the debugging mode on an old copy of Borland Turbo Pascal
Compiler
Now that Borland Software’s Turbo Pascal is long gone, the best bet for compiling on a modern platform is Free PASCAL - http://www.freepascal.org/

C
Interpreter
The ups debugger includes a free C++ interpreter - http://ups.sourceforge.net/main.html
Compiler
Microsoft Visual Studio 2010 Express C++ - http://www.microsoft.com/express/Downloads/#2010-Visual-CPP
Note: Another great resource for free C++ interpreters and compilers is  http://www.thefreecountry.com/compilers/cpp.shtml

C++
As you can see, the same interpreters and compilers that work for C also will work for C++.
Interpreter
The ups debugger includes a free C++ interpreter - http://ups.sourceforge.net/main.html
Compiler
Microsoft Visual Studio 2010 Express C++ - http://www.microsoft.com/express/Downloads/#2010-Visual-CPP
Note: Another great resource for free C++ interpreters and compilers is  http://www.thefreecountry.com/compilers/cpp.shtml

Other References:

Project 4 - Advantages and disadvantages of programming languages

Project 4 - Advantages and disadvantages of programming languages


This blog posting gives a review of the different broad categories of programming languages. It should be noted that there is no central body that oversees the taxonomy of programming languages, so what is presented here is an overview depicting a popular understanding of the different programming languages and how they relate to each other. It is very easy to find well respected texts and articles that place languages into different systems of categorization. It turns out that the world is not black & white, but a continuous spectrum of grays....

Lowest Level Languages

Machine Language and Assembly Language are the least readable to human beings, and the most readable for computer systems.

Machine Language
Processors and micro-controllers communicate digitally in the form of sequences of 1's and 0's, in bits, bytes. Often displayed in hexadecimal format, each byte of machine language represents a single addressable location in memory. Machine language, also called machine code, being the direct digital input and output of a processor, is the lowest level language available to a programmer.
Advantages:
1.      Lowest memory consumed for the code to be executed
2.      Fastest programming language do the lack of processing layers
3.      No additional translators are needed between the machine code and the processor
Disadvantages:
1.      Extremely difficult to learn, write, and debug
2.      The code is very dependant on the hardware configuration it is being run on
3.      There is no process for tracking memory locations used by the machine code
Example:
        8086 Processor Machine Language
References:

Assembly Language
Assembly is a group of computer languages that map to micro-processor families. Assembly directly makes calls to the memory and processor hardware it is running on, resulting in a very fast running code. An Assembly language is very specific to the processor vendor, and very difficult to learn.
Advantages:
1.      High Speed processing compared to any higher level language
2.      Easier error correction compared to raw machine language
3.      There is the potential to leverage specific processor capabilities that may exist within the vendors support of an Assembly language.
Disadvantages:
1.      Machine dependant, not portable to other platforms
2.      Requires in-depth knowledge of the hardware the program will run on
3.      Slower than raw machine language
Examples:
        Macintosh Assembly System, to run on the original Motorola CPU sourced Apple Macintosh computers
References:
        Machine Language For Beginners, y Richard Mansfield, published 1983, http://www.atariarchives.org/mlb/introduction.php
        OSData.com - Introduction to Assembly Language - http://www.osdata.com/topic/language/asm/asmintro.htm

High Level Languages

A High Level programming language is a more human readable programming language than something that must be directly read by a micro-processor. High level programming languages are not directly dependant on the underlying processor location, but rather focused on more general purposes. This abstraction from the underlying processor is often handled by a compiler.
References:

Current Mainstream High Level Language Types

The following are four families of modern high level languages.

Procedural Languages
Synonymous with Imperative Programming, Procedural Programming follow a process of procedures, or functions, to interact with data. The programming routines are segregated from the data being manipulated. At its simplest, a Procedural language creates a series of procedures that the application carries out specific operations.
Advantages:
1.      Very well understood programming paradigms, with a broad range of programming languages and developers available
2.      Easier to quickly understand the flow of an entire application on inspection of the code.
3.      Easier to quickly develop smaller solutions, in comparison with O-o languages
Disadvantages:
1.      Lack of re-usability of the code being developed, for other applications.
2.      Troubleshooting challenges due to the lack of encapsulation of code with data
3.      Lack of flexibility
Examples:
        Basic
        Python
References:

Object Oriented Languages
Object Oriented Languages (O-o) are characterized by a modularity of design and function, maximizing the ability of a developer to re-use code from one project to another. Instead of segregation of code from data in O-o programming, these two are bound together into a single object of code.
Advantages:
1.      Designed to optimize the re-use of code from one application to the next.
2.      Objects require a higher level of documentation than other languages, and are therefore easier to maintain.
3.      Modification of software is easier through the modification of individual objects, or the introduction of new software objects.
Disadvantages:
1.      Lack of support from vendors, as well as lack of knowledge from programmers, due to Object Oriented Languages often being new to the marketplace
2.      The ease of stringing together O-o modules often encourages groups to bypass the traditional software design methods necessary to create a cohesive software package
3.      O-o design requires a different mindset than that used by Procedural Languages
Examples:
        C+
        Java
References:

The Obscure High Level Language Types

Functional Languages
A Functional Programming Language takes the form of single expressions that result in a function completing a task.
Advantages:
1.      Very Quick to learn
2.      Very easy to troubleshoot
3.      Very concise code
Disadvantages:
1.      Not well suited for high performance applications due to the abstraction and calls to function libraries that need to occur “under the hood”
2.      Requires a different set of programming skills from Procedural programming environments
3.      Not well suited to applications that require a Graphic User Interface (GUI)
Examples:
        SQL Query Language
        Haskal
        Skala
References:

Logical Languages
Logical Programming Languages, as the name suggests, are structured around mathematical logic constructs.
Advantages:
1.      Allows for rapid prototyping of tasks by creating lean programs to simulate logical phenomenon.
2.      Well suited for analysis of complex problems that involve logic sets
3.      Easier direct translation of mathematical notation into a program
Disadvantages:
1.      Very esoteric language with limited programming community knowledge and support
2.      Does not support GUI based requirements
3.      Code is rarely reusable, requiring application to be written from scratch each time.
Examples:
        Prolog
        LDL
References:

Language of the Future


Currently, Python is the language of the future. It is being taught in some of America’s best universities as a foundational computer science language, used by Google and other leading Silicon Valley companies as a core development language, and is increasing in popularity over time on the TIOBE Programming Community Index. For the last ten years, in fact, Python has been increasing in popularity faster than any other language.