INFORMATION TECHNOLOGY INTRODUCTION TO PROGRAMMING LESSON 1 Introduction to Programming Preface: Explain the importance of the development of programming languages and state the characteristics of the various types of programming languages. What is Programming? What is Computer Programming? What is a Computer Program? Programming is the planning, scheduling, or performing of a task or event. Computer Programming is the process of planning a sequence of steps a computer should follow. A Computer Program is list of instructions a computer should perform. A concert programme lists the orders of performances and actors, a computer program list the steps the computer should perform to do a specific task. Programming Languages A set of rules, symbols and special words used to construct a computer program. A programming language is simple in form but it is not always easy to use. Machine Language: Native Tongue This is a programming language that is made up of binary coded instructions, that is used directly by the computer to control its operations. In this language, programmers are required to write instructions for the computer in the finest level of detail –the base level of the computer hardware. Each line of code in Machine Language and Assembly Language which follows correspond to a single action of the computer system. It is the only language that needs no interpretation for the computer to understand it. E.g. ALGOL – ALGOrithmic Language. Advantages 1. Faster execution time as no translation is needed. 2. Uses less storage space as instructions controlling translation need to be stored. Disadvantages 1. Difficult for the programmers to develop and fix errors; binary digits are used. 2. Programs can only work with the CPU for which it was formatted. 3. Machine Language Program Code is slow and tedious to write and test. 4. Code for Programs written in Machine Language is difficult to learn, read and correct. 5. Machine Language is specific therefore it cannot be used in the same form on other computer models. A Machine Language Program written for an IBM Computer is not able for use of a Macintosh Computer. NB: All programs must be translated into Machine Language before a program may be executed (used) by the computer. A Programmer needs to know the details of the machine make up before a program can be written for that computer model when writing programs in Machine Language. Assembly Language This Programming Language marks the 2nd Generation of Programming, developed to replace the use of 1s and 0s that were used in the predecessor language – Machine Language. This is a Low Level Language in which mnemonics are used to represent Machine Language Instructions (for a particular program written in Binary Coded Form) and symbols were used allowing for instructions written to be more easily understood and remembered. This language was developed to replace the 0s and 1s used in Machine Language programs with symbols that are easier to understand and remember. This programming language is normally associated with Flow Chart. Advantages 1. Programs written in Assembly Language accounts for greater executional efficiency as they are faster and consume little storage compared to higher-level programming language. 2. Programs written in this language is less tedious to read and understand unlike programs written in Machine Language. 3. Codes used for Assembly Language programs are easier to learn, read, faster and easier to understand than programs written in Machine Language using 0s and 1s. 4. More compact in form that programs written in High Level Language as less statements are used to represent programming instructions. Disadvantages 1. Assembly Language coded programs are machine dependent. 2. Assembly Language programs are more tedious than High Level Language Programs to learn and use. 3. Programming development in Assembly Language is slower than programming in High Level Language. 4. Programs written in Assembly Language take longer to write and maintain that programs written in High Level Language. NB: Any program written in Assembly Language must be translated into Machine Language for its instructions to be executed. An Assembler is a program that translates an Assembly Language Program into its Machine Language Code. High Level Languages This the 3rd Level of Programming Language development differs significantly from its low-level predecessors as they require less coding detail and make programs easier to write. In this programming language, instructions are written using statements closer to English or any other Natural Language. Programs written enable High Level Programmers to develop programs that are machine independent – freeing programmers from knowing the finer details about the hardware on which programs run. Example of such programs includes Pascal, C, FORTRAN, PL/1, APL, BASIC – Beginner’s All purpose Symbolic Instruction Code, among many others. Advantages 1. Programming is done much faster and is less tedious. 2. High Level Language Program codes are easier to learn, read, understand and correct. 3. The High Level Language Program code is more English and Mathematics like in nature making it easier to use and understand. 2 READ Item$, Price, Units WHILE Item$ <> “Last record” Value = Price * Units PRING USING A$; Item$, Price, Value READ Item#, Price, Units END Disadvantage 1. Programs written in High Level Language are sometimes executed slowly. Natural Language Software that uses a natural human language to communicate to the computer system. As such, the user of Natural Language Programming does not need to know the rules, syntax, or even a particular computer language. Instead, the user types out requests at the keyboard or uses voice commands that the computer understands. These are the languages normally spoken by humans which make it comprehensible to humans. However, it is very difficult for computers to understand it owing to vastness of vocabulary, as the languages vary. NB: Any program written in a High Level Language has to be translated into its Machine Language Code before it’s instructions can be executed. A Compiler is a program that is used to translate a High Level Language Program into its Machine Language Code. Fourth Generation Language These very high-level languages are very popular today allowing both programmers and users to get by with program coding on little knowledge on how to code instructions. Consequently, they result in increased on-the-job productivity. These languages unlike its predecessors are declarative (nonprocedural programming language). These languages allowing application programs to be developed much faster and less expensive. Coding is reduced to simple commands and mouse clicks that select instructions. These programming languages consist of high-level English-like instructions to retrieve and format data in queries and report. In 4GLs, the programmer specifies what to do, not how to do it. A few simple 4GL instructions are all that are needed to respond to the following management requests: Which employees have accumulated more than 20 sick days since March 1, 2007? Which single hospital rooms, if any, will be vacated by the end of the day? List the departments that have exceeded their budgets alphabetically by department head’s name. TERMS ASSOCIATED WITH PROGRAMMING Interpreter is a program that translates the program code line by line during its execution. Source Code is a program that is written in a High Level Language. Object Code is a program written or translated into Machine Language/Code. Program Design is planning the specific software solution to meet the program specifications. Program Coding is writing the program. Program Maintenance is making changes to the program over time. Program Debugging and Testing is finding and eliminating errors in the program. Procedure-Oriented Programming Languages requires programmers to solve programming problems using traditional programming logic. COBOL is a good example of an early procedureoriented language. In this language, the emphasis is on what is to be done (the procedure). Non-Procedure Oriented Programming Languages (Object-Oriented Language/Object Oriented Programming) are languages where the emphasis is on the object of the action allowing for programs to be easier to design and understand. E.g. C++ popular for developing graphical applications – windows applications, and JAVA – similar to C++. SOURCE CODE COMPILER 3 OBJECT CODE Diagram showing the relationship between the Source Code and Object Code INFORMATION TECHNOLOGY INTRODUCTION TO PROGRAMMING LESSON 1 Fundamentals of Programming HOMEWORK 1A 1. Write notes on the following Programming Languages and state what are the advantages and disadvantages of each: i. iii. High Level Languages Fourth Generation Languages ii. iv. Natural Languages Fifth Generation Languages (4 marks - definition) (8 marks – adv. & disadv.) 2. In computing, what is ‘Programming’? 3. Why does the computer only understand machine coded instructions - a combination of ones and zeroes? (2 marks) 4. Give one advantage of Assembly Language Programs over Machine Language Programs? (2 marks) 5. Why are High Level Languages so called? 6. What distinguishes a Fourth Generation Programming Language from a Third Generation Programming Language? (2 marks) 7. Why is Natural Language Programming a difficult thing to achieve? 8. Give two possible disadvantages of High Level Languages compared with Assembly Language. (2 marks) 9. What is a ‘Source Code’? (2 marks) 10. Why must High Level Language be either compiled or interpreted? (2 marks) 11. What is the purpose of a Register? (2 marks) (2 marks) (2 marks) TOTAL MARKS 32 4 (2 marks)