
LAST
UPDATE: 12/13/00
This Learning Module is constantly being updated!
This
is the most current version of Learning Module VI; however, the study guide
needs to be written (for the independent learner) and
some
of the content sections, links, and assessment tools need to be fine-tuned.
(Nothing is wrong, just imperfect!)
Note
that the blinking text designates things that I need to work on; the material
is not wrong, but can be improved.
(Don't
worry, I don't like blinking text, either, so there will not be any in
the finished product!)
LEARNING MODULE
VI
SURVEY OF PROGRAMMING
LANGUAGES
THAT ARE ASSOCIATED
WITH THE WEB
Computer languages are software (translators) that allow a developer to
program a computer system; The most common use of computer languages
is
to write
(1) programs. Numerous programming languages have been
developed to facilitate the translation of the developer's algorithms (procedures
for accomplishing tasks) into
(2) language programs that a computer
can execute. The following
over-simplified survey separates all
computer languages into three categories: low, high, and very-high, after
which it focuses primarily on examples used for Web applications, especially
markup languages, Java, and JavaScript. (For a little more general
survey of programmin languages check out my Learning
Module X, of COSC100, Introduction to Computers.) Independent
learners should read the objectives and sequence of presentations, summary,
then the
Study
Guide for this learning module.
The
Objectives of this learning module are:
-
to
survey the classifications of computer programming languages and focus
on those associated with Internet services,
-
to
survey the most popular programming languages used to develop Web sites,
-
to
define some of the basic software development concepts implemented in Java
and JavaScript, and
-
to
see how Java and JavaScript can easily be incorporated into Web pages via
"cut 'n paste".
TPQ
1: Rewrite the preceding objectives in terms of personal accomplishments
to be attained after finishing the study of this learning module.
The
sequence of presentations in this learning module is as follows.
You can click on any link to jump directly to that section.
1.
PROGRAMMING LANGUAGE LEVELS:
A programming language has two primary components (1) a set of built-in
language
primitives (commands, operations, classes, methods, procedures, functions,
etc.) that may be combined into programs and (2) a translator
(assembler,
compiler, and/or interpreter) that transforms source code (written
in the programming language) into object code (machine language
equivalent). There are three basic categories of programming languages:
(For a comparative examples of these see Comparison
of Language Levels in Learning Module X, of COSC100, Introduction to Computers.)
1.1 Low Level Languages
are "computer oriented":
-
Low Level Languages =
computer
oriented languages, i.e. they directly manipulate hardware.
-
Each language is unique to
the CPU on which it is implemented and is, therefore, not portable
(i.e.
not usable on a computer with a different CPU).
-
Each instruction corresponds
to a machine operation, part of the "instruction set" characteristic
of the (3).
-
There are two categories of
low level languages:
-
Machine Language (ML)
uses numeric codes (binary, octal, hex, etc.); non-binary code must be
translated into binary code, the only code that can be directly executable
by the computer. Writing machine language programs is so tedious, complex,
and error prone that it is now virtually never done.However, one must remember
that a computer can only execute machine code (i.e. "run" machine
language programs); therefore, ALL programs are ultimately translated
into machine code, after which they are executed.
-
Assembly Language (AL)
uses mnemonic
(abbreviated English words) instructions which have
a one-to-one correspondence with machine language instructions,
i.e. assembly language instructions correspond to specific operations of
the CPU. This one-to-one corresponds is what makes assembly language a
(4) (computer oriented) language.
Assemby language must be translated into ML by an assembler.
Assembly language, being machine oriented, is
faster and
more
efficient in the use of hardware than HLL or VHLL.
1.2 High-level Languages
(HLL) are "task oriented":
-
The words and grammar of HLL
are English-like. A HLL language is governed by a strict syntax
(usable words and set of grammatical rules); if this is standardized, the
language is portable (can be used on different computer systems).
The
majority of software development is done using HLL, and HLL development
is a core requirement in computer science degrees.
-
HLL programs reflect the logic
and procedures used in a human algorithm. Thus HLL programming is "task-oriented"
rather than "machine oriented"; the programmer is able to concentrate on
developing task algorithms rather than on how the computer will carry out
the instructions. However, the programmer must still specify a complete
set of detailed instructions, i.e. code that implements the task
(5).
-
HLL programs are translated
into ML by either compilers
or interpreters. Most HLL instructions
translate into multiple ML instructions.
-
Any HLL can be used to write
network
applications; however, some make that job much easier than others do.
The two most common ways of writing Web specific programs are:
-
using CGI (Common Gateway
Interface), a standard protocol (NOT a programming language) for running
external programs from a Web server. Such programs, called "CGI
applications" can be written in virtually any computer language
(the most suitable is probably Perl). However, the CGI approach
is being superceded by languages specifically designed for writing programs
to be run by Web browsers, e.g Java (See the next section.) and JavaScript
(See section 1.3.F section 3.)
-
using Java, a purely
object oriented, HLL designed to facilitate reliable, platform-independent,
distributed processing. It is a general purpose language
useful in writing any type of application; however, it has special capabilities
for writing object-oriented programs (covered in section
2.A) that run on networks. The most visible of these capabilities
are "applets" (special programs) that can be called directly
from within an HTML document. This makes it the "language of choice"
for most programmers of network applications. (See section
2.)
1.3 Very High-level Languages
(VHLL) are "human oriented":
VHLL are very new and are still evolutionary. Consequently
there is disagreement over terminology
at present. The following represent a very brief overview of current
concepts and terminology of a huge, diverse subject.
-
VHLL are similar to HLL except
they are more sophisticated and easier to learn and use because
many powerful primitives are built into the languages. One goal of VHLL
is to give nonprogrammers the ability to create simple computer applications.
-
The "power" and ease
of use of these languages arises from the fact that complex tasks can
be accomplished with a few simple commands. To do the same thing
using HLL would involve complex algorithm development for which only professional
programmers are trained. These VHLL commands require only that
the developer specify "what" tasks are to be performed, not the details
of "how" they are performed.
-
However, VHLL are "special
purpose languages", (often associated with specific software packages
like a DBMS or specific environments like the Web), and thus have have
limited range of application, within which they are very powerful. This
power, however, removes much control from the hands of the programmer.
Therefore, the power and ease of use of VHLL must be balanced by the sacrifices
in control over the processing details and access to computer hardware.
As long as the task fits the narrow capabilities of a VHLL, software development
proceeds quickly and smoothly.
-
There is little standardization
in
current VHLL (they are usually intimately associated to a particular type
of hardware or software). This results in a lack of portability
which
has restricted their current popularity. This, however, is changing rapidly.
-
Authoring systems are
VHLL designed to allow nonprogrammers to create Multimedia (text,
graphics, animation, audio, and video) applications. These have greater
potential for developing individualized learning system software.
-
Hypertext
Markup Language (HTML) was the original language used to create
Web pages; it has been updated via several versions. HTML
is really only a collection of (6)
which, when incerted into regular text, tell a Web browser how to format
text, incert multimedia, link to another location, or link to other programs
written in VRML, Java, JavaScript, or other languages (CGI applications).
(See section 2.B.)
-
Dynamic HTML (DHTML)
is an extension of HTML that facilitates the enhancement of animation
and interactivity of Web pages by providing scripting, cascading
style sheets, layering, dynamic fonts, etc. (See section
2.C.)
-
EXtensible
Markup Language (XML) a Web document formating language, is another
improvement on HTML. XML allows new tags to be defined by the developer
for new data types thus dramatically expanding the variety of information
that can be handled in a Web page. XML is "extensible" because, unlike
HTML, the ability to define new markup tags makes it virtually unlimited
and self-defining. (See section 2.D.)
-
Synchronized
Multimedia Integration Language (SMIL) is an upgrade of HTML that
facilitates the synchronization multimedia elements of a streaming Web
page enabling its audio, video and graphics elements to be coordinated.
(See
section
2.E.)
-
(3/19/00)WML
(Wireless Markup Language), part of the WAP protocol, is a subset of XML
specifically designed to program wireless devices so that they can display
the text portions of Web pages. WML (Wireless
Markup Language), formerly called HDML (Handheld Devices Markup Language),
is a language that allows the text portions of Web pages to be presented
on cellular phones and personal digital assistants
(PDAs) via wireless access.
WML is part of the Wireless Application Protocol (WAP)
that is being proposed by several vendors to standards bodies. The Wireless
Application Protocol works on top of standard data link protocols, such
as GSM, CDMA, and TDMA,
and provides a complete set of network communication programs comparable
to and supportive of the Internet set of protocols.
-
WML is an open language offered royalty-free. Specifications
are available at Phone.com's Web site. According to Phone.com, any programmer
with working knowledge of HTML, CGI
scripts, and SQL queries should be able to write
a presentation layer using WML. A filter program
can be written or may be available from a vendor that will translate HTML
pages into WML pages.
-
Virtual Reality Modeling Language
(VRML) is used to create Web pages with computer generated 3D
environments that can be "explored" as if they are the real world.
This promotes a highly interactive human-computer interface.
-
VRML allows the developer to
describe, in program code, three-dimensional (3D) image sequences and
define user interactions with them. Using VRML, you can build a sequence
of visual images into Web settings with which a user can interact by viewing,
moving, rotating, and otherwise interacting with an apparently 3D environment.
For example, you can view a room and use controls to move through the room
as you would experience it if you were walking through it in real space.
-
VRML programs can be "plugged
into" HTML programs.
-
To view a VRML file, you need
a
VRML viewer or a browser _______(7), which can be downloaded
and installed in the browser. Examples include
Silicon
Graphics' Cosmo Player, WebFX, WorldView, and Fountain for the Windows
95 platform. Whurlwind and Voyager are two viewers for the Mac.
-
See the informative article,
VRML
Brings 3-D Worlds To the Web, from PC Magazine at:
http://www.zdnet.com/pcmag/pctech/content/16/14/ir1614.001.html
-
Twenty clarifying questions
(with answers) can be found at:
http://webbuilder.netscape.com/Authoring/Vrml/ss12.html
-
Other web sites, recommended
by Yahoo, dealing with VRML are:
-
Scripting languages are
designed to help nonprogrammers customize applications or create simple
applications, e.g. to "liven up" Web pages. In general, scripting
languages are easier use than high level languages and are ideal for small
programs of limited capability or that can reuse and tie together existing
high level language programs. The most popular scripting languages include
the following
-
JavaScript is VHLL that
is a simplified version of Java specifically designed to add dynamic quality
to Web pages. (See section 4,
below.)
-
REBOL
(Relative Expression-Based Object Language) is a new approach
to Web scripting that introduces the idea of a messaging
language, one that "provides highly-integrated connectivity (networking)
along with context sensitivity (called "dialecting", the ability
to create variations, or sub-languages, for domain-specific communication.)".
It provides a broad range of approaches to the common challenges of Internet
computing. While designed to be simple and productive for novices,
the language extends a new dimension of powerful, practical solutions that
facilitate advanced Web development. Specifically, the languageoffers
a significant new approach to the seamless exchange and interpretation
of network-based information over a wide variety of computing platforms.
A message can be as simple as a single line or as complex as an entire
application.
(REBOL's
creator on ZDTV, 8 min.) For more information on REBOL, see
the home page of the language at: http://www.rebol.com/
-
Python
is simple, high-level
interpreted language that combines ideas from ABC, C, Modula-3, and Icon.
It bridges the gap between C and shell programming, making it suitable
for rapid prototyping and Web scripting. It is object-oriented and supports
packages, modules, classes, user-defined exceptions, a good C interface,
dynamic loading of C modules and has no arbitrary restrictions. (This
is ZDTV's Leo LaPorte's favorite learning language for beginning programmers.)
-
Tcl
(Tool
Command
Language)
is a powerful, extensible, interpreted string processing
language for issuing commands to interactive programs. The
extensibility of Tcl means that it can be easily extended through the addition
of custom Tcl libraries. It is used for prototyping applications as well
as for developing CGI scripts. It has a peculiar but simple syntax.
It may be used as an embedded interpreter in application programs. Tcl
has an associated GUI toolkit, Tk, so it is sometimes referred to as Tcl/Tk.
-
Visual Basic and VBScript
are
are a language duo from Microsoft that rival JavaScript.
-
Visual Basic is specifically
designed to quicly and easily develop code that provides interaction between
different Microsoft applications, e.g. Word and Access or Internet Explorer.
It is actually more of a "programming environment" in which a graphical
user interface is utilized to select and modify "library code" previously
written in the BASIC programming language.
-
VBScript is an interpreted
script language that is a subset of its Visual Basic programming language.
-
ASP
(Active Server Page) is not a programming language, but is called, by Microsoft,
"a server-side scripting environment." To create ASP scripts developers
typically use the languages VBScript or JScript, both of which are automatically
supported by ASP. ASP and HTML are tightly integrated. In HTML,
(8) are delimited with brackets; similarly in ASP one uses the <%
%> delimiters to define the beginning and end of a script. ASP scripts
can be incerted anywhere in an HTML page, and visa versa. One of major
assets of ASP is that it facilitates access to SQL databases. For
a nice, introductory tutorial on ASP, access the CNET site,
http://www.builder.com/Programming/ASPIntro/?dd.cn.txt.0701.10
SAQ
1: (a) What is the difference between (1) low level languages on the one
hand and (2) high level and very high level languages on the other?
(b) What is the primary difference between high level and very high level
languages?
SAQ
2: What is the difference between (1) HTML, DHTML, and XML on the one hand
and (2) VRML on the other?
SAQ
3: (a) Which type of language (low level, high level, or very high level)
is most often associated with Web development? (b) Why?
2.
MARKUP LANGUAGES:
Markup
languages are
VHLL
authoring systems that allow developers to "mark up" text with tags
that format it, incorporate multimedia into it and create
hyperlinks
in it. The most commonly known example is HTML, in which this learning
module is written, but it is being superceded by newer more sophisticated
languages.
-
Standard
General Markup Language (SGML) is a generic markup language for
representing documents.. It is not a language itself but a "metalanguage"
that specifies how a markup language like HTML, DHTML, XML, etc. will work.
It is used to specify the tag set of the markup language
as well as it's syntax.
-
The foundation
of SGML is the idea that a document has a format and components which
can be specified independently of how that document will be displayed,
for example, by a
(9). When
displayed, the actual appearance of such a document will depend on the
output device and style preferences.
-
A document
written in a SGML-based language uses
a Document Type Definition (DTD) file that specifies the
(10), embedded within it.
-
Because
SGML is an international (ISO) standard, based on simple
ASCII text, that is platform-independent, portable to all types
of hardware, and adaptable to various I/O formats, it has the follownig
advantages:
-
(11). Document
design is independent of display devices and application programs, so a
document can be created by considering its inherent format
without
worrying about how it will appear when displayed. Therefore, display
devices and application programs can be changed knowing that these documents
can always be displayed, and that they will retain their basic format and
structure. Also, organizationscan confidently write their documents
in SGML-based languages and store their output without being limited to
a specific vendor.
-
(12). Documents
can be accessed from different computer environment because the document
type definition (DTD), is independent of both the hardware on which the
documents are displayed and the software from which they are accessed.
-
(13). The
separation of content from its presentation allows fordifferentoutput formats
like HTML, text, CD-ROM, etc. Text can beeasily be adapted
for the type of display device, e.g. the computer monitor, or TV.
-
(14). SGML is a core data standard
that enables SGML-aware applications to interact
and share data seamlessly.
-
Hypertext
Markup Language (HTML) is the VHLL that is currently used to
create
(15). It is based on SGML, i.e. HTML implements, with its
tags and syntax, the specifications defined in SGML.
-
HTML itself is the set of
customizable "markup" tags that are inserted into HTML document govern
its format, multimedia content, and hyperlinks. Such documents can
be displayed by any HTML viewer but they are normally viewed using a Web
browser.
-
HTML is a programming language
in that an HTML document is a program that, when "run" by a browser,
displays its text as hypermedia (multimedia with hyperlinks).
-
The "language" HTML is really
only a collection of predefined tags which, when incerted into regular
text, tell a Web browser how to:
-
format the document and
its text,
-
incorporate
(16),
i.e. incert a graphic image, video sequence, or sound clip into the displayed
document,
-
link to other locations,
in the same document, in another Web page, or even on another computer
(server), or
-
link to other programs
written in VRML, Java, JavaScript, or other languages (called CGI applications).
-
Raggett's 10 Minute Guide
to HTML, found at http://www.w3.org/MarkUp/Guide/
is the introduction provided by HTML's official sponsor the World Wide
Web Consortium (WC3). This nice little
guide and its extension, Adding
a touch of style, is considered part of this Learning module, so if
you have not read it during the lab sessions, be sure to do so now. It's
content is on preassessments as well as assessments.
-
More information:
-
Twenty clarifying questions
on HTML (with answers) can be found at:
http://webbuilder.netscape.com/Authoring/Html40/?st.bl.advtech..html4
-
An excellent starting point
for further information on HTML is
CNET's Spotlight on HTML at
http://home.cnet.com/category/0-3880.html.
SAQ
4: (a) What is the purpose of the <a> and <p> tags in HTML?
(b) What tags normally begin and end each HTML document?
-
Dynamic
HTML (DHTML) is a collective term for a combination of new HTML
tags and options, style sheets, and programming that will let you create
Web pages more animated and interactive than standard HTML. Simple
examples of DHTML pages would include (1) having
the color of a text heading change when a user passes a mouse over it or
(2) allowing a user to "drag and drop" an image from one page to another.
DHTML is supposedly a simpler way of adding animation and interactivity
to Web pages than Java and JavaScript, the popular way to do this now.
(From
W3C Stylesheet page, http://www.w3.org/Style/:
Dynamic HTML is a term used to describe HTML pages with dynamic content.
CSS is one of three components in dynamic HTML; the other two are HTML
itself and JavaScript (which is being standardized under the name EcmaScript).
The three components are glued together with DOM, the Document Object Model.
Dynamic HTML is still in its infancy and current implementations are experimental.
) Some of the more important capabilities of
DHTML include:
-
a scripted,
object-oriented view of a Web page and its elements. For example,
each heading on a page can treated as a distinct object, i.e. it
can be named, given attributes of text style and color. More importantly,
such objects can be addressed, by name, in "scripts" (small
progams) placed within the DHTML. These scripted objects can change as
the result of a specified event (e.g. a mouse passing over it or being
clicked or a time interval elapsing). Also, an image object can be
dragged and dropped from one page location to another.
-
cascading style sheets
allows the developer to specify different style sheets
or style statements with predefined levels of precedence within a page
or group of related pages. The style can be scripted to change as a result
of user interaction causing the appearance of the Web page to change.
"Cascading" means that a page can have multiple layers of style sheets
(e.g. a style sheet within a style sheet within a style sheet, etc.). A
new style sheet may vary one or more objects in the style sheet above it.
-
layering allows existing
content objects to be replaced by or superimpose with new content. Layers
can be programmed to appear as part of a timed presentation or as the result
of user interaction.
-
Dynamic fonts, a feature
introduced in Netscape Communicator, allows Web page designers to include
font files containing specific font styles, sizes, and colors as part of
a Web page and to have these fonts downloaded with the page. Therefore,
font choice is no longer dependent on the browser itself.
For more information on DHTML,
See the informative article, DHTML, More Client, Less Server, from
PC Magazine at:
http://www.zdnet.com/pcmag/issues/1613/pcmg0066.htm
-
Extensible
Markup Language (XML), a platform-independent Web document formatting
language, is another improvement on HTML. XML is "extensible" because,
unlike HTML, the ability to define new markup tags makes it virtually unlimited
and self-defining. XML allows the developer to define new tags
specifically for new data types thus dramatically expanding the variety
of customized data that can be handled in a Web page.
In fact, it has been said that "XML is to data what HTML is to
text", but since text is a specific form of data, XML is a more general
markup language than HTML. (It
may compete with DHTML to be the successor of HTML, or it may, at least
in the near future, be used in conjunction with DHTML to complement HTML
in Web applications.)
-
Instead
of using only predefined tags (like HTML does) to format a page and insert
MIME files in it, XML allows tags to be defined by the developer
of the XML document. Thus, tags for virtually any data type (e.g. product,
quantity, and price) can be used for specific applications (like an online
shopping site), allowing Web pages to function like database management
systems.
-
XML is
a subset of SGML (See section A, above.) whereas HTML is a document type
of SGML.
-
XML is
(17) because, unlike HTML, the markup symbols are unlimited
and self-defining.
-
XML is
being supported
by the United Nations as a premier standard for e-business.
-
More information:
-
An excellent
introduction
to XML can be found in the ACM student magazine Crossroads.
-
For focused
questions and answers on essential XML concepts see:
http://webbuilder.netscape.com/Authoring/Xml20/?st.bl.advtech..xml20
-
For an
introduction to XML try the informative article from SunWorld at:
http://www.sunworld.com/swol-06-1999/swol-06-itarchitect.html?0615a
-
SMIL
(Synchronized
Multimedia Integration Language), pronounced "smile", was first released
in the Fall, 1997. It is designed to facilitate the definition
of and synchronization of streaming
multimedia elements (video, sound, still images). Using HTML,
each multimedia element on the Web page is distinct so complex programming
is necessary to coordinate them. SMIL makes it possible to separately
transmit multiple video, image and sound files but coordinate their association
on a Web page. Each multimedia object is identified with a unique
(URL) thus allowing their coordination and reuse.
-
SMIL tagss
are similar to those those of HTML so the language can be used
anywhere that HTML is used. A presentation can be described
using only three XML elements.
-
SMIL
supports multimedia streaming protocols such as RTSP.
-
SMIL also
lets the "producer" store a multimedia object in multiple "versions",
each with a different size so that a smaller version can be transmitted
to users who have low bandwidth channels. The
bandwidth of the user can be determined and the version most appropriate
for that is automatically transmitted using a switch statement. SMIL
also makes it possible to have multiple language versions of soundtracks
on a Web page.
SAQ
5: What is the difference between (a) SGML and the other languages listed
above, (b) HTML and DHTML, (c) HTML and XML,
and (d) HTML and SMIL?
3.
JAVA, THE CURRENT "RAGE" IN SOFTWARE DEVELOPMENT (ESPECIALLY FOR THE INTERNET):
(See the excellent PC Magazine article,
Java
Programming for the Web.)
(Unfortunately, an important illustraction,
"Figure 1" is omitted in this article. You can view
Fig.
SPL-3 which is similar.)
Java
is a high-level, general purpose, platform independent, purely object-oriented
programming language that is designed for efficient software development
for a distributed (networked) computer environment.
It was created
at Sun Microsystems to develop advanced software for consumer electronics.
C++ was originally chosen for this project, but the code often required
extensive debugging and was difficult to maintain. Realizing that a completely
new language was needed, the development team started with C++ but removed
many of its problematic and seldom-used features and added primitives for
distributed computing and other modern features. The result was Java,
familiar
(because of its syntactic similarities to C++) and
simple (at least
when compared to C++!). Because of its special capabilities
for network programming, it has become,
since about 1995, "the" development language for Internet and intranet
applications.
-
Java
is
object-oriented, which means that, software developers think
in terms of "objects" which have a "state" (definded by its
"attributes") and "behavior"( defined by its "methods").
For example, consider a window on a computer screen; its attributes would
include its location, its size, whether or not it scrolls, etc and some
of its methods would would be subprograms that define its abililty to be
opened or closed, moved, resized, etc. In other words object-oriented
programing (OOP) is a human-oriented view of programming rather than a
computer-oriented view. Characteristic of OOP include:
-
Similar
objects can take advantage of being part of the same "class" of
objects. A class is an abstract "template" for creating objects,
but an object is an "instance" of a class. For example the
idea of a computer window would be a class, but the actual window which
contains the text you are reading is an "instance" of the class window.
Each instance of the class window would have different values of
(18) (location, size, etc.) but all would share the same
(19) (movable, resizeable, etc.)
-
Perhaps
the greatest asset of OOP is its built-in facilities for reusing code,
making software development more efficient. This can be accomplished
three basic ways:
-
Classes
can
inherit the code (attributes and/or methods) from a parent class
(or superclass). Inheritance is used to "derive a subclass from
a superclass", i.e. the subclass inherits the attributes and methods
of the superclass and new attributes and methods can be added thus distinguishing
the subclass. Thus the subclass is a special case of the superclass
and one can describe inheritance as an "IsA" relationship between
classes, e.g. a the Car class
could be a subclass of a (20)
class or a "car IsA (20)".
-
Classes
can contain other classes, i.e. incorporate code already written
for other classes. Containership (the proper word is "aggregation")
is called a "HasA" relationship between the classes, the Car
class
would be defined with an engine as an (21),
but if Engine were a class
itself, one would say that the Car
class HasA Engine class, i.e.
the Engine class is contained
within the Car class.
-
Methods
within a class can make use of other classes as well. This is
called the
"UsesA" relationship between classes. For example
a method called "drive" of
the Car class might be written
using the class SteeringWheel (must
be one word), in which case one would say the Car
class UsesA SteeringWheel
class.
-
The methods
of a class are "mini-programs" that define the class's behaviors, one method
for each behavior. The logic of method can be completely defined using
only three control structures: (They
are called "control" structures because they are used to control the flow
of execution of the method.) They are:
-
sequence,
the default execution is one instruction after another unless modified
by selection or repetition constructs,
-
selection
(IF-THE-ELSE; also called IF-ELSE) allows a logical expression to select
one of two alternative blocks of code to execute,
-
repetition
(WHILE, or FOR loops or recursion) allows a logical expression
to govern the repetition of a block of code.
Note that,
although sturctured control structures are essential to OOP languages,
there are languages that use the same sturctures (e.g. C, Pascal, etc.)
but which are not OOP languages, i.e. they do not have the features of
section A.b, above.
-
Objects
are thought of as "nouns" that a user might relate to rather than the traditional
procedural "verbs" which are used as method names.
-
The language is unusual among
programming languages in that it is designed to facilitate the creation
of two types of software, "applications", "applets", and "servlets".
-
Applications are stand-alone
programs in the traditional sense but are based purely on object oriented
technology.
-
Applets are a unique
innovation of Java. They are "miniature applications" that are
specifically
designed to be called from within HTML documents.
-
They must be downloaded from
a server in order to be executed on a client. (See
Figure
SPL-1.) However they are never stored on the client
and are nomrally prevented from accessing files on the client,
although this restriction is being relaxed in new versions of Java.
-
Applets
are
typically used to add animations or user interactiviey to a Web page.
-
Servlets are an even
newer concept unique to Java. Servlets also "miniprograms" but, unlike
applets, they are not downloaded in order to be executed on a client; instead,
servlets are executed on the server and, if necessary, its output
is downloaded to a client.
-
Java’s most innovative features
are its facilities for distributed computing. These include:
-
(22) (described above)
-
unique set of Internet/intranet
primitives from which programs can be constructed, e.g. class libraries
(reusable subprograms) for TCP/IP protocols. Java code can access objects
(other programs) across the Internet/intranet via URLs as easily as on
a local file system. Java 1.1 and higher also has built-in ability
to access objects on remote computers.
-
built in facilities for handling
security problems inherent in distributed systems. This makes it easier
to develop
reliable, virus-free, tamper-free systems. The
reliability goal means it was designed to be secure (hacker resistant)
and robust (bug resistant). Being robust ensures
that a Java instruction can not contain the address of data storage in
another program or in the operating system itself, because errors in such
instructions will cause the program (or even the operating system itself)
to "crash." The Java virtual machine makes a number of checks on
each object to ensure integrity.
-
Java is designed to be run on
the "Java Virtual Machine" (JVM), an "abstract computer architecture"
that is modelled in the Java programming environment. The Java compiler
translates the Java source code (files with a .java
extension)into architecture-neutral bytecode (files
with a .class
extension).
(See
Figure
SPL-3.)
Bytecode (a sequence of
8 bit codes) can be executed by a Java interpreter or just in time compiler
(JIT) to deliver output to the user. This implements a "three-tier
client server architecture" where the
(23) is the middleware level between source code and object
code, i.e. the Java source code is compiled into
(23) that is, in turn, automatically translated, when
it is downloaded, into the (24)
code of the particular CPU.
-
bytecode is designed
to be both easy to interpret on any machine and easily translated (by a
JIT) into native machine code at load time.
-
Since the software developer
need write only one source code program, this gives Java applications their
"platform independence". (This means tha a Java program does not
depend on the
nor (25)
so a program will run on any computer system that has a (26).
Java
bytecode can be run anywhere in a network on any server or any client that
has a Java virtual machine.)
This is the origin of Sun Microsystem’s Java Slogan:
Write Once,
run anywhere!
which has been expanded, with the advent of the Java component model, Java
Beans, to read:
Write Once, run anywhere,
reuse everywhere!
On Wednesday, Nov. 18, 1998,
Sun won a stunning court decision against Microsoft requiring that Microsoft
stop its efforts to "pollute" Java in order to destroy its platform independence!
"It's an unqualified victory for Sun," said Rich Gray, a partner at Bergeson,
Eliopoulos, Grady & Gray in San Jose, California. (Mr. Gray is not
retained by either side.) "This decision gives complete credence to the
government's theory that Microsoft has engaged in anticompetitive activities
to undercut Java, the most important cross-platform technology." Details
can be found here.
A related story can be found on Microsoft's
War on Java.
-
Java is the heart of the revolutionary
NC (network computer); See Figure SPL/3.
-
For more information on Java
see the following:
-
The home
of Java is at Sun Microsystems' Java page, http://java.sun.com/.
-
An incredible
source of links to Java sites, applets you can download, tutorials on Java,
etc is Gamelan at http://www.gamelan.com/.
-
Excellent
introductory tutorials on Java are found on IBM's Web site at http://www.ibm.com/java/education/intro/courseoptions.htm
-
EXAMPLES:
-
The following news ticker from
7@m
News on the Net can be added to a Web page by accessing:
http://www.7am.com/
You can find the code responsible
for calling and displaying the output of this applet by selecting Page
Source From the View menu in Navigator. The code is:
<applet
CODE="sevenAMNewsTicker.class" CODEBASE="http://www.7am.com/java" WIDTH=450
HEIGHT=15>
<br><param NAME="channels"
VALUE="+WORLDnews +CHRISTIANnews +USAnews +SPORTSnews">
<br><param NAME="target"
VALUE="_blank">
<br></applet></ol>
It might be easier to
distinguish in a page by itself; click here.
-
SAQ
6: What is the difference between (a) objects and classes, (b) attributes
and methods, and (c) inheritance and aggregation?
SAQ
7: What is the difference between Java (a) applications (b) applets, and
(c) servlets?
SAQ
8: What is the difference between bytecode and object code?
4. JAVASCRIPT,
A VHLL COMPLIMENT TO JAVA: (See handout, "Spotlight on JavaScript."):
-
JavaScript is a cross-platform,
object-based
scripting language for both client and server applications.
-
JavaScript
is desinged to be embedded directly in HTML. It allows you to create dynamic,
interactive Web-based applications that run completely within a Web
browser;
you don't have to write any programs
that run on the Web server, like you must do with CGI scripts, or must
be downloaded fromt the server like Java (27).
JavaScript
can be embedded in an HTML document four different ways:
-
as statements and functions
written within the HTML <SCRIPT> tag,
-
by specifying a file as the
JavaScript source,
-
by specifying a JavaScript expression
as the value of an HTML attribute, and
-
as event handlers within certain
other HTML tags (mostly form elements)
-
JavaScript is not a "native"
feature of the Java environment, i.e. it was not developed by Sun or any
standards organization as part of or an extension of Java itself.
The origin of JavaScript was "LiveScript", a scripting language,
developed by Netscape, for writing scripts that could be inserted directly
into HTML code in order to add functionality to Web pages. However, Netscape
renamed Livescript as "JavaScript", and, in cooperation with Sun, Netscape
is integrating JavaScript into the Java environment as THE scripting language
of HTML.
-
JavaScript is a "work in
progress". The latest version of the language, JavaScript 1.2,
is supported by Netscape Navigator 4 and Internet Explorer 4.
The first standard version (JavaScript 1.1) was named ECMAScript.
The new features of JavaScript 1.2 are likely to be embodied in a later
ECMAScript standard release
-
JavaScript is object-based
because it has very limited OOP features. It provides built-in objects
but it does not have the capability to define new classes, and it has limited
inheritance (via the prototype mechanism). However, being a "work-in-progress",
it might have such features incorporated later.
-
The syntax of JavaScrip is identical
to that of Java for features that are common to the two lanaguages.
However, JavaScript and Java are fundamentally different! (See the
handout,JavaScript Overview.)
-
Visual JavaScript, written
entirely in Java, is a new visual IDE (integrated development environment)
tool that lets a company's software developers rapidly build Crossware
applications (applications that run across Intranets and Extranets) without
writing software code.
-
JavaScript
is a simpler than Java and is used
for different purposes. It can only be
embedded directly in
(28),
so can not run as a stand alone application like Java programs can.
On the other hand, it is more flexible and easier to use for simple tasks
like animation. However, although you can write reasonably robust and complete
Web applications using JavaScript alone, JavaScript is not a substitute
for Java. In fact,
JavaScript is a good client-side complement to Java;
using the two together allows you to create more complex applications than
are possible with JavaScript alone.
-
EXAMPLES:
-
For two illustrative examples
of JavaScript click here. You
can see the JavaScript by selecting Page Source
from the View menu.
-
Another "fun JavaScript", found
by a student, Clint Malone, can be found here.
-
JavaScript, Java, HTML/DHTML
complement (or should complement) each other. See the article, by
the "ScriptBoy", Danny Goodman called Java
vs. JavaScript -- The Impact of Dynamic HTML. A provocative
article on the importance of using learning JavaScript, learn
JavaScirpt...now! by Dan Shafer is also worth reading.
-
Other Web sites concerning JavaScript
include:
-
C|NET's Web development site,
Builder.com found at: http://builder.cnet.com/Programming/JsSpotlight/?st.bl.pr.pr4.feat.1245.
-
An introductory tutorial on
JavaScript, by C|NET, can be accessed at http://builder.cnet.com/Programming/Javascript/?st.bl.prog.feat.
SAQ
9: What is the difference between Java and JavaScript?
SAQ
10: In Web development, what is the purpose of Java and JavaScript?
5.
SUMMARY:
-
In general, programming languages
are software development environments that consist of (1) a set of
language
primatives (keywords and specified syntax) and (2) a translator
(assembler, compiler, or interpreter) that converts source code
(written in with programming language primatives) into object code
(binary machine language). Programming languages are classified in
three categories:
-
Low level languages,
which are computer oriented, are used to create programs that have
a one-to-one correspondence between their statements and the machine language
statements based on the instruction set of the CPU. Low level language
programs make efficient use of the CPU and memory, but, because they are
tedious and difficult to write correctly, are inefficient from the standpoint
of developer time and effort.
-
machine language which
are numeric, and
-
assembly language which
utilizes mnemonic keywords. Assembly language programs are translated
into object code by assemblers.
Low level languages are not
useful in Internet applications, particularly Web site development.
-
High level languages (HLL),
which are task oriented, facilitate the coding of algorithms.
These languages are the primary tools of computer scientists and
are therefore a key component of Computer Science curricula. HLL
are mainly used in Web development as CGI applications or, in the case
of Java, for writting applets.
-
Very high level languages
(VHLL), which are human oriented, are designed to allow
non-programmers develop customized software. They are very powerful
within the limited domain of their application. There is a
wide range categories of VHLL but the two most useful in Web development
are:
-
Authoring languages
like markup languages (HTML, DHTML, XML) and modelling languages (VRML)
are use to create Web pages and other hypermedia documents.
-
Scripting languages like
JavaScript are used to write miniture programs that can be included within
Web pages providing animation and interactivity.
-
Markup languages are
VHLL used to create documents that are hypermedia when viewed by
a compatible viewer such as a browser. They are called "markup" languages
because they consist of ''tags" that are inserted to pure ASCII text in
order to format it and create hyperlinks.
-
SGML is the metalanguage
which defines the characteristics of all the following markup languages.
-
HTML was the original
Web development languages. It has evolved through several versions
and will probably be superceded by the following languages.
-
DHTML, which stands for
DYNAMIC HTML, adds animation, interactivity, and other user-friendly features
to HTML.
-
XML is an extensible
markup language that allows developers to define their own tags thus making
it possible to specify an unlimited variety of user defined data types.
-
Java is a general purpose,
platform independent, purely object-oriented HLL that has primatives
for distributed computing and other modern facilities.
-
Object oriented languages
are
based on reusable, abstract templates called classes; they normally
contain attributes which specify the state of an object and methods
which define the behavior of that object.
-
To create actual objects,
the abstract classes are instantiated by giving specific values to its
attributes. Such objects are more accurately called "instances"
of the class.
-
The following three fundamental
object-oriented relationships between different classes facilitate
reuability of code.
-
Inheritance implements
the "IsA" relationship between a parent class and a child class;
the child inherits the non-private attributes and methods of the parent.
-
Aggregation implements
the "HasA" relationship where a class that contains another class
as the type of one or more of its attributes, i.e. the container class
has an attribute defined by another class.
-
Dependency implements
the "UseA" relationship when a method contains other classes for
its parameters, local variables, or return type of the method.
-
Java programs can be standard,
stand-alone applications or applets, a unique new way of
allowing clients (e.g. a browser) to download and run these miniprograms"
and have their output displayed witin the client output (e.g. the applet
output will appear in the Web page itself). Servlets are an
even newer concept where the miniprogram is not downloaded; instead, it
is executed on the server and, if necessary, its output is downloaded to
a client.
-
JavaScript is a VHLL
scripting compliment to Java which has the same language syntax; however,
it does not have the object-oriented facility of inheritance, so it is
called an "object-based" language rather than an "object-oriented"
language. Also, unlike Java, JavaScript programs, called "scripts",
are coded directly within an HTML document or within a document
written with another markup language.