Timberwoof Essays {pagetitle}
Programming Languages Compared
 

In article <BCB1D831.4B8C5%snit@nospam.cableone.com>,
§?¡? <snit@nospam.cableone.com> wrote:
> What programming language(s) do you use, and why?
>
> What are the strengths and weaknesses of different languages you know (or
> have knowledge of).
>
> Just curious

I have used assembler, Basic, Visual Basic, PL/I, Fortran, WatFiv, Ratfor, Cobol, Pascal, Ada, C, C++, and a smattering of Perl.

Assembler is one step above the machine language itself. Each CPU instruction is one command in the assembly language. However, where the CPU demands absolute references to places in memory, assembler introduces symbolic variables. These allow programmers to define words that represent places in memory and let the assembler take care of the finicky details such as proper memory alignment. Assembler produced the fastest code, but had no systems for managing complex data types or control structures. Modern optimizing compilers have made the speed gains of assembler insignificant in all but a few cases. And the value of performance gains of higher-level languages through automated error-checking often outstripped what assemblers could deliver. Assemblers were thought to be the Holy Grail of programmer productivity.

High-level Programming means greater abstraction from the machine itself. Where machine programming requires one to know the numbers that represent operations, addresses, and registers, assembly programming introduces symbols that are resolved by another program. Thus assembler is a higher-level language than machine. Although much simpler than Fortran, both Basic and Fortran are "high-level" languages. But both of them would require complicated constructs to simulate object-oriented programming, so that concept is even higher-level. High-Level Programming was thought to be the Holy Grail of programmer productivity,

Basic was what they taught kids in school in the '70s, and given the hardware available at the time it was an adequate language. However, it didn't teach structured programming and allowed spaghetti code.

Visual Basic was an improvement in that it promoted structured and object-based programming. However, it was still interpreted and thus had performance issues.

PL/I was taught in college. It's a big compiled language, with far more features than a first-year student needs, but it is structured and strongly typed, which are useful for teaching programming.

Fortran was the warhorse of scientific programming, used mostly because that's what everybody used. Clearly an early attempt at designing a programming language, it was created before the underlying concepts of translation were really understood. As a result, compilers for it are complex and error-prone (though mostly debugged by now) and it is not structured, let alone object-based or object-oriented. Several years ago its authors basically apologized for the language and asked people to stop using it.

Cobol is a cheap cover for a specific IBM computer's assembler, the less said about which the better.

Pascal is a strongly-typed structured programming language that was promoted and disdained as a "teaching language." Pascal would not permit operations on mixed types: you could add two integers or concatenate two strings, but you could not add a string to an integer. Later extended by Borland into Turbo Pascal and then Object Pascal, it was the native programming language of the Mac OS through System 6. Although in industry it steadily lost favor to C during the '80s and early '90s, it retained a foothold in academia. Its strong typing irritated C programmers until they realized that it was much better to have the computer catch that sort of pesky error for you.

Structured Programming: where Basic and Fortran controlled execution of code by referring to specific lines of code (if A > B then continue execution at line 100, otherwise continue at 200), structured programing controlled execution by the grammatical structure of the control statements. For instance, an if statement would contain a logical expression to evaluate followed by a block of code to execute if it was true, and then by a block of code if it was false. A loop statement would control the repeated execution of the following block of code. Improper nesting of beginnings and endings of such blocks of code would be flagged as errors by the compiler -- they were probably errors in the code design. Nothing in Fortran or Basic would enforce such discipline. Structured Programming was thought to be the Holy Grail of programmer productivity.

WatFiv is a structured successor to WatFor, Waterloo Fortran. Useful for teaching people clever things to do with card-punch machines.

Ratfor is another attempt at structured Fortran. It's essentially a precompiler based on C and Pascal that takes a strange-looking but structured mixture of Fortran, C, and Pascal and converts it into strange-looking but syntactically correct Fortran. It was useful for a senior project in computer science, and perhaps for people trying to do modern structured programming at an installation where only Fortran is available. It's fair to call it obsolete.

C is closely related to UNIX. It was deliberately weakly-typed and allowed direct access to a processor's registers so that operating system gurus could optimize operating system code. Weak typing was hailed as a significant advancement by programmers irritated at automated error-checking but in the end was recognized by most to cause more problems than it solved. For instance, it would allow you to add an integer to the integer representation of a letter, which usually makes no sense. ANSI C reintroduced strong typing and a developing rift in the space-time continuum was quickly mended.

If C was weakly typed and Pascal was strongly typed, then Ada was fascistically typed. You could define BlowlingPins to be a class of integers and define PoolBalls to be another class of integers, but unless you also defined the mathematical operations that could be inflicted upon BowlingPins and PoolBalls, you could not add them. The US DOD surveyed its various contractors and discovered that there were thousands of obscure, special-purpose programming languages being developed, mostly by people who didn't really understand what they were doing. None of these language could talk to any of the others, and all of them had the same sorts of bugs. So the DOD funded the development of a single, systemwide language to be used in all new projects. Ada was object-based but not object-oriented. It was an attempt to define a programming language robust enough to catch at compile time as many errors as possible. Perhaps had Ada been used on that lost Mars probe, the miscommunication between a rocket booster that took commands in miles per hour and a satellite that gave commands in meters per second might have been found much earlier in the project.

Object-Based Programming was an advancement over structured programming. Code and data could be hidden inside packages so that only an authorized piece of code could read or write to a variable or data structure. Any other part of the system that needed access to that data had to go through the read or write methods. Thus a subsystem could be rewritten in a different way, and as long as its access methods were the same, nothing else would break. Under earlier systems, nothing prevented some outside system from sneaking a peek or poke at data ... and breaking whenever the underlying data structure was redesigned.

Object-Oriented Programming was a further refinement of the concept. Inheritance and polymorphism were added: Abstract objects could be defined and refined by reusing code and making only minor changes. For instance, a button, a radio button and a checkbox could all be minor variations of an abstract class of clickable screen widgets. You write the code for click detection and state setting in the abstract class, let the three widgets inherit that, and then write the bits that make them different in the more specific definitions. Object-Oriented Programming was thought to be the Holy Grail of programmer productivity.

Object C was the object-oriented programming language of NeXTstep and is now at the heart of OS X. C++ was written as an extension to C by Bjorne Stroustrup to give C object-oriented features. They have some syntactic differences, but differ principally in when certain relationships between objects are defined. In C++ relationships between two interacting objects are defined when the program is compiled; in Object C they are settled at runtime. C++ was thought to be the Holy Grail of programmer productivity.

Perl is an interpreted report-generating language much used to implement special interactive behaviors in web pages. It is structured but not object-oriented, and strongly typed with intelligent coercion of types. For instance, if you try to add a string that contains the character representation of an integer to an integer, it will do the right thing and convert the character string to an integer and then do the math.

Java is an interpreted C-like language. It was intended to be able to run anywhere, but early on suffered performance problems. With faster processors and better interpreters, performance has increased, but there are still compatibility concerns. Java features automated garbage collection, which means that it knows when some piece of memory is no longer being used, and returns it to the pool of available memory. Java was thought to be the Holy Grail of programmer productivity. This is not an exhaustive list of programming languages, nor of the differentiating features of the languages I did discuss. Which language to use depends, of course, on what you are doing. And where this was an introduction to a textbook on comparative programming languages, that is a textbook.

 

   
 
Google
 
Web www.timberwoof.com
 
  Essays. Copyright © 1997–2005 by Michael Roeder. All Rights Reserved.
Main: http://www.timberwoof.com/essays/index.shtml; Home: Timberwoof’s Den; Letters to Author: Timberwoof’s Mailbox