You are on page 1of 3

A program is a set of instructions, written in a sequence, that tells the comput er what to do.

A program may, for example, instruct the computer to request info rmation from the user, process the information, and display results to the user. Depending on the nature of the task to be done, a program may be simple or comp lex. The instructions are written using a programming language and are later con verted into machine language that can be processed by the computer. ====================================================================== There are many programming languages available today, each having its own streng ths and drawbacks. Some languages are designed to be fast with mathematical calc ulations. Others are designed to be readable by non-programmers. Still others ar e designed to work with databases. The developers can choose any programming lan guage that best suits the project they want to work on. # Common Programming Language Element Despite the differences in the rules for writing instructions among the various languages, all programming languages have the following elements in common: - Literals - Operators - Functions - Variables - Constans - Arrays - Conditional Operator - Branch (If Then statement) - Loops - Procedures - Arguments (Parameter) - File I/O ====================================================================== Each program instruction has syntax that specifies what keywords can be used, wh at combinations of words are meaningful, and what punctuation is necessary while writing the instruction. The syntax of an instruction may vary from one program ming language to another. A computer executes an instruction only if its syntax is correct. # Principles of Coding While writing a program, the programmer should write the source code in a way th at makes it easy to read, understand, and debug. This helps not only the origina l developer, who may have to go back to the code later to fix a bug, but also ot her developers who are enhancing a section of code they did not originally write . The source code can be made more understandable by using two techniques: 1. Comments can be used in the source code to explain what a particular section of code will do. This is useful for explaining those sections of code which are difficult to understand. 2. Whitespaces can be used to enhance the code format and make it more readable. A whitespace is created when you use tabs, spaces, or indents in the code. ====================================================================== Programming methodologies are the different approaches or sets of practices foll owed to write a program. The choice of a particular methodology depends on the n ature of the task to be done by the program, and the ease and efficiency with wh

Some of the advantages of using structured programming are: 1. each module can be checke d individually. The inheritance feature of object-oriented programming allows the creation of new objects and classes from existing ones. The objects created for one program can be used in another program for perfor ming similar functions. Some of the programming languages that follow the structured methodology are C. thus making the program look simpler and easier to understand. Pascal. You would connect the mouse. For example. BASIC. Many programmers can work on a single. Structured programming uses a top-down approach where a big program is viewed as a collection of many small modules. Java. consider t hat you are assembling a computer system. Since a module is defined to perform just one task. These modules are then arranged in a hierarchical structure. ====================================================================== Event-driven programming is a programming methodology in which the flow of a pro gram is determined by user actions such as mouse clicks or key presses. VisualBasic. Some of the commonly used programming methodol ogies are structured programming. The encapsulation feature of object-oriented programming helps hide the imple mentation details from the user and thereby provides increased data security. with each programmer wo rking on a different module. and the program execution flows from higher levels to lower levels. and mess ages received from other programs. On ly the interface of a system is visible to the user. and event-driven programming. This code reusability feature helps in reducing the deve lopment time. printer. These user actions and messages from other pr . 4.NET and C#. 2. to create an application that can perform multiple tasks. monitor. object-oriented programming. Some of the programming languages that follow the object-oriented methodology ar e C++. ====================================================================== Object-oriented programming is a programming methodology where the program is mo delled on the concept of objects and their interactions. which makes debugging easier. ====================================================================== Structured programming is a programming methodology that enforces a logical stru cture on the program being written. Object-oriented programming w orks in a similar way by putting together various objects. thereby reducing the development time. their features. and i nteractions. The program is divided into many simpler mod ules and each module handles a specific task. 2.ich the program can be developed. 3. large program. and Ada. which are usefu l for developing graphical user interfaces. 3. Object-oriented programming provides built-in code libraries. There are three types of flow controls used. to create the complete system. Some of the advantages of object-oriented programming are: 1. and so on.

and save their source code. 2. Some of the programming languages that follow the event-driven methodology are T cl (Tool Command Language) and PERL. 4. 3. 1. In the compiling stage. whereas. Unlike a compiler . load. Some programming languages such a s BASIC and LISP can be executed only by an interpreter. . correct. If any errors are detected in the source code. then error messages are displaye d. In the load phase. . hence code written in a programming language must be translated into machine language before execution. compil e. the source code is converted into machine language by using a compiler. 3. the design of an interpreter is easier and simpler as compared to a compiler. ====================================================================== All the programs developed using Java programming language go through the Java p latform process. the class loader uses the compiled file and transfer s the bytecode into the computer's primary memory. the Java Virtual Machine interprets the bytecod e and executes the program. The program code is written using English alphabets that th e computer cannot execute. the interpreter executes the code line by line and therefore takes comparative ly longer time to complete the process. the Java source code is translated into an interm ediate Java bytecode using the Java compiler. and debug ging. The compiled instructions are saved as an executable program. 1. An event-driven program is made up of many event han dlers. However. the resultant program is executed by the interpreter itself. the instructions of the program are written using a suit able programming language. In the edit phase. The Java platform process consists of five phases: edit. programmers use a text editor to write.An interpreter is software that translates the source code written in a progra mming language into an intermediate form and then executes it. compiling.A compiler is software that converts code written in a programming language in to machine language. In the compile phase. which are subroutines that handle the events generated. ====================================================================== The programming process involves three main stages: coding. In the interpret phase. In the verify phase. A computer can understand only the binary language of zeros and ones. the bytecode contained within the compiled file is validated. Once all the even t handling routines are developed. in an interpreter. 2. In the debugging stage. and interpret. they are combined together by writing a loop which will check for the events being called and call the appropriate event hand ler. Once debugging is done. In a compiler. verify. the resu ltant program is executed by hardware. 5.ograms are known as events. the causes of errors are identified and necessary cor rections are made to the code. the source code is compil ed again. . In the coding stage.