Monday, February 21, 2011

Object-Oriented Programming Languages

The following programming languages are some of the most commonly used object-oriented languages.  They are all similar in some ways and different in others.  Some are derived from the C language, some from Pascal.  Some incorporate Smalltalk, others do not.  Some are multi-paradigm languages.  Each language is different and has its advantages and disadvantages.  The program you are writing and its needs determine which language would best facilitate it.

JAVA
Java derives most of its syntax from C programming language.  Although it shares syntax with C it has a simpler object model and fewer low-level facilities.  Java uses a compiler to transfer Java programming language into Java bytecode, which can be interpreted by any Java Virtual Machine.  This enables Java programming language to be read by any computer regardless of the computer’s architecture.  The Java Virtual Machine acts as an interpreter for your computer and translates the bytecode into machine code readable by your computer.  This enables Java programming to be written once and run anywhere.  Due to its ability to be ran on any computer Java is currently one of the most popular programming languages.  It is used for application software and web applications.

C++
One of the most popular programming languages ever created is the C++ language.  C++ was derived from C with classes added to it.  C++ has many uses including: writing systems software, application software, device drivers, embedded software, high-performance server and client applications, hardware design synthesis, and video game software. 

Python
Python is a multi-paradigm programming language.  It permits the use of object-oriented programming, structured programming, functional programming, aspect-oriented programming, and many other paradigms with the use of extensions.  Languages such as C, C++, and Java are incorporated into Python.  Python is a scripting language that emphasizes code readability, simplicity, and ease of use.  Although C and C based languages are incorporated in Python, Python’s primary language abandons the C language for more readable commands.  Python utilizes dynamic typing and automatic memory management.  Python is a scripting language for web applications that is used by many large organizations including YouTube, Google, Yahoo!, CERN, and NASA.  It also is used for 3D animation packages and 2D imaging programs.

Objective-C
Objective-C is an object oriented programming language used primarily for Macintosh’s OS X and iOS operating systems.  Objective-C is a reflective language meaning that it can observe and modify its own structure and behavior in runtime.  Objective-C adds a Smalltalk style of messaging to the C programming language. Objective-C defers some decisions until runtime that C++ would make at compile time.  These decisions are known as dynamic dispatch, dynamic typing, and dynamic loading.

Delphi
Delphi is an object oriented, visual programming environment.  It is used to develop 32-bit and Microsoft.net applications that can be used on Windows and Linux operating systems as well as on the Internet.  Delphi has many different revisions, most currently Embarcadero Delphi XE, and is still evolving to complement evolving computer technologies.  Delphi allows you to build applications faster with pre-built components and a drag and drop visual design.  Many applications are written in Delphi including Skype and FL Studio (formerly Fruity Loops).

Ruby
Ruby is a general purpose, multi-paradigm, programming language that supports object-oriented, dynamic, functional, imperative, and reflective paradigms.  It utilizes syntax inspired by the Perl programming language with Smalltalk like features.  Ruby also uses a dynamic type system and automatic memory management like Python’s programming language.  Ruby is mainly used to create interactive web pages.

Wednesday, February 16, 2011

Interpreters and Compilers


Compilers and interpreters are programs that translate high-level programming languages or source code such as C++, Java, Pascal, Python, and Objective C into low-level languages such as machine code, and assembly language and vice versa.  While both types of programs do basically the same thing, the way they work is different.  Compilers will translate a whole program at once and create a file from your chosen programming language, which is executable by your operating system.  Interpreters translate your chosen programming language line by line.  It translates each line and runs those instructions before moving on to the next line.  Usually, compilers are used for more advanced programming languages such as C++ and Pascal, while interpreters are used for more basic languages such as JavaScript and Basic.

Compilers turn source code into machine code and save an executable file as the result of this process.  You can then open the executable file and your computer will run your program.  Compilers produce programs that can run quickly and compilers also can spot syntax errors as they are compiling and translating data.  Downsides can be a lengthy compile time and although compilers find errors, it still doesn’t mean your program will be completely free of errors.  A compiler’s complexity depends on the syntax of the language you are compiling.  A C compiler is much simpler than a compiler for C++ or C#.

Interpreters execute source code directly.  They do this by executing written high-level languages line by line.  The plus side to interpreters is that you could run programs without waiting for lengthy compile times to complete.   The problem is that they only store the machine code in memory instead of a separate executable file like a compiler does.  This makes distribution a problem because you would have to distribute your source code along with an interpreter that can convert your source code into machine code.  The original reason interpreters were invented is because compilers were so slow.  Nowadays, compilers are much faster and interpreters are mostly used for running scripted language and for learning purposes.

