Thursday, February 10, 2011

Project 8 - Source Code Verses Executable Code

Plato’s Cave Meets the Matrix - How we Communicate with Computers


In the movie “The Matrix”, Thomas Anderson is a computer programmer by day, elite hacker by night. He has what he perceives to be a full and complete life until events start to unwind in his life, and he discovers everything that he understood to be real is actual an abstraction of his real primal existence. This story has ancient roots, echoing the story told by the Greek philosopher Plato, in his work “The Republic”. In Platos Allegory of the Cave, Plato envisions all people but those most enlightened, the philosophers, to be like a group of people chained to the wall of a cave, living in the dark, trying to understand what is going on in the world about them. All the people are able to see and perceive are the shadows projected on the wall. The people’s view of the world is a highly simplified version of a full dimensional reality outside of their cave. Just as when a prisoner in the cave is freed from the cave and cannot comprehend what he sees outside of the cave in a fully dimensional, full color world, Thomas Anderson cannot believe what he is shown when he leaves the simulation of existence that he has always lived in.

Why do I bring up this interesting historic linkage between “The Matrix” and its ancestor “The Republic”? Not to create another Joseph Campbell style essay on universal myth cycles, but to illustrate the different ways in which we communicate with computers. Stick with me here, and I’ll keep drawing this picture until my pen closes the circle, and this all makes sense. A computer, a collection of nanoscopic electronic components, is designed to fundamentally speak a single language, binary, via billions of combinations of binary logic gates and memory cells. All of these tiny electronic patterns end up responding to either 1’s (power being applied) or 0’s (no power being

Machine Language is the most basic means we can use to communicate with a computer in a complex way. It is a series of commands and addresses of discreet memory locations described as a series of ones and zeroes. To all but those who dedicate extraordinary resources, it is not readable by most human beings. When a program is turned into executable code, it essentially is being transformed by a Compiler into a package of machine code that a particular hardware platform can understand. Assembly is a slightly higher level language that enables variables and some common commands to be used. Like an obscure language artificially designed to streamline communication, Assembly is still very far from the way humans have learned to communicate, resulting in a very cryptic and difficult to digest language, in spite of the insistence by David S. Touretzky in his paper “Source vs. Object Code:  A False Dichotomy”.

A higher level programming language allows a human being to look at the instructions that are being presented to a computer, and see in a more natural language manor what is being asked of the computer. What a person is looking at in a high level language is the Source Code, which not what the computer will see in the end. In the case of programs that are designed for an English language audience, the high level language appears to be somewhat cryptic english that nonetheless is fallowing a clear logic. Once the program is complete, it can either be run through an Interpreter, which will parse the Source Code to the computer a line at a time, dynamically translating the English to machine language, or to a Compiler, which will package it into a bundle of Executable Code (something.exe) of machine language.

All of this brings us back to the dilemma faced by Thomas Anderson, or Plato’s philosopher in the cave. Programmers of high level computer languages can read and understand their code that they are feeding to computers, but the high level language code created by JAVA, C++, Python, or any other high level language is actually just a construct designed to be read and consumed by the humans viewing it. If one delves deep under the layers of programming, the real physical hardware running at billions of instructions per second at nanoscopic scales is consuming a diet of 1’s and 0’s, a reality that looks nothing like the logical constructs that a programmer views.

Interesting, yes?

Tuesday, February 8, 2011

What's the Difference? Object Oriented Languages (Project 6)

Project 6 - Object oriented languages

Object Oriented Language Survey
This blog posting is designed to provide a very high level comparison of the most popular object oriented languages. In order to understand the basics of these languages and how they differ from each other, it is necessary to understand what an object oriented language is.

Aspects of an Object Oriented Language
At the heart of any object oriented programming language is the concept of the Object. An object has a state, an intrinsic quality of the object, and behavior, which is the way in which the object interacts with all that is connected to it. An object stores its state into fields, which act as variables or placeholders for the information that describes the state of an object. The behavior of a programming is referred to as its method or methods. A method operates on an object’s state using some type of predetermined algorithm.
An object oriented language is a collection of objects and their interrelationships. By encapsulating code into object instead of a stream of code, the following advantages are gained:
        Modularity, which is the ability to a program to be created from independent objects that can be reused within an application.
        Information Embedding - Data is maintained within the object, creating higher security by not exposing raw data.
        Code Recycle-ability - Code can be reused between projects
        Code Substitution and Debugging - Objects, in the process of debugging and troubleshooting, can be substituted easily by other well tested objects of code.

Object Oriented Programs share the following fundamental aspects: Class; Inheritance; Interface; and Package(s). A class is a common schema of information, with an instance being just that, a singular example of a class of object that is described by a schema. Inheritance can be seen when objects can share attributes in a hierarchical fashion, allowing common attributes of a class of objects to be shared, flowing in a parent to many children form. An interface is simply a collection of methods for an object that describes how the object will interact with aspects external to the object. A package is a collection of related classes and interfaces, provided as a means of organizing complex objects.

C++
C++ is the object oriented language that most closely resembles the procedural language C. C++ shares much of the syntax of C. One of the inventors of C++ refers to C++ as “C with classes”, a statement that reflect a shared heratage with one of the most popular procedural languages. C++ is not trademarked, which has allowed the language to flourish without the encumbrance of a language that is laden with licensing issues. C++ has a very flexible structure, allowing types of data to be converted to different types of data within the application.

JAVA
JAVA is an object oriented language developed by Sun Microsystems to be a language that would run on multiple platforms without the need to recompile the code for each specific hardware type. A JAVA application runs in a JAVA run-time environment, allowing JAVA code to be compiled and run abstracted from the hardware beneath. JAVA is a highly structured language with a rich set of tools available to validate the data types in use, manage memory, and dynamically debug code before and during the compilation process.

Python
Python is a highly human readable object oriented language that is licensed as open source, providing a free licensing model even for commercial software. Python lends itself to being highly modular, with a large open source library and a large set of syntax shared with C/C++ that allows for an easier learning curve for experience programmers.

Object-C
Object-C is another object oriented language that was designed to resemble the syntax of the C programming language. It was licensed to NeXT Computers, which was purchased by Apple Computers, allowing it to become the favored object oriented platform for Apple devices (OS X and IOS, namely). Object-C is designed to be a lean interpretation of the C programming language, structured as an object oriented language.

Delphi
Delphi is the grandchild of Borland Software’s Turbo Pascal (so old that it is one of the last programming languages I studies in the past), in the form of an object oriented language. Delphi is a fast compiling, highly structured language that has a very readable format structure. Due to the long history behind this language and ease of understanding, it is a popular language.

Ruby
Ruby is another open source language that is designed around best of breed object oriented languages with a very natural syntax. It has become especially popular because of the Ruby on Rails, which is a free web development environment that creates a framework for developing web platforms with minimal programming effort. Ruby is a high functioning object oriented language that is someone unique in supporting only single inheritance, which creates a simplicity in defining the relationship between objects in its code.

Comparison and Contrast

The following table provides a very brief overview comparing these popular object oriented programming languages.

Language
Overview
Similarities
Differences
JAVA
The most popular object oriented language with as few platform dependencies possible
class-based, strong resemblance to C programming libraries
Multi-threaded language the relies on the JAVA run-time environment to interact with the underlying hardware
C++
An extension of the C Programming language in an Object Oriented format
Syntax so similar to C programming that it is often considered to be a merged language
In addition to being object oriented, C++ provides flexible declarations of data types, compared to C
Python
Open Source natural syntax language designed as a powerful, easy to learn language
Python runs on many common hardware platforms, with a large set of libraries resembling C
Python is a stronly typed language that prevents data types from being easily changes within an object
Object-C
The primary object oriented language for Apple platforms
High similarity to the syntax of C
Instead of objects calling a method to communicate, Object-C uses a message passing paradigm to allow modules to interact with each other
Delphi
Object Oriented descendant of Pascal
Very human readable formatted object oriented code
Very Windows centric development platform
Ruby
Open source language with ease of human readability of code that can be combined easily into high power code
based on the simplest aspects of Perl, Smalltalk, Eiffel, Ada, and Lisp
Everything in Ruby is an object, and every data type in Ruby has a value