Programming Languages Introduction PDF

Summary

This document provides an introduction to programming languages. It discusses the role of programming languages in communication with computers, and the different types of programming languages. It also covers the importance of syntax and other factors for choosing programming languages.

Full Transcript

Chapter 1 Introduction 1.1 Introduction to Programming Languages Programming Language is a language used to communicate with the computer by writing programs. Programming language is widely used in the development of operating systems. An Operating System (OS) is a soft...

Chapter 1 Introduction 1.1 Introduction to Programming Languages Programming Language is a language used to communicate with the computer by writing programs. Programming language is widely used in the development of operating systems. An Operating System (OS) is a software (collection of programs) that controls the various functions of a computer. Also it makes other programs on your computer work. Every programming language has rules governing its word usage and punctuation. These rules are called the language’s syntax. Mistakes in a language’s usage are syntax errors. After a computer program is typed using programming language statements and stored in memory, it must be translated to machine language that represents the millions of on/off circuits within the computer. Your programming language statements are called source code, and the translated machine language statements are object code. Each programming language uses a piece of software, called a compiler or an interpreter, to translate your source code into machine language. Machine language is also called binary language, and is represented as a series of 0s and 1s. The compiler or interpreter that translates your code tells you if any programming language component has been used incorrectly. Syntax errors are relatively easy to locate and correct because your compiler or interpreter highlights them. After a program’s source code is successfully translated to machine language, the computer can carry out the program instructions. When instructions are carried out, a program runs, or executes. 1.2 Reasons for Studying Concepts of Programming Languages Increased capacity to express ideas. Improved background for choosing appropriate languages. Increased ability to learn new languages. Better understanding of the significance of implementation. Better use of languages that are already known. Overall advancement of computing. 1.3 Programming Domains The areas of computer applications and their associated languages. 1. Scientific Applications 2. Business Applications 3. Artificial Intelligence 4. Web Software 1.4 Language Evaluation Criteria we need a set of evaluation criteria to language. Such a list of criteria is necessarily controversial, because it is difficult to get even two computer scientists to agree on the value of some given language characteristic relative to others. Some of the characteristics that influence three of the four most important of these criteria are shown in Table 1.1, and the criteria themselves are discussed in the following part. 1. Readability The characteristics that contribute to the readability of a programming language are:  Overall Simplicity. The overall simplicity of a programming language strongly affects its readability. o A language with a large number of basic constructs is more difficult to learn than one with a smaller number. o A second complicating characteristic of a programming language is feature multiplicity—that is, having more than one way to accomplish a particular operation. For example, in Java, a user can increment a simple integer variable in four different ways: count = count + 1 count += 1 count++ ++count o A third potential problem is operator overloading, in which a single operator symbol has more than one meaning. Although this is often useful, it can lead to reduced readability  Orthogonality Orthogonality in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language. A lack of orthogonality leads to exceptions to the rules of the language. Data Types The presence of adequate facilities for defining data types and data structures in a language is another significant aid to readability.  Syntax Design The syntax, or form, of the elements of a language has a significant effect on the readability of programs. Following are some examples of syntactic design choices that affect readability: 1- Special words. Program appearance and thus program readability are strongly influenced by the forms of a language’s special words (for example, while, class, and for). 2- Form and meaning. Designing statements so that their appearance at least partially indicates their purpose is an obvious aid to readability. Semantics, or meaning, should follow directly from syntax, or form. 2. Writability Writability is a measure of how easily a language can be used to create programs for a chosen problem domain. Most of the language characteristics that affect readability also affect writability. The other characteristics are:  Expressivity Expressivity in a language can refer to several different characteristics. o It means that there are very powerful operators that allow a great deal of computation to be accomplished with a very small program. o It means that a language has relatively convenient, rather than cumbersome, ways of specifying computations. For example, in C, the notation count++ is more convenient and shorter than count = count + 1. 3. Reliability A program is said to be reliable if it performs to its specifications under all conditions. The several language features that have a significant effect on the reliability of programs in a given language are:  Type Checking Type checking is simply testing for type errors in a given program, either by the compiler or during program execution. Because run-time type checking is expensive, compile-time type checking is more desirable.  Exception Handling The ability of a program to intercept run-time errors (as well as other unusual conditions detectable by the program), take corrective measures, and then continue is an obvious aid to reliability. This language facility is called exception handling.  Aliasing Aliasing is having two or more distinct names in a program that can be used to access the same memory cell.  Readability and Writability Both readability and writability influence reliability. 4. Cost The total cost of a programming language is a function of many of its characteristics.  First, there is the cost of training programmers to use the language, which is a function of the simplicity and orthogonality of the language and the experience of the programmers.  Second, there is the cost of writing programs in the language.  Third, there is the cost of compiling programs in the language.  Fourth, the cost of executing programs written in a language is greatly influenced by that language’s design.  The fifth factor in the cost of a language is the cost of the language implementation system.  Sixth, there is the cost of poor reliability.  The final consideration is the cost of maintaining programs, which includes both corrections and modifications to add new functionality. 1.5 Types of Programming Languages 1. Machine Language: Every computer has its own language called machine language. It depends on the specific Hardware of the computer. A machine language is also known as low level language also called machine understandable language. Computer understands & executes the program only in machine level language. 2. Assembly Language: Assembly language is the mnemonic language written in some specific symbolic codes, such as ADD, SUB etc. An assembly language program is first translated into machine language instruction by system program called assembler, before it can be executed. These are languages understandable by CPU & ALU. 3. High Level Language: A High level lay program also needs to be transferred into machine language instructions before it can be executed because computer understands only machine level language. Some popular High Level languages are Basic, Fortran, Cobol, Pascal, C & C++. High-level language offers three significant advantages over machine language: simplicity, uniformity and portability (i.e., machine independence).

Use Quizgecko on...
Browser
Browser