Introduction
Computer programs are collections of instructions that tell a computer how to interact with the user, interact with the computer hardware and process data. The first programmable computers required the programmers to write explicit instructions to directly manipulate the hardware of the computer. This "machine language" was very tedious to write by hand since even simple tasks such as printing some output on the screen require 10 or 20 machine language commands. Machine language is often referred to as a "low level language" since the code directly manipulates the hardware of the computer.
By contrast, higher level languages such as "C", C++, Pascal, Cobol, Fortran, ADA and Java are called "compiled languages". In a compiled language, the programmer writes more general instructions and a compiler (a special piece of software) automatically translates these high level instructions into machine language. The machine language is then executed by the computer. A large portion of software in use today is programmed in this fashion.
We can contrast compiled programming languages with interpreted programming languages. In an interpreted programming language, the statements that the programmer writes are interpreted as the program is running. This means they are translated into machine language on the fly and then execute as the program is running. Some popular interpreted languages include Basic, Visual Basic, Perl and shell scripting languages such as those found in the UNIX environment.
We can make another comparison between two different models of programming. In structured programming, blocks of programming statements (code) are executed one after another. Control statements change which blocks of code are executed next.
In object oriented programming, data are contained in objects and are accessed using special methods (blocks of code) specific to the type of object. There is no single "flow" of the program as objects can freely interact with one another by passing messages.
In this tutorial, we focus only on structured programming.
Program Structure
Virtually all structured programs share a similar overall structure:
Statements to establish the start of the program
Variable declaration
Program statements (blocks of code)
The following is a simple example of a program written in several different programming languages. We call this the "Hello World" example since all the program does is print "Hello World" on the computer screen.
Language
Example program
"C"
#include
void main() {
printf("Hello World");
}
C++
#include
int main()
{
cout
Pascal
program helloworld (output);
begin
writeln('Hello World');
end.
Oracle PL/SQL
CREATE OR REPLACE PROCEDURE helloworld AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello World');
END;
Java
class helloworld
{
public static void main (String args [])
{
System.out.println ("Hello World");
}
}
Perl
#!/usr/local/bin/perl -w
print "Hello World";
Basic
print "Hello World"
Tuesday, June 1, 2010
programming concepts
Posted by enny efafiqa at 7:46 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment