Advanced Programming Languages - ELTE

Transcription

Advan ed ProgrammingLanguages

AuthorsTibor ÁsványiÁkos BalaskóIván József BalázsBalázs CsizmaziaPéter CsontosSzabina FodorAttila Góbi†Hajnalka Heged¶sZoltán HorváthAndrás JuhászAttila KispityeTamás KozsikLehel István KováRis D.hárd LegéndiTamás MarinkovisAttila Rajmund NohlJudit Nyéky-GaizlerGábor PáliZoltán PorkolábGábor PésyMáté TejfelSzabols SergyánBalázs ZaisekViktória Zsók

Advan ed ProgrammingLanguagesEditorJudit Nyéky-Gaizler

The book is supported by the TÁMOP-4.1.2.A/11-1/1 project.Editor:Judit Nyéky-Gaizlerc Tibor Ásványi, Ákos Balaskó, Iván József Balázs, Balázs Csizmazia,Péter Csontos, Szabina Fodor, Attila Góbi, Hajnalka Hegedûs†,Zoltán Horváth, András Juhász, Attila Kispitye, Tamás Kozsik,Lehel István Kovács D., Richárd Legéndi, Tamás Marcinkovics,Attila Rajmund Nohl, Judit Nyéky-Gaizler, Gábor Páli,Zoltán Porkoláb, Gábor Pécsy, Máté Tejfel, Szabolcs Sergyán,Balázs Zaicsek, Viktória ZsókLayout editor: Attila KispityePublisher: Eötvös Loránd UniversityISBN: 978-963-284-450-3

Contents at a Glan odu tion 1Language Design 6Lexi al elements 42Control stru tures, statements 62S ope and lifespan 126Data types 158Composite types 224Subprograms 266Ex eption handling 366Abstra t data types 416Obje t-oriented programming 464Type parameters 562Corre tness in pra ti e 618Con urren y 704Program libraries 828Elements of fun tional programming languagesLogi programming and Prolog 932Aspe t-oriented programming 1012Appendix 1026Bibliography 1049Index 1069 856

Table of Contents

Introdu tion1. 1Language Design 6Szabina Fodor1.1. Programming languages: syntax, semantics, and pragmaticsSyntax 9Semantics 10Pragmatics 101.2. Implementation of computer programs 111.3. The evolution of programming languages 15The early years 15The move to higher-level languages 16The future of programming languages 191.4. Programming language categories 20Imperative or procedural languages 21Applicative or functional languages 21Rule-based or logical languages 22Object-oriented languages 23Concurrent programming languages 23Scripting languages 241.5. Influences on language design 241.6. Principles of programming language design 26Features of a good programming language 26Language design 351.7. The standardization process 361.8. Summary 371.9. Exercises 371.10. Useful tips 381.11. Solutions 38 8

viii Table of Contents2.3.42Judit Nyéky-Gaizler, Attila Kispitye2.1. Symbol sets 43The ASCII code 45The EBCDIC code 45The ISO 8859 family 46The Unicode standard 462.2. Symbol sets of programming languages 472.3. Identifiers 49Allowed syntax 51Distinction between lower and upper case lettersLength restrictions 52Reserved words 522.4. Literals 53Numeric literals 53Characters and strings 562.5. Comments 562.6. Summary 582.7. Exercises 582.8. Useful tips 592.9. Solutions 59Lexi al elements 62Balázs Csizmazia, Attila Kispitye, Judit Nyéky-Gaizler3.1. The job of a programmer 63Sentence-like description 64Flow diagrams 65D-diagrams 66Block diagrams 67Structograms 683.2. Implementation in assembly 68The solution in Pascal 69LMC 69Comparison of the solutions in LMC and Pascal3.3. An elementary approach 73Elements of the while-programs 73Higher level operations 74Considerations 763.4. Control approaches 76Imperative programming languages 76Declarative and functional languages 77Parallel execution 77Event driven programming 77 51Control stru tures, statements 72

