Вы находитесь на странице: 1из 12

Programming Language

I. Introduction

Programming language, in computer science, are the artificial languages used to


write a sequence of instructions (a computer program) that can be run by a computer.
Similar to natural languages, such as English, programming languages have a
vocabulary, grammar, and syntax. However, natural languages are not suited for
programming computers because they are ambiguous, meaning that their vocabulary
and grammatical structure may be interpreted in multiple ways. The languages used to
program computers must have simple logical structures, and the rules for their
grammar, spelling and punctuation must be precise.
Programming languages vary greatly in their sophistication and in their degree of
versatility. Some programming languages are written to address a particular kind of
computing problem or for use on a particular model of computer system. For instance,
programming languages such as FORTRAN and COBOL were written to sole certain
general types of programming problems —FORTRAN for scientific applications, and
COBOL for business applications. Although these languages were designed to address
specific categories of computer problems, they are highly portable, meaning that they
may be used to program many types of computers. Other languages, such as machine
languages, are designed to be used by one specific model of computer system, or even
by one specific computer in certain research applications. The most commonly used
programming languages are highly portable and can be used to effectively solve
diverse types of computing problems. Languages like C, PASCAL, and BASIC fall
into this category.

II. .Language Types

Programming languages can be classified as either low-level languages or high-


level languages. Low-level programming languages, or machine languages, are the
most basic type of programming languages and can be understood directly by a
computer. High-level languages are programming languages that must first be
translated into a machine language before they can be understood and processed by a
computer. Examples of high-level languages are C, C++, PASCAL, and FROTRAN.
Assembly languages are intermediate languages that are very close to machine
languages and do not have the level of linguistic sophistication exhibited by other
high-level languages, but must still be translated into machine language.
1. Machine Languages

In machine languages, instructions are written as sequences of 1s and 0s, called


bits, that a computer can understand directly. An instruction in machine language
generally tells the computer four things: (1) where to find one or two numbers or
simple pieces of data in the main computer memory (Random Access Memory, or
RAM), (2) a simple operation to perform, such as adding the two number together, (3)
where in the main memory to put the result of this simple operation, and (4) where to
find the next instruction to perform. While all executable programs are eventually
read by the computer in machine language, they are not all programmed in machine
language. It is extremely difficult to program directly in machine language because
the instructions are sequences of 1s and 0s. A typical instruction in a machine
language might read 10010 1100 1011 and mean add the contents of storage register A
to the contents of storage register B.
2 .High-Level Languages

High-Level languages are relatively sophisticated sets of statements utilizing


words and syntax from human language. They are more similar to normal human
language than assembly or machine languages and are therefore easier to use for
writing complicated programs. These programming languages allow larger and more
complicated programs to be developed faster. However, high-lever languages must be
translated into machine language by another program called a compiler before a
computer can understand them. For this reason, programs written in a high-level
language may take longer to execute and use up more memory than programs written
in an assembly language.

3. Assembly Languages

Computer programmers use assembly languages to make machine language


programs easier to write. In an assembly language, each statement corresponds
roughly to one machine language instruction. An assembly language statement is
composed with the aid of easy-to-remember commands. The command to add the
contents of storage register A to the contents of storage register B might be written
ADD B,A in a typical assembly language statement. Assembly languages share
certain features with machine languages. For instance, it is possible to manipulate
specific bits in both assembly and machine languages. Programmers use assembly
languages when it is important to minimize the time it takes to run a program, because
the translation from assembly language to machine language is relatively simple.
Assembly languages are also used when some part of the computer has to be
controlled directly, such as individual dots on a monitor or the flow of individual
characters to a printer.
III. Language structure and components

Programming languages use specific types of statements, or instructions, to


provide functional structure to the program. A statement in a program is a basic
sentence that expresses a simple idea —its purpose is to give the computer a basic
instruction. Statements define the types of data allowed, how data are to be
manipulated, and the ways that procedures and functions work. Programmers use
statements to manipulate common components of programming languages, such as
variables and macros (mini-programs within a program).
Statements known as data declarations give names and properties to elements of
a program called variables. Variables can be assigned different values within the
program. The properties variables can have are called types, and they include such
things as what possible values might be saved in the variables, how much numerical
accuracy is to be used in the values, and how one variable may represent a collection
of simpler values in an organized fashion, such as a table or array. In many
programming languages, a key data type is a pointer. Variables that are pointers do not
themselves have values; instead, they have information that the computer can use to

locate some other variable—that is, they point to another variable.

An expression is a piece of a statement that describes a series of computations to


be performed on some of the program’s variables, such as X+Y/Z, in which the
variables are X, Y, and Z and the computations are addition and division. An
assignment statement assigns a variable a value derived from some expression, while
conditional statements specify expressions to be tested and then used to select which
other statements should be executed next.

Procedure and function statements define certain blocks of code an procedures or


function that can then be returned to later in the program. These statements also
define the kinds of variables and parameters the programmer can choose and the type
of value that the code will return when an expression access the procedure or
function. Many programming languages also permit mini-translation programs called
macros. Macros translate segments of code that have been written in a language
structure translate segments of code that have been written in a language structure
defined by the programmer into statements that the programming language
understands.
IV. History

Programming languages date back almost to the invention of the digital


computer in the 1940s. The first assembly languages emerged in the late 1950s with
the introduction of commercial computers. The first procedural languages were
developed in the late 1950s to early 1960s: FORTRAN, created by John Backus, and
then COBOL, created by Grace Hopper. The first functional language was LISP,
written by John McCarthy in the late 1950s. Although heavily updated, all three
languages are still widely used today.
In the late 1960s, the first object-oriented languages, such as SIMULA, emerged.
Logic languages became well-known in the mid 1970s with the introduction of
PROLOG, a language used to program artificial intelligence software. During the
1970s, procedural languages continued to develop with ALGOL, BASIC, PASCAL,
C, and Ada . SMALLTALK was a highly influential object-oriented language that led
to the merging of object-oriented and procedural languages in C+ and more recently
in JAVA. Although pure logic languages have declined in popularity, variations have
become vitally important in the form of relational languages for modern database,
such as SQL.

Characteristics of Java
Java has become enormously popular. Java’s rapid rise and wide acceptance can
be traced to its design and programming features, particularly its promise that you can
write a program once and run it anywhere. As stated in the Java-language white paper
by Sun, Java is simple, object-oriented, distributed, interpreted, robust, secure,
architecture-neutral, portable, high-performance, multithreaded, and dynamic.

1. Java is Simple

No language is simple, but Java is a bit easier than the popular object-oriented
programming language C++, which was the dominant software-development
language before Java. Java is partially modeled on C++, but greatly simplified and
improved. For instance, pointers and multiple inheritance often make programming
complicated. Java replaces the multiple inheritance in C++ with a simple language
construct called an interface, and eliminates pointers.

Java uses automatic memory allocation and garbage collection, whereas C++
requires the programmer to allocate memory and collect garbage. Also, the number of
language constructs is small for such a powerful language. The clean syntax makes
Java programs easy to write and read .Some people refer to java as “C++--” because it
is like C++ but with more functionality and fewer negative aspects.

2. Java Is Object-Oriented

Java is inherently object-oriented. Although many object-oriented languages


began strictly as procedural languages, Java was designed form the start to be object-
oriented programming (OOP) is a popular programming approach that is replacing
traditional procedural programming techniques.
Software systems developed using procedural programming languages are based
on the paradigm of procedures. Object-oriented programming models the real world
in terms of objects. Everything in the world can be modeled as an object. A circle is
an object, a person is an object, and a Windows icon is an object. Even a loan can be
perceived as an object. A Java program is object-oriented because programming in
Java is centered on creating objects, manipulating objects, and making objects work
together.
One of the central issues in software development is how to reuse code. Object-
oriented programming provides great flexibility, modularity, clarity, and reusability
through encapsulation, inheritance, and polymorphism. For years, object-oriented
technology was perceived as elitist, requiring a substantial investment in training and
infrastructure. Java has helped object-oriented technology enter the mainstream of
computing. Its simple, clean syntax makes programs easy to write and read. Java
programs are quite expressive in terms of designing and developing applications.
3. Java Is distributed

Distributed computing involves several computers working together on a


network. Java is designed to make distributed computing easy. Since networking
capability is inherently integrated into Java, writing network programs is like sending
and receiving data to and from a file.
4. Java Is Interpreted

You need an interpreter to run Java programs. The programs are complied into
the Java Virtual Machine code called bytecode . The bytecode is machine-independent
and can run on any machine that has a Java interpreter, which is part of the Java
Virtual Machine (JVM).
Most compliers, including C++ compliers, translate programs in a high-level
language to machine code. The code can only run on the native machine. If you run
the program on other machines, it has to be recompiled on the native machine. For
instance, if you compile a C++ program in the Windows platform. With Java, you
compile the source code once , and the bytecode generated by a Java compiler can run
on any platform with a Java interpreter. The Java interpreter translates the bytecode
into the machine language of the target machine.
5. Java Is Robust

