introduction by: dr. javad razjouyan. programming languages

25
Introduction By: Dr. Javad Razjouyan

Upload: shauna-atkinson

Post on 28-Dec-2015

237 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction By: Dr. Javad Razjouyan. Programming Languages

Introduction

By: Dr. Javad Razjouyan

Page 2: Introduction By: Dr. Javad Razjouyan. Programming Languages

Programming Languages

Page 3: Introduction By: Dr. Javad Razjouyan. Programming Languages

• So, what exactly is a programming language? As a loose definition, a programming language is a tool used by a programmer to give the computer very specific instructions in order to serve some purpose for the user. A program is like a recipe. It outlines exactly the steps needed to create something or perform a certain task. For, example, when baking chocolate chip cookies, there are certain steps that need to be followed:

Page 4: Introduction By: Dr. Javad Razjouyan. Programming Languages

Chocolate Chip Cookies Baking Steps:

• mix eggs, butter, sugar in a bowl

• add flour, baking soda, and flavorings

• mix until creamy

• add chocolate chips

• bake in the oven.

Page 5: Introduction By: Dr. Javad Razjouyan. Programming Languages

• For a person who has made cookies before and knows the amounts of each ingredient to use, this recipe is sufficient, however, for a person who has never baked cookies before, this recipe will not do. That person would need a recipe like the following: – place two eggs in a bowl – add 1.5 c. butter to the eggs– ... – bake cookies for 10-12 minutes at 375 degrees

or until brown

Page 6: Introduction By: Dr. Javad Razjouyan. Programming Languages

• There is still a problem with the preceding recipe. The first instruction says to put two eggs in the bowl, but it doesn't say to shell them first! This may seem like common sense, but it illustrates a fundamental concept: computers do exactly what they are told, no more, no less.

• When writing a program, a programmer must outline every possible step and scenario that could occur.

Page 7: Introduction By: Dr. Javad Razjouyan. Programming Languages

• The first programming languages that emerged, were assembly languages. These languages are exactly the instruction set of a specific processor. These languages are very low-level and hard to understand. For example, say we wanted to add two numbers, 3 and 4 and get a result:

Page 8: Introduction By: Dr. Javad Razjouyan. Programming Languages

• in C++: –int a = 3 +

4;

• in assembly: – ldl 3, R1

– ldl 4, R2

– addl R1, R2, R3

Page 9: Introduction By: Dr. Javad Razjouyan. Programming Languages

• The version in C++ is easier to understand and simpler to write. This is analagous to the differences in the first recipe presented and the second recipe presented. The first recipe expressed the method of baking cookies on a high level, while the second method went more in depth on how to actually mix and bake the cookies. Programmers write their code in a high level language and then use a compiler to translate their code into an assembly language and then into a machine language that will run on the machine they are using.

Page 10: Introduction By: Dr. Javad Razjouyan. Programming Languages

• Programs consist of algorithms. An algorithm is just a well-outlined method for completing a task. The above recipes could be called algorithms for the task of baking cookies. A high level algorithm for adding two numbers could be as follows:– ask the user for the first number – ask the user for the second number – add the two numbers – display the result on the screen

Page 11: Introduction By: Dr. Javad Razjouyan. Programming Languages

• This high-level abstraction is not actual code. However, it does express the ideas of a program, and is called pseudo-code. Often, programmers will design their programs in pseudo-code, and then use this to write their actual code.

Page 12: Introduction By: Dr. Javad Razjouyan. Programming Languages

• So, why is there more than one programming language? It may seem that a standard language should be agreed on, since all languages are translated using a compiler anyways. However, languages are often designed with a specific use in mind, and some are better than others for dealing with certain problems. So if a programmer is capable of writing a compiler (which is a very complex piece of software) then they can design and create a language.

Page 13: Introduction By: Dr. Javad Razjouyan. Programming Languages

• The most important thing to remember about programming languages is that they are only an abstraction! Programming languages were created so developers could express their ideas on a higher level than a computer can understand. Once a user has a good concept of how computers work, and has learned a few computer languages, it becomes much easier to pick up new languages.