Table of Contents3.5. Programming languages examined 79Sentence-like algorithm description: COBOL 79Structured programming: the Pascal language 80Portable assembly: the C language 81Everything is an object: the Smalltalk language 82Other examined programming languages 833.6. Assignment, arithmetic statements 83Features of COBOL 84Simple assignment: the Pascal language 85Assignment in C 85Solution in Smalltalk 86Multiple assignment and the CLU language 86The role of assignment in programs 86The empty statement 873.7. Sequence and the block statement 87Block statement in Pascal 88Break with the tradition of Pascal: the Ada languageCharacteristics of the C language family 90Block statement in Smalltalk 903.8. Unconditional transfer of control 91The features of COBOL 92Unconditional transfer of control in Pascal 93Modula-3: end of GOTO 93Special control statements in C 93New features in Java 943.9. Branch structures 95Branching in COBOL 96Conditional statement in Pascal 97Multiway branching in Pascal 98Safe branching: innovations of Modula-3 99Safe CASE in Modula-3 100Branch structures in C 100Multiway branching in C 101Multiway branching in C# 101Conditional statement in Smalltalk 102 89 ix

x Table of Contents3.10. Loops 102Loops in COBOL 103Loops in Pascal 104Modula-3: safe loops 106Loop–end–exit loops 107Features of the Ada language 107Repeating structures in C and Java 108Novelties of the C# language 109Iterators 111Loop statement in Smalltalk 1143.11. Self-invoking code (recursion) 1153.12. Summary 1163.13. Exercises 1173.14. Useful tips 1193.15. Solutions 1204.126Iván József Balázs, Zoltán PorkolábS ope and lifespan 4.1. The types of memory storage 128The static memory 128The automatic memory 129Dynamic memory 130A simple example 1314.2. Scope 132Global scope 134Compilation unit as a scope 134Functions and code blocks as scope 135A type as scope 1354.3. Lifespan 136Creation and destruction of objects 136Static 137Automatic 138Dynamic 1394.4. Examples 1404.5. Summary 1434.6. Exercises 1444.7. Useful Tips 1454.8. Solutions 145

Table of Contents158Gábor Pécsy5.1. What is a data type? 159The programming language perspective 160The programmers’ perspective 160Type systems of programming languages 163Type conversions 1645.2. Taxonomy of types 168Type classes 169Attributes in Ada 1695.3. Scalar type class 170Representation 170Operations 171Scalar types in Ada 1715.4. Discrete type class 172Enumerations 173Integer types 175Outliers 1815.5. Real type class 184Type-value set 184Operations 186Programming languages 1865.6. Pointer types 188Memory management 189Type-value set 191Operations 194Dereference 197Pointers to subprograms 198Language specialties 2005.7. Expressions 202Structure of expressions 203Evaluating expressions 2055.8. Other language specialties 208Ada: Type derivation and subtypes 2085.9. Summary 2105.10. Exercises 2135.11. Useful tips 2145.12. Solutions 2155. Data types xi

xii Table of Contents6.7.224Gábor Pécsy6.1. Type equivalence 2266.2. Mutable and immutable types 2276.3. Cartesian product types 229Type-value set 229Operations 230Representation of cartesian product typesLanguage specific features 2356.4. Union types 237Type-value set 238Operations 238Union-like composite types 2396.5. Iterated types 2466.6. Array 247Type-value set 247Operation 248Language specific features 249Arrays in Java 250Generalization – multi-dimensional arrays6.7. Sets 254Type-value set 255Operations 2556.8. Other iterated types 2566.9. Summary 2576.10. Exercises 2616.11. Useful tips 2616.12. Solutions 262Composite types 233 253266Tamás Kozsik, Attila Kispitye, Judit Nyéky-GaizlerSubprograms 7.1. The effect of subprograms on software quality 2687.2. Procedures and functions 269Languages with no difference between procedures and functions270Languages which distinguish between procedures and functions272

Table of Contents7.3. Structure of subprograms and calls 273What could be a parameter or return value? 273Specification of subprograms 280Body of subprograms 287Calling subprograms 292Recursive subprograms 297Declaration of the subprograms 297Macros and inline subprograms 299Subprogram types 3017.4. Passing parameters 302Parameter passing modes 302Comparison of parameter passing modes 310Parameter possibilities in some programming languages 3127.5. Environment of the subprograms 319Separate compilability 319Embedding 321Static and dynamic scope 323Lifetime of the variables 3267.6. Overloading subprogram names 327Operator overloading 3297.7. Implementation of subprograms 330Implementation of subprograms passed as parameters 3347.8. Iterators 3357.9. Coroutines 3387.10. Summary 3407.11. Exercises 3427.12. Useful tips 3447.13. Solutions 3478.366Attila Rajmund Nohl8.1. Introduction 367Basic concepts 367Why is exception handling useful 369The aspects of comparing exception handling 3758.2. The beginnings of exception handling 376Exception handling of a single statement: FORTRAN 376Exception handling of multiple statements: COBOL 376Dynamic exception handling: PL/I 377Ex eption handling xiii

xiv Table of Contents8.3. Advanced exception handling 378Static exception handling: CLU 378Exception propagation: Ada 379Exception classes: C 382Exception handling and correctness proving: Eiffel 384The finallyblock: Modula-3 386Checked exceptions: Java 387The exception handling of Delphi 389Nested exceptions: C# 390Exception handling with functions: Common Lisp 391Exceptions in concurrent environment: Erlang 392New solutions: Perl 396Back to the basics: Go 3988.4. Summary 4008.5. Examples for exception handling 401C 401Java 402Ada 404Eiffel 405Erlang 4078.6. Excercises 4088.7. Useful tips 4128.8. Solutions 4129.416Gábor Pécsy, Attila Kispitye9.1. Type constructs and data abstraction 4179.2. Expectations for programming languages 4189.3. Breaking down to modules 419Modular design 419Language support for modules 4249.4. Encapsulation 4369.5. Representation hiding 436Opaque type in C 437Private view of Ada types 438CLU abstract data types 439Visibility levels 440Abstra t data types

Table of tion of specification and implementationManagement of module dependency 443Consistent usage 444Generalized program schemes 445Summary 448Exercises 451Useful tips 451Solutions 452 440464Judit Nyéky-Gaizler, Balázs Zaicsek, István L. Kovács D., Szabolcs Sergyán10. Obje t-oriented programming 10.1. The class and the object 465Classes and objects in different languages 46710.2. Notations and diagrams 476Class diagram 476Object diagram 477The representation of instantiation 47710.3. Constructing and destructing objects 477Instantiation and the concept of Self (this) 48310.4. Encapsulation 48410.5. Data hiding, interfaces 485Friend methods and classes 488The private notation of Python 490Visibility Rules of Scala 49010.6. Class data, class method 492Class diagrams 49610.7. Inheritance 496Data hiding and inheritance 505Polymorphism and dynamic dispatching 508Abstract class 521Common ancestor 527Multiple inheritance 528Interfaces 541Nested classes, inner classes 54610.8. Working with classes and objects 546The Roman Principle 547Testing doubles 548SOLID object hierarchy 549The Law of Demeter 55310.9. Summary 55510.10. Exercises 55610.11. Useful tips 55610.12. Solutions 557 xv

xvi Table of Contents562Attila Góbi, Tamás Kozsik, Judit Nyéky-Gaizler, Hajnalka Hegedűs†, TamásMarcinkovics11.1. Control abstraction 56311.2. Data abstraction 56711.3. Polymorphism 571Parametric polymorphism 573Inclusion polymorphism 575Overloading polymorphism 580Coercion polymorphism 581Implementation of polymorphism in monomorphic languages 58311.4. Generic contract model 58411.5. Generic parameters 587Type and type class 587Template 591Subprogram 591Object 591Module 59211.6. Instantiation 594Explicit instantiation 595On-demand instantiation 595Lazy instantiation 595Generic parameter matching 596Specialization 597Type erasure 59911.7. Generics and inheritance 60011.8. Summary 60311.9. Examples 603C 603Java 606C# 608Comparing the examples 61111.10. Excercises 61111.11. Useful tips 61211.12. Solutions 61311. Type parameters 618András Juhász, Section 12.7: Judit Nyéky-Gaizler12. Corre tness in pra ti e 12.1. Introduction 620Thought-provoking 621

Table of Contents12.2. Flavor of object-oriented approach 622Abstract data types 622Type system 623Dynamic properties 623Object-oriented problem solving 62312.3. The correctness specification language 625Eiffel and first-order predicate Logic 625Stack as an example 632Partial and total functions 634Precondition 635Postcondition 635Pre- and postconditions in Eiffel 636Design aspects 639Class invariant 639Check construct 642Loops 643Assertions and inheritance 64712.4. Program-correctness in Eiffel 652Hoare-formulas 653Correctness of attributes 654Loop correctness 654Check correctness 656Exception correctness 656Class consistency 658Class correctness 660Note on method correctness 660Program correctness 66112.5. Program correctness issues 662Dependencies 662Void-safety 663Type safety 666Concurrency 66912.6. Correctness specification language 669Practical limits 669Model classes: an interim solution? 671Theoretical limits 67312.7. Languages and tools supporting Design by ContractD language 673Cobra language 675Oxygene language 676Correctness in .NET 678Java language and additional tools 682Ada 2012 language 689 673 xvii