Robust means reliable. No programming language can ensure complete


reliability. Java puts a lot of emphasis on early checking for possible errors, because
Java compilers can detect many problems that would first show up at execution time
in other languages. Java has eliminated certain types of error-prone programming
constructs found in other languages. It does not support pointers, for example, thereby
eliminating the possibility of overwriting memory and corrupting data.

Java has a runtime exception-handling feature to provide programming support


for robustness. Java forces the programmer to write the code to deal with exceptions.
Java can catch and respond to an exceptional situation so that the program can
continue its normal execution and terminate gracefully when a runtime error occurs.
6. Java Is Secure

As an Internet programming language, Java is used in a networked and


distributed environment. If you download a Java applet (a special kind of program)
and run it on your computer, it will not damage your system because Java implements
several mechanisms to protect your system against harm caused by stray programs.
The security is based on the premise that nothing should be trusted.

7. Java Is Architecture-Neutral

Java is interpreted. This feature enables Java to be architecture-neutral, or to use


an alternative term, platform-independent. With a Java Virtual Machine (JVM), you
can write one program that will run on any platform.
Java’s initial success stemmed from its Web-programming capability. You can
run Java applets from a Web browser, but Java is for more than just writing Web
applets. You can also run standalone java applications directly from operating
systems, using a Java interpreter. Today, software vendors usually develop multiple
versions of the same product to run on different platforms. Using Java, developers
need to write only one version that can run on every platform.

8. Java is Portable

Because Java is architecture-neutral, Java programs are portable. They can be run
on any platform, without being recompiled. Moreover, there are no platform-specific
features in the Java language. In some languages, suck as Ada, the largest integer
varies on different platforms. But in Java, the range of the integer is the same on every
platform, as is the behavior of arithmetic. The fixed range of the numbers makes the
program portable.

The Java environment is portable to new hardware and operating systems. In


fact, the Java compiler itself is written in Java.

9. Java’s Performance

Java’s performance is sometimes criticized. The execution of the bytecode is


never as fast as it would be with a compiled language, such as C++. Because Java is
interpreted, the bytecode is not directly executed bye the system, but is run through
the interpreter. However, its speed is more than adequate form most interactive
applications, where the CPU is often idle, waiting for input or for data from other
sources.

CPU speed has increased dramatically in the past few years, and this trend will
continue. There are many ways to improve performance. Users of the earlier Sun Java
Virtual Machine certainly noticed that Java was slow. However, the new JVM is
significantly faster. The new JVM uses the technology known as just-in-time
compilation. It complies bytecode into native machine code, stores the native code,
and reinvokes the native code when its bytecode is executed. Sun recently developed
the Java HotSpot Performance Engine, which includes a compiler for optimizing the
frequently used code. The HotSpot Performance Engine can be plugged into a JVM to
dramatically boost its performance.

10. Java Is Multithreaded


Multithreading is a program’s capability to perform several tasks simultaneously.
For example, downloading a video file while playing the video would be considered
multithreaded programming is smoothly integrated in Java, whereas in other
languages you have to call procedures specific to the operating system to enable
multithreading.

Multithreading is particularly useful in graphical user interface (GUI) and


network programming. In GUI programming, there are many things going on at the
time. A user can listen to an audio recording while surfing a Web page. In network
programming, a server can serve multiple clients at the same time. Multithreading is a
necessity in multimedia and network programming.

11. Java Is Dynamic

Java was designed to adapt to an evolving environment. New class can be loaded
on the fly without recompilation there is no need for developers to create, and for
users to install, major new software versions. New features can be incorporated
transparently as needed.
Software Life Cycle
A fundamental concept in software engineering is the software life cycle.
Software, like many other products, goes through a cycle of repeating phases(see
Figure 5A-1).
Software is first developed by a group of developers/programmers. Usually, it is
in use for a while before modifications are necessary. Modification is often needed
due to errors found in the software, changes in the rules or laws, or changes in the
company itself. The software should be modified before further use. These two steps,
use and modify, continue until the software becomes obsolete. By “obsolete,” we
mean the software loses its validity because of inefficiency, obsolescence of language,
major changes in the company, or other factors. Some examples of software
developments that normally go through this cycle are student registration systems,
billing systems, and accounting systems.
START

