Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing Programming a general discussion. What is a Program? Sets of instructions that get the computer to do something Programs may be a few lines.

Similar presentations

Presentation on theme: "Introducing Programming a general discussion. What is a Program? Sets of instructions that get the computer to do something Programs may be a few lines."— Presentation transcript:

1 Introducing Programming a general discussion

2 What is a Program? Sets of instructions that get the computer to do something Programs may be a few lines or millions of lines of code All instructions are translated, eventually, to machine language. Ada, Countess of Lovelace First computer Programmer

3 Programming Tasks Most programs can be though of as having three phases 1. To gather input data or generate it. 2. To manipulate that data aka process the data. 3. To give meaningful information back to the user (output). The MAS programs we just programmed did the above. The values defined at the end of the program were the data items that we gathered.

4 Families of Languages 1. Machine Languages This was the HEX code we saw in memory. All languages must be translated to this. This language is DIFFERENT for every distinct processor. 2. Assembly Languages This was the MAS code we wrote. This language matches the Machine language of the processor. 3. High Level Languages: Procedural Languages Object Oriented Languages

5 Machine Languages Machine language commands are comprised of words of binary values. In our case we had 16 bit words. Each word contained an instruction or data or junk. We wrote this language in HEX in order to save space. Machine language is normally thought of as the Native language of the particular processor. Different processor types have different machine languages. Although the Marie machine is imaginary even it has it own machine language ( i.e. the 15 instructions we used)

6 Assembly Languages Assembly language was invented to make programming in machine easier. Each machine language instruction has an assemble language counterpart. Every time we assembled the Assembly language (MAS) we generated machine (MEX). Requires an Assembler to do this translation. MASMEX Assembler

7 High Level Languages High level language commands are very close, in syntax, to English, thus resulting in comparatively low error rate. High level commands need to be translated to machine language using an interpreter or compiler

8 There are many HLL’s Popular Today C C++ Perl Visual Basic Python Java HTML And many others

9 Translation Using an Interpreter Interpreters translate code into machine language on a line-by-line basis. Examples include Perl, Python et Typically, the translation speed is comparatively quicker than a compiler, but the execution speed is slower. These languages are somewhat easier to program in that compiled languages. We will study Perl as an example. print “ This is your first program”; $A = 10; $Sum = $Sum + 1;

10 Translation Using a Compiler Compiler translate code into machine language by translating the entire program at once. Typically, the translation speed is comparatively slower than an interpreter, but the execution speed is much quicker. Examples include C, C++, Fortran, and Cobol cout<< “This is your first c++ program”; a = 19; a = a + 1; If (a>20) cout <<“ done”;

11 Common Operations All types of high level languages share three families of operations: 1. Sequential Operations 2. Conditional Operations 3. Looping Operations

12 High Level Langauges High level languages are designed to make it easier for humans to program computers. They use many language constructs that are well known in our Human languages such as English

13 Sequential Operations Sequential operations are lines of code that execute in order. Sequential operations are the default operations in programming. Each instruction in a sequential block is executed one after another. cout<< “This is your first c++ program”; a = 19; a = a + 1; cout << “This is the value of a:” << a << endl;

14 Conditional Operations Conditional operations (sometimes called decision structures) alter the course of a program based on the result of a TRUE/FALSE test. Programmers construct those tests using relational operators. This are usually what we call If-Then-Else constructions and look something like… if ( comparision) { do some instructions } else { do some different instructions }

15 Looping Operations Looping operations are those structures in which code repeats until a given condition is met. Similar to conditional operations, programmers construct looping operations using relational operators. Remember or loops in MAS. We had to use the complicated skipcond instruction. HLL’s make this much easier. while (x < 10) { do some instructions }

16 Procedural Languages Early high-level languages were procedural in nature. The focus of procedural languages was on structure. Examples include QuickBasic, Fortran, Pascal, and early versions of Visual Basic.

17 Object-Oriented Languages Object-oriented languages are a more recent development, where the focus is on data (the “Primacy of Data”). In OOP, programmers include data and the ways to manipulate that data into one entity – the object. Examples include Java,C++, C# and VB.NET.

18 Summary A program is a set of instructions to get your computer to do something. All programs have three basic types of instructions: (1) input instructions; (2) processing instructions and (3) output instructions.

19 Summary Machine languages are comprised of 1s and 0s and are the native languages of computers. Assembly language commands are tied to specific processors and represent shortcuts to machine language.

20 Summary High level languages are close, in syntax, to English. To translate high-level languages, we must use compilers or interpreters. All high-level languages share three basic groups of operations: sequential, conditional & looping.

Download ppt "Introducing Programming a general discussion. What is a Program? Sets of instructions that get the computer to do something Programs may be a few lines."

Similar presentations

Ads by Google