xviii Table of Contents12.8.12.9.12.10.12.11.12.12.Summary 689Example source codeExercises 693Useful tips 697Solutions 69813. Con urren y 690704Richard O. Legendi, Ákos Balaskó, Máté Tejfel, Viktória Zsók13.1. Reasons for concurrency 70813.2. An abstract example 70813.3. Fallacies of concurrent computing 71413.4. Possible number of execution paths 716Amdahl’s law 71913.5. Taxonomy of concurrent architectures 72113.6. Communication and synchronization models 72213.7. Mutual exclusion and synchronization 723Deadlocks 723Starvation 725Techniques for synchronization 725Solutions for managing critical sections 72613.8. Taxonomy of languages supporting concurrency 729Processes, tasks, threads: Concurrent execution units 732Monitors 739Alternative approaches 74013.9. Common execution models 743Producers-consumers problem 743Readers-writers problem 744Dining philosophers problem 74413.10. Ada 746Tasks 746Entry, entry calls, accept statement 753Selective handling of incoming messages 756Exception handling 761Examples 76113.11. CSP 76813.12. Occam 77113.13. MPI 775Case study: Matrix multiplication 78013.14. Java 78113.15. C#/.NET 795Comparison of .Net with Java 795

Table of Contents13.16. Scala 798Comparison with concurrent processes 800Parallel collections 80513.17. General tips for creating concurrent softwareSingle responsibility principle 809Restrict access to shared resources 809Independency 809Do not reinvent the wheel! 810Know the library support 811Write thread-safe modules 811Testing 81113.18. Summary 81213.19. Exercises 81213.20. Useful tips 81413.21. Solutions 814 809828Attila Kispitye, Péter Csontos14. Program libraries 14.1. Requirements against program libraries 830Skills of a good program library developer 830Basic quality requirements 831Special requirements for program libraries 834Conditions for fulfillment of the requirements 83714.2. Object-oriented program library design 837Class hierarchy 838Size of the classes 841Size of services 844Types of classes 84614.3. New paradigms 85014.4. Standard program libraries 850Data structures 851I/O 851Memory management 85214.5. Lifecycle of program libraries 852Design phase 853Implementation phase 853Maintenance phase 85414.6. Summary 854 xix

xx Table of Contents856Zoltán Horváth, Gábor Páli, coauthors in Section 15.10: Viktória Zsók, MátéTejfel15. Elements of fun tional programming languages 15.1. Introduction 857The functional programming style 858Structure and evaluation of functional programs 859Features of modern functional languages 861Brief overview of functional languages 86515.2. Simple functional programs 867Definition of simple functions 867Guards 867Pattern matching 86815.3. Function types, higher-order functions 869Simple type constructions 871Local declarations 877An interesting example: queens on the chessboard 87715.4. Types and classes 881Polymorphism, type classes 881Algebraic data types 884Type synonyms 887Derived types 887Type constructor classes 88915.5. Modules 889Abstract algebraic data types 89015.6. Uniqueness, monads, side effects 893Unique variables 893Monads 895Mutable variables 89715.7. Interactive functional programs 89815.8. Error handling 90115.9. Dynamic types 90215.10. Concurrent, parallel and distributed programs 903Parallel and distributed programming in Concurrent Clean 904Distributed, parallel and concurrent programming in Haskell 907Parallel and distributed language constructs of JoCaml 91915.11. Summary 92215.12. Exercises 92215.13. Useful tips 92315.14. Solutions 924

Table of Contents16. Logiprogramming and Prolog 932Tibor Ásványi16.1. Introduction 93316.2. Logic programs 934Facts 935Rules 936Computing the answer 938Search trees 940Recursive rules 94216.3. Introduction to the Prolog programming language16.4. The data structures of a logic program 94616.5. List handling with recursive logic programs 948Recursive search 950Step-by-step approximation of the output 951Accumulator pairs 953The method of generalization 95416.6. The Prolog machine 954Executing pure Prolog programs 955Pattern matching 956NSTO programs 958First argument indexing 960Last call optimization 96116.7. Modifying the default control in Prolog 962Disjunctions 963Conditional goals and local cuts 963Negation and meta-goals 967The ordinary cut 96916.8. The meta-logical predicates of Prolog 972Arithmetic 972Type and comparison of terms 974Term manipulation 97516.9. Operator symbols in Prolog 97716.10. Extra-logical predicates of Prolog 980Loading Prolog programfiles 980Input and output 981Dynamic predicates 98216.11. Collecting solutions of queries 98516.12. Exception handling in Prolog 98716.13. Prolog modules 988Flat, predicate-based module system 988Module prefixing 990Modules and meta-predicates 991 944 xxi

xxii Table of Contents16.14. Conclusion 993Some classical literature 993Extensions of Prolog 993Problems with Prolog 994Fifth generation computers and their programsNewer trends 99516.15. Summary 99616.16. Exercises 99716.17. Useful tips 99916.18. Solutions 1003 9951012Péter Csontos, Tamás Kozsik, Attila Kispitye17. Aspe t-oriented programming 17.1. Overview of AOP 1014Aspects and components 1015Aspect description languages 1015Aspect weavers 101617.2. Introduction to AspectJ 1017Elements and main features of AspectJ 1017A short AspectJ example 1018Development tools and related languages 101817.3. Paradigms related to AOP and their implementations 1019Multi-dimensional separation of concerns (MDSC) 1019Adaptive programming (AP) 1020Composition filters (CF) 1021Generative programming (GP) 1021Intentional programming (IP) 1022Further promising initiatives 102317.4. Summary 10241026Péter Csontos, Attila Kispitye et al.18. Appendix 18.1. Short descriptions of programming languagesAda 1027ALGOL 60 1028ALGOL 68 1029BASIC 1029BETA 1029C 1029C 1030C# 1031Clean 1031 1027

Table of ContentsCLU 1031COBOL 1032Delphi 1032Eiffel 1033FORTRAN 1033Haskell 1034Java 1034LISP 1035Maple 1035Modula-2 1036Modula-3 1036Objective-C 1036Pascal 1037Perl 1037PHP 1038PL/I 1038Python 1038Ruby 1038SIMULA 67 1039Smalltalk 1039SML 1040SQL 1040Tcl 104118.2. Codetables 1042The ASCII character table 1042The ISO 8859-1 (Latin-1) printable character tableThe ISO 8859-2 (Latin-2) printable character tableThe IBM Codepage 437 1044The EBCDIC character table 1045Bibliography Index 10691049 10431043 xxiii

Introdu tion

Programming languages are thought by many to provide as a notation formfor program description. This view does not take into account – or does noteven know –, how high level or user-centered languages can aid in managingprogram complexity. Different languages with their possibilities suggest differentprogramming approaches, so the common practice, which is still used nowadaysin many places, is highly dangerous, when programming methodology is taughtthrough particular programming languages, not independently from them – thiscould only lead to narrow concerning all the programming possibilities.The goal of programming is to produce a good quality software product, sothe education of programming must start with the general definition of thetask and its solving program [Fot83]. Then based on this principle, the differentconcrete language tools should be acquainted to the programmers, which supportthe implementation. However, as it is questionable to teach the methodologythrough particular concrete programming languages, it also leads to a dead end,if the used programming language is said to be not important for the sake of themethodology. This is – as described by Bertrand Meyer [Mey00] – like “a birdwithout wings”. The idea is inseparable from the possibilities of formulation. It isnot a coincidence that in programming no single language has become dominant,nor that always newer programming languages are designed, which support evenmore the adaptation of different methodological concepts and requirements intopractice.Designers of programming languages must deal with three problems [Hor94]: The representation provided by the language must fit the hardware andthe software at the same time.The language must provide a good nomenclature for the description ofalgorithms.The language must serve as a tool to manage program complexity.

2 Introdu tionAspe ts of software qualityThe software is a product, and as for every product, it has – as defined by many([Mey00], [Hor94] and [LG96]) – different quality characteristics and requirements. One of the most important goals of the programming methodology isto specify a theoretical approach for creating good quality program products.The design and the evaluation of already existing programming languages aredefinitely influenced by methodological considerations.Next, characteristics of “good” software will be discussed according to thework of Bertrand Meyer [Mey00]. After that, language features will be examinedfor supporting the methodology – through numerous programming languages.Software quality is influenced by many factors. One part of these – suchas reliability, speed, or ease of use – are basically perceived by the user of theprogram. Others – such as how easy it is to reuse some parts of it for a different,but similar problem – affect program developers.Corre tnessCorrectness of the program product means that the program solves exactly theproblem and fits the desired specification. This is the first and most importantcriterion, since if a program is not working like it should, other requirementsdo not really count. The elementary basis for this is the precise and the mostcomplete specification.ReliabilityA program is called reliable if it is correct, and abnormal – not described inthe specification – circumstances do not lead to catastrophe, but are handled insome “reasonable” way.This definition shows, that reliability is by far not as a precise notion ascorrectness. One could say, of course with a more specific specification reliabilitywould mean correctness exactly, but in practice there are always cases which arenot covered by specification explicitly. That is why reliability is of high priorityfor the program product quality.MaintainabilityMaintainability refers to how easy it is to adjust the program product to specification changes.The users often demand further development, modification, adjustment of theprogram product to new external conditions. According to some surveys 70 %of program product costs are spent on maintenance, so it is understandablethat this requirement significantly affects the quality of the program. (This is

Introdu tionrelevant especially if developing big programs and program systems, since forsmall programs usually no change is too complex.)To increase maintainability, design simplicity and decentralization (to haveindependent modules) can be seen as the two most important basic principles.ReusabilityReusability is the feature of the software products, that they can be partly or asa whole reused in new applications.This is different to maintainability, since the same specification was modifiedthere, but now the experience should be utilized, that many elements of softwaresystems follow common patterns, and reimplementing already solved problemsshould be avoided.This question is particularly important, not only when producing individualprogram products, but for a global optimization of software development, asthe more reusable components are available to help problem solving, the moreenergy remains to improve other quality characteristics (at the same costs).CompatibilityCompatibility shows how easy it is to combine the software products with eachother. Programs are not developed isolated, so efficiency can go up by ordersof magnitude, if ready software can be simply connected to other systems.(Communication between programs is based on some standards, such as, forexample, in Unix.)Other hara teristi sFrom the quality characteristics of the program product, portability, efficiency,user friendliness, testability, clarity etc. are also important to pay attention to.Portability regards how easy it is to port the program to another machine,configuration or operating system – usually to have it run in different runtimeenvironments.The efficiency of a program is proportional to the running time and usedmemory size – the faster, or the less memory is used, the more efficient it is.(These requirements often contradict each other, a faster run is often set off bybigger memory requirements, and vice versa.)The user friendliness is very important for the user: this requires data inputto be logical and simple, the output of the results must be clearly formatted.Testability and clarity are important for the developers and maintainers ofthe program, without these the reliability of the program cannot be guaranteed. 3

4 Introdu tionAspe ts of software designSome of these requirements – the improvement of correctness and reliability– require primarily the development of specification tools. The easier it is toverify if a piece of program code is really an implementation according to thespecification, the easier it will be to developed correct and reliable programs.The main role here have programming language features for specification (typeinvariant, pre- and postconditions) descriptions – this is supported for exampleby Eiffel [Mey00], by Ada 2012 [Nyek98] etc.Implementation of another group of requirements – mainly maintainability,reusability and compatibility – can be best supported by designing the programsas independent program units having well defined interconnections. This is thebasis of the so called modular design. (A module here is not a programminglanguage concept, but a unit of the design.) This question will be handled inmore detail in Chapter 9.3.Our goal is to examine the features of different programming languages tosupport professional programmers in developing reliable software of good quality.Study of the tools of programming languagesIt is a natural question, why it is not enough to know one programming language,for what purpose it is good to deal with all the possible features of differentprogramming languages. In the following – primarily based on the work ofRobert W. Sebesta [Seb13] – we will try to summarize the advantages comingfrom this:In rease of the expressive powerOur thinking and even abstraction skills are strongly influenced by the possibilities of the language used. Only that can be expressed, for which there arewords. Likewise during program development and designing the solution, theknowledge of diverse programming language features can help programmers towiden their horizon. This is also true if a particular language must be used, sincegood principles can be applied in any environments.Choosing the appropriate programming languageMany programmers have learnt programming through one or two languages.Others know older languages which are now considered obsolete, and they arenot familiar with the features of modern languages. This could result in notselecting the most appropriate language if there would be more programminglanguages as options to choose from for a new task – since they do not know thepossibilities the other languages could offer. If these programmers would know

Introdu tionthe unique features of the available tools, they could make considerably betterdecisions.Better attainment of new toolsNewer and newer programming languages will appear, thus quality programmingrequires continuous learning. The more the basic elements of the programminglanguages are known, the easier it will be to learn and keep up with progress.In our book most examples are in Ada, C/C or Java language for certainlanguage constructs, there are only a few chapters (except of course those aboutlogical and functional programming) where these languages are not referencedin almost every paragraph.Our book is aimed at facilitating primarily, the studies of unive

1.3. The evolution of programming languages 15 The early years 15 The move to higher-level languages 16 The future of programming languages 19 1.4. Programming language categories 20 Imperative or procedural languages 21 Applicative or functional languages 21 Rule-based or logical languages 22 Object-oriented .