Develop the System

Yes
Obsolete
?
No

Use the System

Modify the System

Stop

Figure 5A-1:System Life Cycle

The development process in the software life cycle involves four phases:
analysis, design, implementation, and testing. Figure 5A-2 shows these phases as part
of the development process.

System Development

Analysis Design Implementation Testing

Figure 5A-2: System Development Phases


The development process starts with the analysis phase, which shows what the
package should do. In this phase, the systems analyst defines requirements that
specify what the proposed system is to accomplish. The requirements are usually
stated in terms that the user understands. There are four steps in the analysis phase:
define the user, define the needs, define the requirements, and define the methods.

A software package may be designed for a generic user or a specific user. For
example, an accounting package may be created for use by any firm. On the other
hand, a customized banking package may be created for a specific bank. The user of
the package must be clearly defined.
After the user has been identified, the analyst clearly defines the needs. In this
step, the best answer comes from the user. The user, or the representative of the user,
clearly defines his/her expectations of the package.
Based on the needs of the user, the analyst can exactly define the requirements
for the system. For example, if a package is to print checks at the end of the month for
each employee, what level of security and accuracy should be implemented?
Finally, after the requirements are defined in clear terms, the analyst can choose
the appropriate methods to meet those requirements.

The design phase defines how the system will accomplish what was defined in
the analysis phase. In the design phase, the systems are determined, and the design of
the files and/or the databases is completed.
Today, the design phase users a very well-established principle called modularity.
The whole package is divided into small modules. Each module is designed and tested
and is linked to other modules through a main program.
The design phase uses several tools, the most common being a structure chart. A
structure chart shows how to break your package into logical steps; each step is a
separate module. The structure chart also shows the interaction between all the parts
(modules).
In the implementation phase, you create the actual programs.

This phase uses several tools to show the logical flow of the programs before the
actual writing of code. One tool, still popular, is the flowchart. A flowchart uses
standard graphical symbols to represent the logical flow of data through a module.
The second tool used by programmers is pseudocode. Pseudocode is part English
and part program logic that describes, in precise algorithmic detail, what the program
is to do. This requires defining the steps in sufficient detail so that conversion to a
computer program can be accomplished easily.
After production of a flowchart, pseudocode, or both, the programmer actually
writes the code in a language specific for the project. The choice of the language is
based on the efficiency of the language for that particular application.
Once the programs have been written, they must be tested. The testing phase can
be a very tedious and time-consuming part of program development. The
programmers are completely responsible for testing their programs. In large
development project, there are often specialists known as test engineers who are
responsible for testing the system as a whole——that is , for testing to make sure all
the programs work together.

These are two types of testing: black box and white box. Black box testing is
done by the system test engineer and the user. White box testing is the responsibility
of the programmer.
Black box testing gets its name from the concept of testing a program without
knowing what is inside it and without knowing how it works. In other words, the
program is like a black box that you can’t see into.
Simply stated, black box test plans are developed by looking only at the
requirements statement. This is why it is so important to have a good set of
requirements. The test engineer uses these requirements and his or her knowledge of
systems development and the user working environment to create a test plan. This
plan will then be used when the system is tested as a whole. You should ask to see
these test plans before you write you program.

Whereas black box testing assumes that nothing is known about the program,
white box testing assumes that you know everything about the program. In this case,
the program is like a glass house in which everything is visible.
White box testing is the responsibility of the programmer, who knows exactly
what is going on inside the program. You must make sure that every instruction and
every possible situation have been tested. That is not a simple task!
Experience will help a programmer design good test data, but one thing that she
can do from the start is to get in the habit of writing test plan. She should start her test
plan when she is in the design stage. As she builds her structure chart, she should ask
herself what situations, especially unusual situations, she needs to test for and make a
note them immediately. She may not remember an hour later.

When she is writing her flowcharts or pseudocode, she should review them with
an eye toward test cases and make notes of the cases she needs.

When it comes time to construct her test cases, she should review the notes and
organize them into logical sets. Except for very simple student programs, one set of
test data will not completely validate a program. For large-scale development project,
20, 30, or more test cases may need to be run to validate a program.
Finally, while she is testing, she will think of more test cases. Again, she should
write them down and incorporate them into her test plan. After her program is finished
and in production, she will need the test plans again when she modifies the program.

Вам также может понравиться