Interpreters and Compilers for BASIC, PASCAL, C, and C++ can easily be found with a simple Google search.  Simply search, “interpreter or compiler (whichever you are looking for) for a programming language and your operating system.”  There are tons of free interpreters and compilers out there for all of these languages.  For a Mac you get a free program with your operating system called XCode.  Although I haven’t used it yet I believe that it only compiles Objective C language.  To use XCode you need a Mac with an Intel processor, Mac’s Snow Leopard operating system, and you need to be registered as an Apple developer, but this is easy to do.  It’s just an online registration process and it’s free.  You can download XCode from Apple’s website or install it from your operating system install disk.

A few places I found with many compilers and interpreters are:

Once you have your interpreter or compiler, all you need is a text editor to write your code.  When your code is written, open your saved text file of your code and watch it come to life!

Monday, February 7, 2011

Common Programming Paradigms and the Language of the Future

Today there are many different Computer Programming Languages.  These languages are different, but use similar techniques called paradigms.  Deciding which language is best to use when writing your program is incredibly important.  To do this, find out what paradigms you would need to utilize to properly operate your program, and find a language that uses those paradigms.  Also using a commonly used language can be to your advantage.  Following, are four of the most common paradigms that programming languages use, and some advantages and disadvantages of each.

Object-Oriented Programming Languages are programming languages that use objects (independent entities which contain data and can respond to messages).  OOP is widely used, most commonly with the C++ and Java languages.  The advantages to using OOP include:  They are easier to learn, understand, manage, and maintain; objects can be derived from classes (a collection of objects of similar type) making similar objects easier to write; and OOP’s are easier to test and debug.  This is possible because if there is a problem with one or multiple objects, those objects can be independently re-written.  Otherwise a program would have to be re-written as a whole, taking much more time and effort.  OOP also does a good job of modeling the real world.  This is because ideas are organized like the real world with similar items (objects) grouped into categories (classes).

Although Object Oriented Languages are easier to manage and maintain, thus less expensive in the long run, there is a much higher upfront cost.  Thus it is used more for programs that are large and expected to be updated in the future.  OOP’s are best used for programming large applications.  For many small programs OOP gives no advantages over other languages and would require more time to write.  In addition OOP requires more memory to run, so if you are trying to write a small fast running program, OOP languages are the worst choice for your program.

Procedural Programming also known as imperative programming contains a series of steps for a computer to carry out.  Procedural Programming Languages utilize a small amount of memory, are simple in structure, and are easily implemented with compilers and interpreters.  The simplicity of Procedural Programming Languages makes it unusable when writing more complex programs.  It is considered to be less productive than other paradigms.  Procedural Programming carries out one process at a time, so when you are writing programs which require parallelization (two processes being completed at once) Procedural Programming languages are unable to carry this out.

Functional Programming Languages are computer languages that are treated by computers as mathematical functions.  It was derived from lambda calculus, by forming programs designed by the composition of functions.  Functional Programming avoids mutable data (objects that can be modified after it is created).  The earliest functional programming language was LISP, although it does contain non-functional elements.  LISP was pre-eminent in the development of Artificial Intelligence programs.  Advantages of Functional Programming are that programs can be easily understood, functions are reusable, and large programs containing thousands of functions are possible because the functions have no side effects.  Downsides to Functional Programming include efficiency (relating to it’s use of CPU and memory), difficulty doing input-output, and that some aspects of problem solving can’t be performed in a functional manner.

Logical Languages, including PROLOG (the most prominent Logical Programming Language), use predicates and rules of inference to determine an output.  Logical Languages are good at reasoning about programs, have well understand semantics, and can lead to concise solutions to problems.  Although Logical Programming can reason about programs they have trouble understanding and debugging large programs.  They also are slow in their execution and have a limited view of the world (only understands it’s predicates and rules of inference).

Of all the programming languages available today I think Objective C will be used frequently in the future.  It is used mainly for Mac’s OSX and iOS software.  There has been a surge in Objective C’s use in the past few years due to Apple’s iPhone and the high use of it’s apps.  This will only expand now that Verizon has the right to sell iPhones, ending AT&T’s exclusivity rights to the highly popular iPhone.  Python seems to be another language that is on the rise recently.  Many large corporations use Python including Google, Yahoo!, and YouTube.

Sources: