CSCI-235 Micro-Computer Applications Programming: Part I
Programming Program – a set of detailed, step-by-step instructions that directs the computer to do what you want it to do Programming language – a set of rules that provides a way of telling the computer what operations to perform © Prentice-Hall, Inc
The Programming Process Five main steps Defining the problem Planning the solution Coding the program Testing the program Documenting the program © Prentice-Hall, Inc
Defining the Problem Develop a written agreement that specifies: The input data The desired output Sometimes, the programmer receives a written specification from the systems analyst Other times, the programmer meets with users directly © Prentice-Hall, Inc
Planning the Solution Algorithm – a detailed, step-by-step solution to the problem Several tools help plan the algorithm © Prentice-Hall, Inc
Planning Tools Flowchart – a pictorial representation of the algorithm Pseudocode – English-like language Specifies algorithm with more precision than you can in English, but less than a programming language © Prentice-Hall, Inc
Coding the Program Translating the algorithm from the planning stage into a formal programming language All languages have syntax rules Similar to grammatical rules The computer will reject a program with even a minor syntax error Programs can be keyed into the computer by using a text editor © Prentice-Hall, Inc
Programming Languages Assembly Language Machine Language Fortran Pascal COBOL BASIC Ada Visual Basic C and C++ Java Smalltalk © Prentice-Hall, Inc
Testing the Program Two phases of testing the program Translation Converting the program you wrote into the binary instructions the CPU understands Debugging Identifying and correcting logic errors in the program © Prentice-Hall, Inc
Translation Compiler translates the program (source module) into a machine language version (object module) If the compiler detects syntax errors, it will produce messages describing those errors If no syntax errors exist, the object module will be linked to create a load module Load module is executed by the computer EXAMPLE © Prentice-Hall, Inc
Documenting the Program Materials are generated at each part of the process Common examples of documentation Flowchart and/or pseudocode Comments within the source code Testing procedures Layouts of input and output records A narrative description of the program © Prentice-Hall, Inc
Levels of Languages Lower-level languages – more like the 0s and 1s the computer itself uses Higher-level languages – more like the languages people use © Prentice-Hall, Inc
Machine Language Programs and memory locations are written in strings of 0s and 1s Problems with machine languages Programs are difficult to write and debug Each computer has its own machine language Only option available to early programmers © Prentice-Hall, Inc
Machine Language Machine language: Consists of binary numbers (0s and 1s) Is the earliest programming language Is the only language the computer understands without translation Is machine dependent Each family of processors has its own machine language © Prentice-Hall, Inc
Assembly Languages Substitute mnemonic codes for 0s and 1s For example, A for add, C for compare, etc. Use names rather than binary addresses for memory locations Require an assembler to translate the program into machine language Still used for programming chips and writing utility programs © Prentice-Hall, Inc
Assembly Languages Assembly language: Resembles machine language Is a low-level language Uses brief abbreviations for program instructions Abbreviations are called mnemonics A program is written in source code (text file) and translated into machine language by an assembler © Prentice-Hall, Inc
High-Level Languages Transformed programming Programmers could focus on solving problems rather than manipulating hardware Programs could be written and debugged much more quickly Requires a compiler to convert the statements into machine language Each computer has its own version of a compiler for each language © Prentice-Hall, Inc
High-level Languages High-Level languages: Create programs at a high level of abstraction Are easier to read, write, and maintain than machine and assembly languages Use a compiler or interpreter to translate code © Prentice-Hall, Inc
Compilers and Interpreters A compiler is a program that changes source code to object code An interpreter translates source code one line at a time and executes the instruction © Prentice-Hall, Inc
Major Programming Languages FORTRAN COBOL BASIC Visual Basic C Java © Prentice-Hall, Inc
FORTRAN The first high-level language Stands for FORmula TRANslator Used primarily for engineering, mathematical, and scientific tasks © Prentice-Hall, Inc
COBOL Stands for COmmon Business-Oriented Language Used primarily for business requirements Processes large data files Produces well-formatted reports © Prentice-Hall, Inc
BASIC Stands for Beginners’ All-Purpose Symbolic Instruction Code Developed to teach programming to college students Became very popular with the introduction of the microcomputer © Prentice-Hall, Inc
C Originally designed to write systems software Offers the ease of use of a high-level language with the efficiency of an assembly language Very portable – can be used with virtually every combination of computer and operating system © Prentice-Hall, Inc
Java A network-friendly programming language that permits a piece of software to run directly on many different platforms Allows programmers to write one version of the program, rather than a separate version of each platform Very useful for Internet development Java applets can run in the user’s Web browser © Prentice-Hall, Inc