Languages Paper

advertisement
Joseph Hoeppner
Programming Language Paradigms
Languages Paper
10/21/13
It is a bit of a rarity for a programming language to withstand the test of time; languages
come and go as new ones are created as replacements. In spite of this trend, COBOL has
remained useful over fifty years after its creation. COBOL, or the Common Business Oriented
Language, still makes up the backbone of industry today. In 2009, it was reported that 80% of
business transactions take place using COBOL programs, and that 65% of all software is written
in COBOL [1]. But why is this language still used today when so many others have been
forgotten? First, COBOL was designed with readability in mind. COBOL is a very verbose
language by today’s standards. It was designed to be a language that anyone, programmer or not,
could pick up and understand. While it did not succeed on both of these fronts, its focus stopped
it from becoming terse, and is still very readable to programmers today. COBOL programs are
rigidly structured into distinct segments, each of which serves a unique purpose. For instance,
one segment defines all of the variables to be used in the program, one defines all of the
environmental variables, such as peripherals and files that will be used during execution, and
another separate segment contains the program source code. This separation brings order and
understandability to the code, and it also serves as a form of self-documentation. Another boon
that COBOL’s rigid structure grants programmers is updateability and portability. If a program is
to be ported from one system to another, only the environmental variable section needs to be
updated; if variable values need to be changed or types updates, programmers just need to make
one change instead of hunting through source code to find every instance of a variable.
COBOL’s structure naturally lends itself to be readable and updateable, which helps to explain
its longevity [1].
What COBOL lacks in writeability it makes up for with reliability. Because it is so
verbose, COBOL is not the best language to quickly write programs in. Its rigidness adds
overhead to the time and effort needed to write simple programs, leaving some to move to other
languages and platforms for faster results. That is not to say that COBOL is overall lacking in
writeability. Its original specification did not contain pointers or user-defined types, which
simplified the language, added to its writeability, and cut down on abstraction. It was also written
to mirror English. Conditional statements, for instance, could be written “IF a < b AND > C
THEN…”, as we would say in English [1]. This would have helped programmers in the early
days adapt to using high-level languages and think about how to solve problems rather than how
to represent a solution in code. Regardless, COBOL makes up for any lack of writeability with
its long-run reliability. COBOL has lasted over the last fifty years because it is able to create and
support large-scale programs. The fact that our business world’s transactional backbone is
written in COBOL is a testament to the language’s reliability. However, COBOL contains some
dangerous statements that take away from its reliability. One such statement is the “ALTER X
TO PROCEED TO Y” statement, which makes it possible to write self-modifying code [2].
Statements like these can be avoided to ensure safe and reliable code, but their presence poses a
potential reliability and security risk.
Today, COBOL can be run cross platform. An open source compiler called OpenCOBOL
exists to translate COBOL code into C, and then to compile and run the newly-translated
program. This limits the run time support necessary for COBOL to C’s runtime support plus the
ability to run OpenCOBOL. All in all, COBOL is not a very costly language. It is very readable
and reliable, but lacks some writeability and abstraction capabilities. It is easily portable, requires
not much more runtime support than C needs, and is just about as efficient as C if a compiler like
OpenCOBOL is used.
LISP is another old programming language that has influenced computing today. Unlike
COBOL, though, it has not managed to survive all these years. Instead, LISP lives on in its child
languages – Common LISP and Smalltalk, to name a few. LISP, or LISt Processing, was the
second high-level programming language. As its name suggests, LISP is designed to manipulate
lists of data. Its most prevalent data structure is thus the linked list, which is uses to perform most
operations with an efficiency of O(n). LISP is not nearly as readable as COBOL is. On the
contrary, LISP has its own (at that time) unique program structure, and is still quite different
from the programs you expect today. LISP can be classified as a list-based language, and not
only because its specialty is list operations. LISP programs are themselves parenthesized lists.
This gives them many unique features, though it reduces readability. Programmers used to
languages like C and Java expect neat function calls and curly braces to delimit blocks of code.
They would feel out of place looking at LISP’s foreign syntax of nested parentheses and spacedelimited lists representing everything from function calls to recursion. LISP’s syntax also
affects writeability – there is a learning curve to LISP since even something as simple as a
function call is represented as a list. Despite the learning curve, LISP is a powerful language. It
was one of the first languages to support recursion because of its linked list structure, it is able to
manipulate LISP programs as easily as it does data since the programs are data lists themselves,
and it has become a favorite among the A.I. community [3].
One of LISP’s strengths is its reliability. It has a firm grounding in the mathematics of set
and list theory, which not only give it a reliable basis, but also make program verification easier
than in other languages. LISP was also the first language to utilize automatic garbage collection,
and many of today’s garbage collection algorithms exist because of LISP. For all of its
contributions and strengths, though, LISP has a higher overall cost than COBOL. It is harder to
learn, it does not lend itself to easy updatability, and it does not encourage documentation via its
syntax. Despite its drawbacks, LISP does have some advantages over using COBOL. LISP
allows for recursion and user-defined functions, two features that COBOL lacks. Once you
overcome its learning curve, LISP programs are a lot faster to write than their COBOL
equivalents since LISP is a more terse language than COBOL and does not contain the overhead
of partitioning code into segments. Lastly, LISP contains pointers, which gives LISP many levels
of complexity over COBOL, and allows LISP users to define their own data types. As previously
stated, the LISP language is not as used as Common LISP and Smalltalk, so it is not as well
supported anymore, though compilers and interpreters for it can still be found online today [3]
[4].
Lastly, let’s compare a modern language with LISP and COBOL. Python is an interpreted
language created in the early nineties. Like in COBOL, readability was a language design goal
for Python, though it was achieved through a very different approach. Rather than trying to make
Python as verbose as possible, Guido van Rossum, the language’s creator, decided to make it as
clear and uncluttered as possible. It is for that reason that curly braces are not used in Python to
delimit scope – tabs and whitespace are used instead. Python’s readability increases its
writeability as well. Its simplistic style allows new Python programmers to quickly see the
program’s syntax and scope. There are also only a few keywords in the language, which
simplifies language constructs, decreases user memorization, and gives users more freedom
when naming variables. Lastly, Rossum and the Python community agree that there should
generally only be only one syntactic way to do something from a language point of view. This
helps to simplify the grammar, give programmers one accepted and well-documented way to do
things, and, overall, make Python an easy language to pick up and learn [5] [6].
Continuing with its theme of simplicity, Python was designed as a small core language
that would be augmented by vast libraries of functionality. That way, the language is able to
focus on just the core features, and all other functionality can be added in later as the need arises.
Python can further be expanded via modules written in other languages like C. This gives users
the chance to make Python work for them and to adapt to the future’s rising needs [6].
In addition to being highly readable and writable, Python is reliable and portable. Most
any type of computer is able to run Python – the Python interpreter is a cross platform tool
capable of parsing and executing whole Python files. Python also comes with command line
tools to execute lines at a time, an IDE for multi-line code development, and comes in a
compiled language flavor, CPython. Because it utilizes the same interpreter regardless of the
platform it resides on, Python is sure to be reliable as well as portable [5].
One of Python’s strengths over the other two languages is its support for program
verification. Python has built in “assert” statements that can be used to test a variable’s value
during runtime, and to stop execution if the variable ever contains an unexpected value. Python
also prohibits statements from appearing where conditions are necessary. This eliminates
accidentally using the assignment operator instead of the equality operator inside an “if”
statement’s condition. These tools are not of the same caliber as LISP’s mathematical
background for verification, but they are potentially a lot more practical and useful for on-the-go
program verification [5].
I would argue that Python is a much less costly language than both COBOL and LISP.
Python’s simplicity makes for a very easy learning curve, and allows quick programs to be
written that can potentially solve large problems. In a way, it surpasses the understandability that
COBOL strove for and the speed that LISP’s terseness bought, and combines that with the
expandability and features of a current high-level programming language. Python does not win
on every count, though – COBOL programs will still outlive Python ones if their current track
record is anything to go by, and COBOL is naturally more documented than Python is. While
Python is more suited for quick, command line-esque solutions to problems, COBOL programs
require more structure and time to write. This structure is what gives COBOL programs
updateability and helps them to expand into fully fledged systems while Python programs remain
as quick programs. But, given today’s world, it will be much easier for a programmer to pick up
Python since it is so new, current, expandable, and community-developed and supported.
Works Cited
[1] Deartment of Computer Science & Information Systems. N.p., Apr. 2002. Web. 21
Oct. 2013. <http://www.csis.ul.ie/cobol/course/COBOLIntro.htm>.
[2] "COBOL." Wikipedia. N.p.: n.p., n.d. Wikipedia. Web. 21 Oct. 2013.
<http://en.wikipedia.org/wiki/COBOL>.
[3] "LISP (programming language)." Wikipedia. N.p.: n.p., n.d. Wikipedia. Web. 21 Oct. 2013.
<http://en.wikipedia.org/wiki/Lisp_(programming_language)L>.
[4] "LISP Tutorial 1: Basic LISP Programming." Simon Fraser University School of
Computer Science. N.p., n.d. Web. 21 Oct. 2013. <http://www.cs.sfu.ca/
CourseCentral/310/pwfong/Lisp/1/tutorial1.html>.
[5] "Python (programming language)." Wikipedia. N.p.: n.p., n.d. Wikipedia. Web. 21 Oct.
2013. <http://en.wikipedia.org/wiki/Python_(programming_language)>.
[6] "Python Overview." Tutorialspoint. N.p., n.d. Web. 21 Oct. 2013.
<http://www.tutorialspoint.com/python/python_overview.htm>.
Download