This document discusses reasons for studying programming language concepts and introduces some key topics in programming languages. It covers:
1) Reasons for studying programming language concepts include increased ability to express ideas, improved ability to choose appropriate languages, and greater ability to learn new languages.
2) Programming domains discussed include scientific applications, business applications, artificial intelligence, systems programming, and scripting languages.
3) Key criteria for evaluating programming languages are discussed, including readability, writability, reliability, and cost. Factors that influence these criteria include simplicity, orthogonality, support for abstraction, and type checking.
This document discusses reasons for studying programming language concepts and introduces some key topics in programming languages. It covers:
1) Reasons for studying programming language concepts include increased ability to express ideas, improved ability to choose appropriate languages, and greater ability to learn new languages.
2) Programming domains discussed include scientific applications, business applications, artificial intelligence, systems programming, and scripting languages.
3) Key criteria for evaluating programming languages are discussed, including readability, writability, reliability, and cost. Factors that influence these criteria include simplicity, orthogonality, support for abstraction, and type checking.
This document discusses reasons for studying programming language concepts and introduces some key topics in programming languages. It covers:
1) Reasons for studying programming language concepts include increased ability to express ideas, improved ability to choose appropriate languages, and greater ability to learn new languages.
2) Programming domains discussed include scientific applications, business applications, artificial intelligence, systems programming, and scripting languages.
3) Key criteria for evaluating programming languages are discussed, including readability, writability, reliability, and cost. Factors that influence these criteria include simplicity, orthogonality, support for abstraction, and type checking.
This document discusses reasons for studying programming language concepts and introduces some key topics in programming languages. It covers:
1) Reasons for studying programming language concepts include increased ability to express ideas, improved ability to choose appropriate languages, and greater ability to learn new languages.
2) Programming domains discussed include scientific applications, business applications, artificial intelligence, systems programming, and scripting languages.
3) Key criteria for evaluating programming languages are discussed, including readability, writability, reliability, and cost. Factors that influence these criteria include simplicity, orthogonality, support for abstraction, and type checking.
Download as DOC, PDF, TXT or read online from Scribd
Download as doc, pdf, or txt
You are on page 1of 7
Chapter 1 Preliminaries
Reasons for Studying Concepts of Programming Languages
Increased ability to express ideas. It is believed that the depth at which we think is influenced by the expressive power of the language in which we communicate our thoughts. It is difficult for people to conceptualize structures they cant describe, verbally or in writing. Language in which they develop S! places limits on the kinds of control structures, data structures, and abstractions they can use. "wareness of a wider variety of #L features can reduce such limitations in S! development. $an language constructs be simulated in other languages that do not support those constructs directly% Improved background for choosing appropriate languages &any programmers, when given a choice of languages for a new pro'ect, continue to use the language with which they are most familiar, even if it is poorly suited to new pro'ects. If these programmers were familiar with other languages available, they would be in a better position to make informed language choices. Greater ability to learn new languages #rogramming languages are still in a state of continuous evolution, which means continuous learning is essential. #rogrammers who understand the concept of (( programming will have easier time learning )ava. (nce a thorough understanding of the fundamental concepts of languages is ac*uired, it becomes easier to see how concepts are incorporated into the design of the language being learned. Understand significance of implementation +nderstanding of implementation issues leads to an understanding of why languages are designed the way they are. ,his in turn leads to the ability to use a language more intelligently, as it was designed to be used. Ability to design new languages ,he more languages you gain knowledge of, the better understanding of programming languages concepts you understand. Overall advancement of computing In some cases, a language became widely used, at least in part, bc those in positions to choose languages were not sufficiently familiar with #L concepts. &any believe that "L-(L ./ was a better language than 0ortran1 however, 0ortran was most widely used. It is attributed to the fact that the programmers and managers didnt understand the conceptual design of "L-(L ./. 2o you think I3& has something to do with it% Programming Domains Scientific applications In the early 4/s computers were invented for scientific applications. ,he applications re*uire large number of floating point computations. 0ortran was the first language developed scientific applications. "L-(L ./ was intended for the same use. Business applications ,he first successful language for business was $(3(L. #roduce reports, use decimal arithmetic numbers and characters. ,he arrival of #$s started new ways for businesses to use computers. Spreadsheets and database systems were developed for business. Artificial intelligence Symbolic rather than numeric computations are manipulated. Symbolic computation is more suitably done with linked lists than arrays. LIS# was the first widely used "I programming language. Systems programming ,he (S and all of the programming supports tools are collectively known as its system software. 5eed efficiency because of continuous use. Scripting languages #ut a list of commands, called a script, in a file to be executed. #6# is a scripting language used on !eb server systems. Its code is embedded in 6,&L documents. ,he code is interpreted on the server before the document is sent to a re*uesting browser. Special7purpose languages 8#- is an example of these languages. Language Evaluation Criteria Readability Software development was largely thought of in term of writing code 9LOC:. Language constructs were designed more from the point of view of the computer than the users. 3ecause ease of maintenance is determined in large part by the readability of programs, readability became an important measure of the *uality of programs and programming languages. ,he result is a crossover from focus on machine orientation to focus on human orientation. ,he most important criterion 9ease of use: Overall simplicity 9Strongly affects readability: ,oo many features make the language difficult to learn. #rogrammers tend to learn a subset of the language and ignore its other features. 9"L-(L ./: &ultiplicity of features is also a complicating characteristic 9having more than one way to accomplish a particular operation.: ;x 9Java:< count = count + 1 count += 1 count ++ ++count "lthough the last two statements have slightly different meaning from each other and from the others, all four have the same meaning when used as stand7alone expressions. (perator overloading where a single operator symbol has more than one meaning. "lthough this is a useful feature, it can lead to reduced readability if users are allowed to create their own overloading and do not do it sensibly. Orthogonality &akes the language easy to learn and read. &eaning is context independent. #ointers should be able to point to any type of variable or data structure. ,he lack of orthogonality leads to exceptions to the rules of the language. " 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. ;very possible combination is legal and meaningful. ;x< page == in book. ,he more orthogonal the design of a language, the fewer exceptions the language rules re*uire. ,he most orthogonal programming language is "L-(L .>. ;very language construct has a type, and there are no restrictions on those types. ,his form of orthogonality leads to unnecessary complexity. Control Statements It became widely recognized that indiscriminate use of goto statements severely reduced program readability. ;x< $onsider the following nested loops written in $ while ?incr @ A/B C while ?sum @D =// C sum ED incr1 F incrEE1 F if $ didnt have a loop construct, this would be written as follows< loop=< if ?incr GD A/B go to out1 loopA< if ?sum G =//B go to next1 sum ED incr1 go to loopA1 next< incrEE1 go to loop=< out< 3asic and 0ortran in the early H/s lacked the control statements that allow strong restrictions on the use of gotos, so writing highly readable programs in those languages was difficult. Since then, languages have included sufficient control structures. ,he control statement design of a language is now a less important factor in readability than it was in the past. Data Types and Structures ,he presence of ade*uate facilities for defining data types and data structures in a language is another significant aid to reliability. ;x< 3oolean type. timeout D = or timeout D true Syntax Considerations ,he syntax of the elements of a language has a significant effect on readability. ,he following are examples of syntactic design choices that affect readability< Identifier forms< 8estricting identifiers to very short lengths detracts from readability. "5SI 3"SI$ ?=IH>B an identifier could consist only of a single letter of a single letter followed by a single digit. Special Words< #rogram appearance and thus program readability are strongly influenced by the forms of a languages special words. ;x< while, class, for. $ uses braces for pairing control structures. It is difficult to determine which group is being ended. 0ortran IJ allows programmers to use special names as legal variable names. orm and !eaning< 2esigning statements so that their appearance at least partially indicates their purpose is an obvious aid to readability. Semantic should follow directly from syntax, or form. ;x< In $ the use of static depends on the context of its appearance. If used as a variable inside a function, it means the variable is created at compile time. If used on the definition of a variable that is outside all functions, it means the variable is visible only in the file in which its definition appears. Writability It is a measure of how easily a language can be used to create programs for a chosen problem domain. &ost of the language characteristics that affect readability also affect writability. Simplicity and orthogonality " smaller number of primitive constructs and a consistent set of rules for combining them is much better than simply having a large number of primitives. Support for abstraction Astraction means the ability to define and then use complicated structures or operations in ways that allow many of the details to be ignored. " process abstraction is the use of a subprogram to implement a sort algorithm that is re*uired several times in a program instead of replicating it in all places where it is needed. ;xpressivity It means that a language has relatively convenient, rather than cumbersome, ways of specifying computations. ;x< EEcount count D count E = more convenient and shorter Reliability " program is said to be reliale if it performs to its specifications under all conditions. Type chec!ing< is simply testing for type errors in a given program, either by the compiler or during program execution. ,he earlier errors are detected, the less expensive it is to make the re*uired repairs. )ava re*uires type checking of nearly all variables and expressions at compile time. "xception handling< the ability to intercept run7time errors, take corrective measures, and then continue is a great aid to reliability. Aliasing< it is having two or more distinct referencing methods, or names, for the same memory cell. It is now widely accepted that aliasing is a dangerous feature in a language. #eadaility and writaility< 3oth readability and writability influence reliability. Cost $ategories ,raining programmers to use language $riting programs 9!ritability: $ompiling programs ;xecuting programs Language implementation system 90ree compilers is the key, success of )ava: #eliaility, does the software fail% %aintaining programs< &aintenance costs can be as high as two to four times as much as development costs. #ortability 9standardization of the language: -enerality ?the applicability to a wide range of applicationsB Influences on Language Design Computer architecture< Kon 5eumann !e use imperative languages, at least in part, because we use von 5eumann machines 2ata and programs stored in same memory &emory is separate from $#+ Instructions and data are piped from memory to $#+ 8esults of operations in the $#+ must be moved back to memory 3asis for imperative languages Kariables model memory cells "ssignment statements model piping Iteration is efficient Programming methodologies =IJ/s and early =I./s< Simple applications1 worry about machine efficiency Late =I./s< #eople efficiency became important1 readability, better control structures Structured programming ,op7down design and step7wise refinement Late =IH/s< #rocess7oriented to data7oriented data abstraction &iddle =I>/s< (b'ect7oriented programming Language Categories Imperative $entral features are variables, assignment statements, and iteration $, #ascal 0unctional &ain means of making computations is by applying functions to given parameters LIS#, Scheme Logic 8ule7based 8ules are specified in no special order #rolog (b'ect7oriented ;ncapsulate data ob'ects with processing Inheritance and dynamic type binding -rew out of imperative languages $EE, )ava Programming Environments ,he collection of tools used in software development +5IL "n older operating system and tool collection 3orland )3uilder "n integrated development environment for )ava &icrosoft Kisual Studio.5;, " large, complex visual environment +sed to program in $M, Kisual 3"SI$.5;,, )script, )M, or $EE