Page 14: Introduction By: Dr. Javad Razjouyan. Programming Languages

• A programming language is a tool used by programmers in order to specifically outline a series of steps that a computer is to take in a certain instance. High-level programming languages allow a programmer to express ideas on an abstract level, and forces the compiler to worry about the low-level implementation details. This allows for faster development of applications, since applications are easier to write.

• There are even fourth generation languages emerging as viable programming languages. Recall that machine code is considered first generation, assembly languages are second generation, compiled languages are third generation. Fourth generation languages are actually code-generating environments, such as Microsoft's Visual Basic.

• These fourth generation languages allow programmers to express their ideas visually, and the environment then writes the code to implement these ideas.

Page 15: Introduction By: Dr. Javad Razjouyan. Programming Languages

Why Program in C++?

Page 16: Introduction By: Dr. Javad Razjouyan. Programming Languages

• So what is so special about C++? Why should you use C++ to develop your applications? First, C++ is not the best language to use in every instance. C++ is a great choice in most instances, but some special circumstances would be better suited to another language.

• There are a few major advantages to using C++:

Page 17: Introduction By: Dr. Javad Razjouyan. Programming Languages

1. C++ allows expression of abstract ideas – C++ is a third generation language that allows a

programmer to express their ideas at a high level as compared to assembly languages.

Page 18: Introduction By: Dr. Javad Razjouyan. Programming Languages

2. C++ still allows a programmer to keep low-level control – Even though C++ is a third generation

language, it has some of the "feel" of an assembly language. It allows a programmer to get down into the low-level workings and tune as necessary. C++ allows programmers strict control over memory management.

Page 19: Introduction By: Dr. Javad Razjouyan. Programming Languages

3. C++ has national standards (ANSI) – C++ is a language with national standards. This

is good for many reasons. Code written in C++ that conforms to the national standards can be easily integrated with preexisting code. Also, this allows programmers to reuse certain common libraries, so certain common functions do not need to be written more than once, and these functions behave the same anywhere they are used.

Page 20: Introduction By: Dr. Javad Razjouyan. Programming Languages

4. C++ is reusable and object-oriented – C++ is an object-oriented language. This makes

programming conceptually easier (once the object paradigm has been learned) and allows easy reuse of code, or parts of code through inheritance.

Page 21: Introduction By: Dr. Javad Razjouyan. Programming Languages

5. C++ is widely used and taught – C++ is a very widely used programming

language. Because of this, there are many tools available for C++ programming, and there is a broad base of programmers contributing to the C++ "community".

Page 22: Introduction By: Dr. Javad Razjouyan. Programming Languages

A Brief History of C++

Page 23: Introduction By: Dr. Javad Razjouyan. Programming Languages

• The C++ Programming Language is basically an extension of the C Programming Language. The C Programming language was developed from 1969-1973 at Bell labs, at the same time the UNIX operating system was being developed there. C was a direct descendant of the language B, which was developed by Ken Thompson as a systems programming language for the fledgling UNIX operating system. B, in turn, descended from the language BCPL which was designed in the 1960s by Martin Richards while at MIT.

Page 24: Introduction By: Dr. Javad Razjouyan. Programming Languages

• In 1971 Dennis Ritchie at Bell Labs extended the B language (by adding types) into what he called NB, for "New B". Ritchie credits some of his changes to language constructs found in Algol68, although he states "although it [the type scheme], perhaps, did not emerge in a form that Algol's adherents would approve of" After restructuring the language and rewriting the compiler for B, Ritchie gave his new language a name: "C".

Page 25: Introduction By: Dr. Javad Razjouyan. Programming Languages

• In 1983, with various versions of C floating around the computer world, ANSI established a committee that eventually published a standard for C in 1989.

• In 1983 Bjarne Stroustrup at Bell Labs created C++. C++ was designed for the UNIX system environment, it represents an enhancement of the C programming language and enables programmers to improve the quality of code produced, thus making reusable code easier to write.

Bjarne Stroustrup