Computer
Languages
by Lee Alexander
The
broadest definition I could find for language was a
means of communication. Different languages for different
nationalities, spoken and written languages for the trades and science
(otherwise known as jargon), all bespeak of communication among
humans or between species. A between-species example would be teaching
an animal to respond to verbal commands by a reward system. What
reward can you give a machine? Computers have certainly changed
the world and a new form of linguistics is not the least of it.
Computer
languages exist in genres: programming, operating systems, drivers,
macros, machine language, etc. Languages come and go but, for the
most part, they grow from common roots and have great deal of similarity.
This is particularly true for programming languages. Hardware innovations
can give rise to new algorithms; witness the GUI (Graphics User
Interface) which has been a major factor in supplanting the text-only
languages of the past: APL (A Programming Language), BASIC (Beginners
All-purpose Symbolic Instruction Code), COBOL (Common Business Oriented
Language), FORTRAN (Formula Translator). Does this list make you
wonder, which came first, the name or the acronym?
A
matter of definition – a gloss is the application of the first and/or
primary letters of a term to create a “word;” if that word is pronounceable,
it is an acronym. One of the most famous acronyms is radar (RAdio
Detection And Ranging). This term is now so common it is accepted
in lower case. By the way, try pronouncing RDR as a word. To be
anonymous, you “go under the radar.”
High
level computer languages are those that are (almost) readable as
opposed to machine level languages dedicated to a particular system.
Even Assembly Language, a fast and fundamental coding, must be translated
to work with a specific CPU (Central Processing Unit).The higher
level languages come in two forms: compiled and interpreted. A compiled
language is run through a software process that translates the code
into machine language; examples are C, C++, and Delphi . Interpreted
languages are translated and executed one instruction at a time;
examples are Basic, Visual Basic, and Java. A compiled program (after
compilation) will run faster than an interpretive one. However,
changes in the faster program require re-compilation.
This
is an example of Fortran coding.
C
PROGRAM TO AVERAGE THREE NUMBERS
C
A, B, AND C DENOTE THE NUMBERS
C
AV DENOTES THE AVERAGE
A=12.25
B=19.40
C=17.10
AV=(A+B+C)/3.0
WRITE(6,10)AV
FORMAT(1X,'AVERAGE IS' ,F7.2
STOP
END
Would
produce AVERAGE IS 16.25
The
C prefix stands for Comment, a non-executable statement used for
documentation. In this instance, you would have to rewrite the program
to revalue the 3 constants and then recompile the program to run
it – not very practical. Of course, there are ways to input fresh
data without reinventing the wheel. That is beyond the scope of
this article.
The
following examples of programming in BASIC are
intentionally trivial. We just wish to show the mechanics of how
to use the application in Windows OS's. The instruction code can
be written in Notepad, the simple word processor included with the
Operating System. This demonstrates batch files , and uses
the filename extension of .BAT. They function in the MS-DOS
(Microsoft-Disk Operating System)environment; in Win XP,
you get there via Start | All Programs | Accessories | Command Prompt.
The first command you should enter in the MS-DOS environment is
DOSKEY . This utility will keep a list of the commands
entered for that session. Recalling a command is done by the arrow
keys; a mouse does not work in DOS. To get ‘Full Screen' in DOS,
use <Alt> <Enter> key combination.
The
following BASIC program takes a list of words as an argument and
outputs them as a single word per line.
@ECHO
OFF
REM
This is SHOWPRM3.BAT
IF
%1!==! GOTO OOPS
:TOP
IF
%1!==! GOTO END
ECHO
%1
SHIFT
GOTO
TOP
:OOPS
ECHO
Enter several words after %0
:END
The
% character is a placeholder for up to 9 items. The @, preceding
the ECHO OFF command, prevents that command from being displayed.
REM stands for Remark and is not an executable instruction; it is
used to document the program. The colon before a term makes it a
label . Labels and variables are not case sensitive, but
values are; alpha = a and ALPHA = a give the same result; however,
alpha = a and alpha = A are NOT equivalent.
Usage:
SHOWPRM3.BAT alpha beta gamma delta
Yields:
alpha
beta
gamma
delta
This
batch program deletes backup files named with the extension .bak.
The asterisk, *, is a wild card for any number of characters.
@ECHO
OFF
REM
This is BAK.BAT
IF
NOT EXIST *.BAK GOTO OOPS
DEL
*.BAK
ECHO
*BAK files deleted
GOTO
END
:OOPS
ECHO
No *.BAK files found
:END
To
see a list of COMMANDS for BASIC, type HELP |more. The switch “|more”
pauses the display at a full screen. Without it the display will
roll to the last screen and you will not be able to see the beginning
of the list. To view the rest of the list, type p (for
page) ® Lines: ; enter
the number of lines to view next. <CTRL> C is the “ESC” equivalent.
The following Website could get you started in learning more about
the BASIC programming language.
http://en.wikipedia.org/wiki/BASIC_programming_language
- Syntax
In
the Microsoft world, BASIC and QBasic (Quick Basic) has been supplanted
by Visual Basic (VB). A stand-alone product, it sells for ~$200.
VBA (Visual Basic for Applications) is included with Microsoft Office
applications.
From
http://en.wikipedia.org/wiki/Visual_Basic_for_Applications
What
Is Visual Basic?
When
Microsoft started getting hooked on GUIs (Graphical User Interfaces),
with a long series of Basic interpreters and compilers behind them,
they created Visual Basic. Distributed in both a DOS and a Windows
version, it allowed one to write a GUI with almost no trouble at
all. It is called visual because you can create the GUI just using
normal drag and drop techniques, see what it looks like as you go
and then VB writes the code for you. The DOS version ended with
1.0 (with a professional update) and the Windows version continues
to evolve. It went through version 6 before becoming VBNET. The
reason Visual Basic is so popular today is because it allows one
to very quickly write applications. It manages to be a RAD (Rapid
Application Development) environment by hiding all the little details
and only exposing the parts that are most important to us.
Programming
languages are a subset of computer languages. HTML (Hyper Text Markup
Language), for example, is a markup language – not a programming
language – but is still a computer language. Another example is
SQL (Structured Query Language) for accessing relational databases.
As a Novice SIG topic, we will be concerned with the more popular
entities.
The
following is courtesy of www.sharpened.net/glossary
:
C
is a high-level programming language that was developed
in the mid-1970s. It was originally used for writing UNIX programs,
but now is used to write applications for nearly every available
platform. Some nice things about the language are that it is easy
to read, it is flexible (can be used for a wide variety of purposes),
and C programs typically use memory very efficiently.
C++
, pronounced "C plus plus," is a programming
language that was built off the C language. The syntax of C++ is
nearly identical to C, but it has object-oriented features, which
allow the programmer to create objects within the code. This makes
programming easier, more efficient, and some would even say more
fun. Because of the power and flexibility of the language, most
programs today are written in C++.
Java
is Sun's trademark for a set of technologies for creating
and safely running software programs in both stand-alone and networked
environments. There was quite a hubbub between Microsoft and Sun
over Java code when Microsoft tried to modify it and include it
in Windows. For an exhaustive article on Java, see www.stanford.edu/class/cs193i/handouts2003/JavaSection.pdf
.
JavaBeans
- reusable
software modules that are written in the Java programming language.
These modules can be deployed in a network or within individual
applications, such as Web browsers and word processors, on any major
operating system. Like Java applets, JavaBeans can be used to give
Web pages interactive capabilities.
JavaScript
- a scripting
language developed by Netscape that allows programmers to create
interactive elements and dynamic content for Web pages. Widely supported
by Microsoft and Netscape browsers and other Web tools, JavaScript
code is embedded in HTML pages. JavaScript was initially based on
Sun Microsystems's Java, and it shares many of the features and
structures of that programming language.
JIT
- just-in-time compiler –
a code generator that converts Java byte code into machine code
designed to run on specific computer hardware, just before the Java
program is run. Although a JIT works much like a Java Virtual Machine
(JVM), it does its job more quickly. Java programs often run faster
with a JIT than with a JVM. Under Internet Options ®
Advanced tab ®
Microsoft VM section, you will
find a checkbox to toggle the JIT compiler.
The
following is from www.python.org/
Python
® is a dynamic object-oriented programming language that can
be used for many kinds of software development. It offers strong
support for integration with other languages and tools, comes with
extensive standard libraries, and can be learned in a few days.
Many Python programmers report substantial productivity gains and
feel the language encourages the development of higher quality,
more maintainable code.
Python
is absolutely free, even for commercial use (including resale).
You can sell a product written in Python or a product that embeds
the Python interpreter. No licensing fees need to be paid for such
usage.
PHP
- Stands for "Hypertext Preprocessor." PHP is
an HTML-embedded Web scripting language. This means PHP code can
be inserted into the HTML of a Web page. When a PHP page is accessed,
the PHP code is read or "parsed" by the server the page
resides on. The outputs from the PHP functions on the page are typically
returned as HTML code, which can be read by the browser. Because
the PHP code is transformed into HTML before the page is loaded,
users cannot view the PHP code on a page. This makes PHP pages secure
enough to access databases and other secure information.
A
lot of the syntax of PHP is borrowed from other languages such as
C, Java and Perl. However, PHP has a number of unique features and
specific functions as well. The goal of the language is to allow
Web developers to write dynamically generated pages quickly and
easily. PHP is also great for creating database-driven Web sites.
If you would like to learn more about PHP, the official site is
PHP.net.
PERL
- Perl stands for "Practical Extraction and Report
Language," but you don't really need to know that unless you
want to impress your nerd friends. Perl is a scripting language
which uses syntax similar to C/C++. It is commonly used by Web programmers
to create scripts for Web servers. Perl is especially good at parsing
text, so programmers often use it for reading and searching through
text files.
As
a regular computer user, you won't get to see Perl in action, since
it does most of its work "behind the scenes." Perl scripts
are run on the server computer before any information is sent to
your Web browser. Oh well, the code looks like hieroglyphics to
most people anyway.
API
- Although not strictly a programming language, API
( Application Programming Interface)
is
the specification defining how an application accesses the functionality
of an operating environment or another application. Programmers
developing Windows applications, for example, write to Windows APIs,
which provide access to such user interface elements as scroll bars
or icons as well as messaging, printing, and display functions.
An example is:
The
OpenGL® API began as an initiative by SGI
(Silicon Graphics) to create a single, vendor-independent API for
the development of 2D and 3D graphics applications. Prior to the
introduction of OpenGL, many hardware vendors had different graphics
libraries. This situation made it expensive for software developers
to support versions of their applications on multiple hardware platforms,
and it made porting of applications from one hardware platform to
another very time-consuming and difficult. SGI saw the lack of a
standard graphics API as an inhibitor to the growth of the 3D marketplace
and decided to lead an industry group in creating such a standard.
Glosses
and acronyms
tend to be intimidating but are a real part of the shorthand
jargon for the computer cognoscenti. Tossed about as literary barbs,
they can quickly alienate true seekers of information. The lengths
to which some go to create acronyms can be a little far-reaching.
Consider the following:
AJAX
( Asynchronous JavaScript and XML).
By
invoking the name of a mythical Greek hero and adding the superfluous
term Asynchronous, we are led to believe this is a good thing. An
alias for AJAX is IPU (In-place Page Updating), not quite as catchy.
|