Introduction to Programming Languages Programming in C C Scheme Prolog C and SOA 5th Edition Yinong Chen pdf download
Introduction to Programming Languages Programming in C C Scheme Prolog C and SOA 5th Edition Yinong Chen pdf download
https://ebookfinal.com/download/introduction-to-programming-
languages-programming-in-c-c-scheme-prolog-c-and-soa-5th-edition-
yinong-chen/
https://ebookfinal.com/download/programming-languages-principles-and-
practices-3rd-edition-kenneth-c-louden/
https://ebookfinal.com/download/medicine-in-rural-china-c-c-chen/
https://ebookfinal.com/download/c-programming-in-linux-2nd-edition-
david-haskins/
https://ebookfinal.com/download/c-programming-program-design-
including-data-structures-5th-edition-d-s-malik/
A Complete Guide to Programming in C 1st Edition Ulla
Kirch-Prinz
https://ebookfinal.com/download/a-complete-guide-to-programming-
in-c-1st-edition-ulla-kirch-prinz/
https://ebookfinal.com/download/mastering-c-database-programming-1st-
edition-jason-price/
https://ebookfinal.com/download/programming-with-ansi-c-2nd-edition-
bhushan-trivedi/
https://ebookfinal.com/download/programming-in-prolog-fifth-edition-w-
f-clocksin/
Introduction to Programming Languages Programming
in C C Scheme Prolog C and SOA 5th Edition Yinong
Chen Digital Instant Download
Author(s): Yinong Chen
ISBN(s): 9781524916992, 1524916994
Edition: 5
File Details: PDF, 27.24 MB
Year: 2016
Language: english
Introduction to Programming Languages
Fifth Edition
Yinong Chen
Arizona State University
Kendall Hunt
publishing company
Cover image courtesy of© Shutter stock, Inc. Used under license.
Kendall Hunt
publis�ing company
www .kendallhunt.com
Send all inquiries to:
4050 West mark Drive
Dubuque, IA 52004-1840
Copyright© 2003, 2006, 2012, 2015 by Yinong Chen and Wei-Tek Tsai
2017 by Kendall Hunt Publishing Company
ISBN 978-1-5249-1699-2
Preface .............................................................................................................................................. x1
Chapter 1 Basic Principles of Programming Languages.................................................................... 1
1.1 Introduction............................................................................................................................ 2
1.1.1 Programming concepts and paradigms 2
1.1.2 Program performance and features of programming languages 3
1.1.3 Development of programming languages 4
1.2 Structures of programming languages ................................................................................... 8
1.2.1 Lexical structure 8
1.2.2 Syntactic structure 9
1.2.3 Contextual structure 9
1.2.4 Semantic structure 9
1.2.5 BNF notation 9
1.2.6 Syntax graph 11
1.3 Data types and type checking .............................................................................................. 12
1.3.1 Data types and type equivalence 13
1.3.2 Type checking and type conversion 13
1.3.3 Orthogonality 14
1.4 Program processing and preprocessing ................................................................................ 16
1.4.1 Interpretation and compilation 16
1.4.2 Preprocessing: macro and inlining 18
* 1.5 Program development .......................................................................................................... 23
1.5.1 Program development process 23
1.5.2 Program testing 24
1.5.3 Correctness proof 27
1.6 Summary .............................................................................................................................. 29
1.7 Homework and programming exercises .............................................................................. 31
Chapter 2 The Imperative Programming Languages, C/C++ ......................................................... 39
2.1 Getting started with CIC++.................................................................................................. 40
2.1.1 Write your first CIC++ program 40
2.1.2 Basic input and output functions 41
2.1.3 Formatted input and output functions 42
2.2 Control structures in CIC++ ................................................................................................. 44
2.2.1 Operators and the order of evaluation 44
111
2.2.2 Basic selection structures (if-then-else and the conditional expression) 45
2.2.3 Multiple selection structure (switch) 46
2.2.4 Iteration structures (while, do-while, and for) 49
2.3 Data and basic data types in CIC++ ..................................................................................... 51
2.3.1 Declaration of variables and functions 51
2.3.2 Scope rule 52
2.3.3 Basic data types 53
2.4 Complex types ..................................................................................................................... 56
2.4.1 Array 56
2.4.2 Pointer 58
2.4.3 String 60
2.4.4 Constants 69
2.4.5 Enumeration type 70
2.5 Compound data types........................................................................................................... 73
2.5.1 Structure types and paddings 73
2.5.2 Union 75
2.5.3 Array of structures using static memory allocation 77
2.5.4 Linked list using dynamic memory allocation 80
2.5.5 Doubly linked list 84
2.5.6 Stack 86
2.6 Standard input and output, files, and file operations ........................................................... 89
2.6.1 Basic concepts of files and file operations 89
2.6.2 File operations in C 90
2.6.3 Flush operation in C 95
2.7 Functions and parameter passing ......................................................................................... 97
2.8 Recursive structures and applications ................................................................................ 101
2.8.1 Loop structures versus recursive structures 101
2.8.2 The fantastic-four abstract approach of writing recursive functions 102
2.8.3 Hanoi Towers 103
2.8.4 Insertion sorting 106
2.8.5 Merge sort algorithm 108
2.8.6 Quick sort algorithm 110
2.8.7 Tree operations 110
2.8.8 Gray code generation 114
2.9 Modular design .................................................................................................................. 116
2.10 Case Study: Putting All Together ...................................................................................... 118
iv
2.11 Summary ............................................................................................................................ 125
2.12 Homework, programming exercises, and projects ............................................................. 127
Chapter 3 The Object-Oriented Programming Language, C++ ................................................... 147
3.1 A long program example: a queue and a priority queue written in C++ ........................... 148
3.2 Class definition and composition ....................................................................................... 151
3.2.1 Class definition 151
3.2.2 Scope resolution operator 152
3.2.3 Objects from a class 153
3.2.4 Definition of constructor and destructor 153
3.3 Memory management and garbage collection ................................................................... 154
3.3.1 Static: global variables and static local variables 155
3.3.2 Runtime stack for local variables 156
3.3.3 Heap: dynamic memory allocation 159
3.3.4 Scope and garbage collection 159
3.3.5 Memory leak detection 164
3.4 Inheritance ......................................................................................................................... 171
3.4.1 Class containment and inheritance 171
3.4.2 Inheritance and virtual function 174
3.4.3 Inheritance and hierarchy 177
3.4.4 Inheritance and polymorphism 191
3.4.5 Polymorphism and type checking 193
3.4.6 Polymorphism and late binding 194
3.4.7 Type Casting in C++ 194
3.5 Function and Operator Overloading .................................................................................. 196
3.5.1 Function overloading 196
3.5.2 Operator overloading 197
3.6 File Operations in C++ ...................................................................................................... 203
3.6.1 File objects and operations in C++ 203
3.6.2 Ignore operation in C++ 208
3.7 Exception Handling ........................................................................................................... 209
3.8 Case Study: Putting All Together ...................................................................................... 213
3.8.1 Organization of the program 213
3.8.2 Header files 214
3.8.3 Source fi1es 216
*3.9 Parallel computing and multithreading .............................................................................. 224
3.9. l Basic concepts in parallel computing and multithreading 224
V
3.9.2 Generic features in C++ 224
3.9.3 Case Study: Implementing multithreading in C++ 226
3.10 Summary ............................................................................................................................ 230
3.11 Homework, programming exercises, and projects ............................................................. 231
Chapter 4 The Functional Programming Language, Scheme ....................................................... 241
4.1 From imperative programming to functional programming .............................................. 242
4.2 Prefix notation.................................................................................................................... 244
4.3 Basic Scheme terminology ................................................................................................ 246
4.4 Basic Scheme data types and functions ............................................................................. 249
4.4.1 Number types 249
4.4.2 Boolean 250
4.4.3 Character 251
4.4.4 String 252
4.4.5 Symbol 252
4.4.6 Pair 252
4.4.7 List 254
4.4.8 Application of Quotes 255
4.4.9 Definition of procedure and procedure type 256
4.4.10 Input/output and nonfunctional features 258
*4.5 Lambda-calculus ................................................................................................................ 260
4.5.1 Lambda-expressions 260
4.5.2 A-procedure and parameter scope 261
4.5.3 Reduction rules 261
4.6 Define your Scheme procedures and macros ..................................................................... 262
4.6.1 Unnamed procedures 263
4.6.2 Named procedures 263
4.6.3 Scopes of variables and procedures 263
4.6.4 Let-form and unnamed procedures 265
4.6.5 Macros 266
4.6.6 Compare and contrast imperative and functional programming paradigms 268
4.7 Recursive procedures ......................................................................................................... 270
4.8 Define recursive procedures on data types ........................................................................ 272
4.8.1 Number manipulations 272
4.8.2 Character and string manipulations 276
4.8.3 List manipulations 277
4.9 Higher-order functions....................................................................................................... 279
Vl
4.9.1 Mapping 280
4.9.2 Reduction 283
4.9.3 Filtering 284
4.9.4 Application of filtering in query languages 286
4.10 Summary ............................................................................................................................ 287
4.11 Homework, programming exercises, and projects ............................................................. 289
Chapter 5 The Logic Programming Language, Prolog .................................................................. 299
5.1 Basic concepts of logic programming in Prolog ................................................................ 299
5.1.1 Prolog basics 300
5.1.2 Structures of Prolog facts, rules, and goals 302
5.2 The Prolog execution model .............................................................................................. 303
5.2.1 Unification of a goal 303
5.2.2 Example of searching through a database 305
5.3 Arithmetic operations and database queries ...................................................................... 306
5.3.1 Arithmetic operations and built-in functions 306
5.3.2 Combining database queries with arithmetic operations 308
5.4 Prolog functions and recursive rules .................................................................................. 310
5.4.l Parameter passing in Prolog 310
5.4.2 Factorial example 311
5.4.3 Fibonacci numbers example 311
5.4.4 Hanoi Towers 312
5.4.5 Graph model and processing 313
5.4.6 Map representation and coloring 314
5.5 List and list manipulation .................................................................................................. 316
5.5.1 Definition of pairs and lists 316
5.5.2 Pair simplification rules 317
5.5.3 List membership and operations 318
5.5.4 Knapsack problem 321
5.5.5 Quick sort 322
5.6 Flow control structures ...................................................................................................... 323
5.6.l Cut 324
5.6.2 Fail 327
5.6.3 Repeat 328
*5.7 Prolog application in semantic Web .................................................................................. 330
5.8 Summary ............................................................................................................................ 331
5.9 Homework, programming exercises, and projects ............................................................. 333
vii
Chapter 6 Fundamentals of the Service-Oriented Computing Paradigm .................................... 341
6.1 Introduction to C# .............................................................................................................. 341
6.1.1 Getting started with C# and Visual Studio 341
6.1.2 Comparison between C++ and C# 343
6.1.3 N amespaces and the using directives 343
6.1.4 The queue example in C# 345
6.1.5 Class and object in C# 346
6.1.6 Parameters: passing by reference with re f&out 349
6.1.7 Base classes and constructors 350
6.1.8 Constructor, destructor, and garbage collection 350
6.1.9 Pointers in C# 351
6.1.10 C# unified type system 352
6.1.11 Further topics in C# 353
6.2 Service-oriented computing paradigm ............................................................................... 353
6.2.l Basic concepts and terminologies 353
6.2.2 Web services development 355
6.2.3 Service-oriented system engineering 356
6.2.4 Web services and enabling technologies 357
6.3 *Service providers: programming web services in C# ...................................................... 358
6.3.l Creating a web service project 359
6.3.2 Writing the service class 360
6.3.3 Launch and access your web services 361
6.3.4 Automatically generating a WSDL file 363
6.4 Publishing and searching web services using UDDI ......................................................... 365
6.4.1 UDDI file 365
6.4.2 ebXML 367
6.4.3 Ad hoc registry lists 368
6.5 Building applications using ASP.Net ................................................................................ 368
6.5.1 Creating your own web browser 368
6.5.2 Creating a Windows application project in ASP.Net 369
6.5.3 Developing a website application to consume web services 374
6.6 Silverlight and Phone Applications Development ............................................................. 377
6.6.1 Silverlight Applications 377
6.6.2 Developing Windows Phone Apps Using Silverlight 380
6.7 Cloud computing and big data processing ......................................................................... 389
6.7.1 Cloud computing 389
6.7.2 Big data 392
Vlll
6.8 Summary ............................................................................................................................ 394
6.9 Homework, programming exercises, and projects ............................................................. 395
Appendix A Basic Computer Architectures and Assembly Language Programming .................... 401
A. l Basic computer components and computer architectures .................................................. 401
A.2 Computer architectures and assembly programming ......................................................... 402
A.3 Subroutines and local variables on stack ........................................................................... 407
Appendix B Programming Environments Supporting C, C++, Scheme, and Prolog ..................... 409
B. l Introduction to operating systems ...................................................................................... 409
B.2 Introduction to Unix and CIC++ programming environments........................................... 412
B.2.1 Unix and Linux operating systems 412
B.2.2 Unix shell and commands 413
B.2.3 Unix system calls 417
B.2.4 Getting started with GNU GCC under the Unix operating system 419
B.2.5 Debugging your CIC++ programs in GNC GCC 421
B.2.6 Frequently used GCC compiler options 424
B.2.7 CIC++ operators 424
B.2.8 Download programming development environments and tutorials 426
BJ Getting started with Visual Studio programming environment ......................................... 426
B.3.1 Creating a CIC++ project in Visual Studio 427
B.3.2 Debugging your CIC++ programs in Visual Studio 429
B.4 Programming environments supporting Scheme programming ........................................ 430
B.4.1 Getting started with DrRacket 430
B.4.2 Download DrRacket programming environment 431
B.5 Programming environments supporting Prolog programming .......................................... 432
B.5.1 Getting started with the GNU Prolog environment 432
B.5.2 Getting started with Prolog programming 433
B.5.3 Download Prolog programming development tools 435
Appendix C ASCII Character Table ................................................................................................... 437
Bibliography ........................................................................................................................................... 439
Index ........................................................................................................................................... 443
ix
Preface
We all have witnessed the rapid development of computer science and its applications in many domains,
particularly in web-based computing (Web 2.0), cloud computing, big data processing, and mobile
computing. As a science discipline, the fundamentals of computer science, including programming
language principles and the classic programming languages, are stable and do not change with the
technological innovations. C, C++, Scheme/LISP, and Prolog belong to the classic programming languages
that were developed several decades ago and are still the most significant programming languages today,
both in theory and in practice. However, the technologies that surround these languages have been changed
and improved, which give these languages new perspectives and new applications. For example, C++ is
extended to generic classes and writing multithread programs. Functional programming principles are
widely used in database query languages and the new object- and service-oriented programming languages
such as C#.
This text is intended for computer science and computer engineering students in their sophomore year of
study. It is assumed that students have completed a basic computer science course and have learned a high
level programming language like C, C++, or Java.
Most of the content presented in the text has been used in the "Introduction to Programming Languages"
course taught by the author in the School of Computer Science at the University of the Witwatersrand at
Johannesburg, and in the Computer Science and Engineering programs at Arizona State University. This
text is different from the existing texts on programming languages that either focus on teaching
programming paradigms, principles, and the language mechanisms, or focus on language constructs and
programming skills. This text takes a balanced approach on both sides. It teaches four programming
languages representing four major programming paradigms. Programming paradigms, principles, and
language mechanisms are used as the vehicle to facilitate learning of the four programming languages in a
coherent way. The goals of such a programming course are to make sure that computer science students are
exposed to different programming paradigms and language mechanisms, and obtain sufficient
programming skills and experience in different programming languages, so that they can quickly use these
or similar languages in other courses.
Although there are many different programming paradigms, imperative, object-oriented, functional, and
logic programming paradigms are the four major paradigms widely taught in computer science and
computer engineering departments around the world. The four languages we will study in the text are the
imperative C, object-oriented C++, functional Scheme, and logic Prolog. At the end of the course, students
should understand
• the language structures at different layers (lexical, syntactic, contextual, and semantic), the control
structures and the execution models of imperative, object-oriented, functional, and logic
programming languages;
• program processing (compilation versus interpretation) and preprocessing (macros and inlining);
• different aspects of a variable, including its type, scope, name, address, memory location, and value.
More specific features of programming languages and programming issues are explored in cooperation with
the four selected languages. Students are expected to have understood and be able to
• write C programs with complex data types, including pointers, arrays, and generic structures, as
well as programs with static and dynamic memory allocation;
xi
• apply the object-oriented features such as inheritance and class hierarchy, polymorphism and
typing, overloading, early versus late binding, as well as the constructors, the destructor and the
management of static memory, stack, and heap in C++;
• apply the functional programming style of parameter passing and write Scheme programs requiring
multiple functions;
• apply the logic programming style of parameter passing, write Prolog facts, rules, and goals, and
use multiple rules to solve problems;
• be able to write programs requiring multiple subprograms/procedures to solve large programming
problems;
• be able to write recursive subprograms/procedures in imperative, object-oriented, functional, and
logic programming languages.
The text has been revised and improved throughout in each of the new editions. In the second edition, the
major change made was the inclusion of programming in Service-Oriented Architecture (SOA). Since the
publication of the first edition in 2003, SOA programming has emerged as a new programming paradigm,
which has demonstrated its strength to become a dominating programming paradigm. All major computing
companies, including HP, IBM, Intel, Microsoft, Oracle, SAP, and Sun Microsystems, have moved into
this new paradigm and are using the new paradigm to produce software and even hardware systems. The
need for skill in SOA programming increases as the deployment of SOA applications increases. This new
SOA paradigm is not only important in the practice of programming, but it also contributes to the concepts
and principles of programming theory. In fact, SOA programming applies a higher level of abstraction,
which requires fewer technical details for building large software applications. We, the authors of this book,
are leading researchers and educators in SOA programming. The inclusion of the new chapter on C# and
SOA programming makes the text unique, which allows teaching of the most contemporary programming
concepts and practice. The new chapter also gives professors a new component to choose from, which adds
flexibility for them to select different contents for different courses. As SOA has developed significantly in
the past 10 years, this chapter is also updated in the fourth edition to include an introduction to Silverlight
animation, phone application development, cloud computing, and big data processing.
In the third edition, we completely rewrite Chapter 5. We also discuss the modem applications of Prolog in
the semantic web (Web 3.0) and its relationship with the currently used web semantic languages RDF
(Resource Description Framework) and OWL (Web Ontology Language). Semantic web is considered the
next generation of web that allows the web to be browsed and explored by both humans and computer
programs. In the third edition revised print, this chapter is further expanded with the latest computing
technologies in cloud computing and big data processing.
Since the publication of the second edition in 2006, the programming environment for Chapter 4, on
Scheme, has been changed from DrScheme to DrRacket. The change does not affect the examples in the
text. They all work in the new DrRacket environment, except certain notational issues. We have updated
Chapter 4 to match the changes made in DrRacket.
As parallel computing and multithreading are becoming more and more important in software development,
the third edition adds a new section on parallel computing and multithreading in C++, in Chapter 3. A
MapReduce example is used as a case study for explaining multithreading in C++. The parallel computing
concept is also emphasized in Chapter 4, where the eager evaluation and higher functions Map and Reduce
are linked to parallel computing.
In the fourth edition, we added a number of new sections and many examples throughout Chapters 1, 2, 3,
4, 5, and 6 to explain the more difficulty concepts. In Chapter 1, macro expansion and execution are
explained in more detail and the order of executions are discussed and showed on different programming
environments. More complex examples of syntax graphs are given in Section 1.2. In Chapter 2, structure
padding is discussed in Section 2.5. The file operations in Section 2.6 are extended. More recursive
xii
examples are given in Section 2.7. A case study that puts a11 together is given in a new section at the end of
the chapter. In Chapter 3, a new subsection on memory leak detection is added in Section 3.3 on memory
management. Section 3.4 on inheritance is extended with a new subsection on type casting. A new section
on C++ file operations is added as Section 3.5. In Chapter 4, the application of filtering in query languages
is added in Section 4.9. In the new editions, Chapter 5 is further extended to include web application and
phone application development in C#. It also extends the discussions to cloud computing and big data
processing.
In the fifth edition, changes and revisions are made throughout the book. In Chapter 2, more data structures
are discussed, including doubly linked list, graphs, and trees. Chapter 3, Object-Oriented Programming
Language C++, is significantly extended to include inheritance, type casting, function overloading and
operator overloading, and C++ file operations. A new section 3.8 Case Study is included to put together all
the concepts and programming mechanisms learned in this chapter. In Appendix B, tutorials on using GNU
GCC environment and Visual Studio environment to edit and debug programs are added.
This edition of the text is organized into six chapters and three appendices. Chapter 1 discusses the
programming paradigms, principles, and common aspects of programming languages. Chapter 2 uses C as
the example of the imperative programming paradigm to teach how to write imperative programs. It is
assumed that students have a basic understanding of a high-level programming language such as C, C++,
or Java. Chapter 3 extends the discussion and programming from C to C++. The chapter focuses on the
main features of object-oriented programming paradigms, including class composition, dynamic memory
management and garbage collection, inheritance, dynamic memory allocation and deallocation, late
binding, polymorphism, and class hierarchy. Chapters 4 and 5 take a major paradigm shift to teach
functional and logic programming, respectively. Students are not required to have any knowledge of
functional and logic programming to learn from these two chapters. Chapter 6 gives a brief introduction to
C# and service-oriented computing paradigm. A full discussion of the service-oriented computing paradigm
is given in another book by the authors: Service-Oriented Computing and Web Software Integration.
Assignments, programming exercises, and projects are given at the end of each chapter. The sections with
an asterisk(*) are optional and can be skipped if time does not permit covering all the material. Chapters 4
and 5 are self-contained and can be taught independently, or in a different order.
The three appendices provide supplementary materials to the main text. In Appendix A, the basic computer
organization and assembly language programming are introduced. If students do not have a basic computer
science background, the material should be covered in the class. Appendix B starts with basic Unix
commands. If the class uses a Unix-based laboratory environment, students can read the appendix to get
started with Unix. Then the appendix introduces the major programming language environments that can
be used to support teaching the four programming languages, including GNU GCC/G++ for C and C++,
Visual Studio for C and C++, DrRacket for Scheme, and GNU Prolog. Appendix C gives the ASCII code
table that is referred to in various parts of the text.
The text consists of six chapters, which can be considered reconfigurable components of a course. A half
semester course(25-30 lecture hours) can teach from two to three chapters, and a full semester course can
teach four to five chapters of choice from the text. Chapter 3(C++) is closely related to Chapter 2. If Chapter
3 is selected as a component of a course, Chapter 2, or a part of Chapter 2, should be selected as well. Other
chapters are relatively independent of each other and can be selected freely to compose a course.
For a half-semester course, sensible course compositions could include: (Chapters 1, 2, 3);(Chapters 2, 3);
(Chapters 1, 2, 6); (Chapters 2, 3, 6); (Chapters 1, 4, 5); and (Chapters 4, 5). For a full semester course,
sensible course compositions could include: (chapters 1, 2, 3, 4, 5); (chapters 1, 2, 3, 4, 6); (Chapters 1, 2,
3, 5, 6); and(Chapters 2, 3, 4, 5, 6).
I wish to thank all those who have contributed to the materials and to the formation of this text. Particularly,
I would like to thank my colleagues Scott Hazelhurst and Conrad Mueller of the University of the
Xlll
Witwatersrand, and Richard Whitehouse of Arizona State University who shared their course materials
with me. Parts of these materials were used in teaching the programming languages course and in preparing
this text. Thomas Boyd, Joe DeLibero, Renee Turban, and Wei-Tek Tsai of Arizona State University
reviewed the drafts of the text and made constructive suggestions and useful comments. Other instructors
using this text have given me invaluable feedback and improvement suggestions, including Janaka
Balasooriya, Calvin Cheng, Mutsumi Nakamura, and Yalin Wang. My teaching assistants helped me in the
past few years to prepare the assignments and programming exercises; particularly, I would like to thank
Ruben Acuna, Raynette Brodie, Justin Convery, Gennaro De Luca, Garrett Gutierrez, and Kevin Liao.
The text was written and revised while I was carrying out a full university workload. I am thankful to my
family. I could not imagine that I would be able to complete the task without their generous support by
allowing me to use most of the weekends in the past year to write the text.
Although I have used the materials in teaching the programming languages courses at the University of the
Witwatersrand, Johannesburg and at Arizona State University for several years, the text was put together
in a short period of time. There are certainly many errors of different kinds. I would appreciate it if you
could send me any corrections, comments, or suggestions for improving the text. My email address
dedicated to dealing with the responses to the text is <yinong.chen@asu.edu>. Instructors who use the text
can contact the author for instructional support, including lecture slides in PowerPoint format and the
solutions to the assignments.
Yinong Chen
December 2016
XIV
Chapter 1
Basic Principles of Programming Languages
Although there exist many programming languages, the differences among them are insignificant compared
to the differences among natural languages. In this chapter, we discuss the common aspects shared among
different programming languages. These aspects include:
• programming paradigms that define how computation is expressed;
• the main features of programming languages and their impact on the performance of programs
written in the languages;
• a brief review of the history and development of programming languages;
• the lexical, syntactic, and semantic structures of programming languages, data and data types,
program processing and preprocessing, and the life cycles of program development.
At the end of the chapter, you should have learned:
• what programming paradigms are;
• an overview of different programming languages and the background knowledge of these
languages;
• the structures of programming languages and how programming languages are defined at the
syntactic level;
• data types, strong versus weak checking;
• the relationship between language features and their performances;
• the processing and preprocessing of programming languages, compilation versus interpretation,
and different execution models of macros, procedures, and inline procedures;
• the steps used for program development: requirement, specification, design, implementation,
testing, and the correctness proof of programs.
The chapter is organized as follows. Section 1.1 introduces the programming paradigms, performance,
features, and the development of programming languages. Section 1.2 outlines the structures and design
issues of programming languages. Section 1.3 discusses the typing systems, including types of variables,
type equivalence, type conversion, and type checking during the compilation. Section 1.4 presents the
preprocessing and processing of programming languages, including macro processing, interpretation, and
compilation. Finally, Section 1.5 discusses the program development steps, including specification, testing,
and correctness proof.
1
1.1 Introduction
1.1.1 Programming concepts and paradigms
Millions of programming languages have been invented, and several thousands of them are actually in use.
Compared to natural languages that developed and evolved independently, programming languages are far
more similar to each other. This is because
• different programming languages share the same mathematical foundation (e.g., Boolean algebra,
logic);
• they provide similar functionality (e.g., arithmetic, logic operations, and text processing);
• they are based on the same kind of hardware and instruction sets;
• they have common design goals: find languages that make it simple for humans to use and efficient
for hardware to execute;
• designers of programming languages share their design experiences.
Some programming languages, however, are more similar to each other, while other programming
languages are more different from each other. Based on their similarities or the paradigms, programming
languages can be divided into different classes. In programming language's definition, paradigm is a set
of basic principles, concepts, and methods for how a computation or algorithm is expressed. The major
paradigms we wilJ study in this text are imperative, object-oriented, functional, and logic paradigms.
The imperative, also called the procedural, programming paradigm expresses computation by fully
specified and fully controlled manipulation of named data in a stepwise fashion. In other words, data or
values are initially stored in variables (memory locations), taken out of (read from) memory, manipulated
in ALU (arithmetic logic unit), and then stored back in the same or different variables (memory locations).
Finally, the values of variables are sent to the 1/0 devices as output. The foundation of imperative languages
is the stored program concept-based computer hardware organization and architecture (von Neumann
machine). The stored program concept will be further explained in the next chapter. Typical imperative
programming languages include all assembly languages and earlier high-level languages like Fortran,
Algol, Ada, Pascal, and C.
The object-oriented programming paradigm is basically the same as the imperative paradigm, except that
related variables and operations on variables are organized into classes of objects. The access privileges of
variables and methods (operations) in objects can be defined to reduce (simplify) the interaction among
objects. Objects are considered the main building blocks of programs, which support language features like
inheritance, class hierarchy, and polymorphism. Typical object-oriented programming languages include
Smalltalk, C++, Java, and C#.
The functional, also called the applicative, programming paradigm expresses computation in terms of
mathematical functions. Since we express computation in mathematical functions in many of the
mathematics courses, functional programming is supposed to be easy to understand and simple to use.
However, since functional programming is very different from imperative or object-oriented programming,
and most programmers first get used to writing programs in imperative or object-oriented paradigms, it
becomes difficult to switch to functional programming. The main difference is that there is no concept of
memory locations in functional programming languages. Each function will take a number of values as
input (parameters) and produce a single return value (output of the function). The return value cannot be
stored for later use. It has to be used either as the final output or immediately as the parameter value of
another function. Functional programming is about defining functions and organizing the return values of
one or more functions as the parameters of another function. Functional programming languages are mainly
2
based on the lambda calculus that will be discussed in Chapter 4. Typical functional programming
languages include ML, SML, and Lisp/Scheme.
The logic, also called the declarative, programming paradigm expresses computation in terms of logic
predicates. A logic program is a set of facts, rules, and questions. The execution process of a logic program
is to compare a question to each fact and rule in the given fact and rulebase. If the question finds a match,
we receive a yes answer to the question. Otherwise, we receive a no answer to the question. Logic
programming is about finding facts, defining rules based on the facts, and writing questions to express the
problems we wish to solve. Prolog is the only significant logic programming language.
It is worthwhile to note that many languages belong to multiple paradigms. For example, we can say that
C++ is an object-oriented programming language. However, C++ includes almost every feature of C and
thus is an imperative programming language too. We can use C++ to write C programs. Java is more object
oriented, but still includes many imperative features. For example, Java's primitive type variables do not
obtain memory from the language heap like other objects. Lisp contains many nonfunctional features.
Scheme can be considered a subset of Lisp with fewer nonfunctional features. Prolog's arithmetic
operations are based on the imperative paradigm.
Nonetheless, we will focus on the paradigm-related features of the languages when we study the sample
languages in the next four chapters. We will study the imperative features of C in Chapter 2, the object
oriented features of C++ in Chapter 3, and the functional features of Scheme and logic features of Prolog
in Chapters 4 and 5, respectively.
1.1.2 Program performance and features of programming languages
A programming language's features include orthogonality or simplicity, available control structures, data
types and data structures, syntax design, support for abstraction, expressiveness, type equivalence, and
strong versus weak type checking, exception handling, and restricted aliasing. These features will be further
explained in the rest of the book. The performance of a program, including reliability, readability,
writability, reusability, and efficiency, is largely determined by the way the programmer writes the
algorithm and selects the data structures, as well as other implementation details. However, the features of
the programming language are vital in supporting and enforcing programmers in using proper language
mechanisms in implementing the algorithms and data structures. Table 1.1 shows the influence of a
language's features on the performance of a program written in that language.
Readability/
L� Efficiency Reusability Writability Reliability
Simplicity/Orthogonality ✓ ✓ ✓ ✓
Control structures ✓ ✓ ✓ ✓
Typing and data structures ✓ ✓ ✓ ✓
Syntax design ✓ ✓ ✓
Support for abstraction ✓ ✓ ✓
Expressiveness ✓ ✓
Strong checking ✓
Restricted aliasing ✓
Exception handling ✓
3
The table indicates that simplicity, control structures, data types, and data structures have significant impact
on all aspects of performance. Syntax design and the support for abstraction are important for readability,
reusability, writability, and reliability. However, they do not have a significant impact on the efficiency of
the program. Expressiveness supports writability, but it may have a negative impact on the reliability of the
program. Strong type checking and restricted aliasing reduce the expressiveness of writing programs, but
are generally considered to produce more reliable programs. Exception handling prevents the program from
crashing due to unexpected circumstances and semantic errors in the program. All language features will
be discussed in this book.
1.1.3 Development of programming languages
The development of programming languages has been influenced by the development of hardware, the
development of compiler technology, and the user's need for writing high-performance programs in terms
of reliability, readability, writability, reusability, and efficiency. The hardware and compiler limitations
have forced early programming languages to be close to the machine language. Machine languages are the
native languages of computers and the first generation of programming languages used by humans to
communicate with the computer.
Machine languages consist of instructions of pure binary numbers that are difficult for humans to remember.
The next step in programming language development is the use of mnemonics that allows certain symbols
to be used to represent frequently used bit patterns. The machine language with sophisticated use of
mnemonics is called assembly language. An assembly language normally allows simple variables, branch
to a label address, different addressing modes, and macros that represent a number of instructions. An
assembler is used to translate an assembly language program into the machine language program. The
typical work that an assembler does is to translate mnemonic symbols into corresponding binary numbers,
substitute register numbers or memory locations for the variables, and calculate the destination address of
branch instructions according to the position of the labels in the program.
This text will focus on introducing high-level programming languages in imperative, object-oriented,
functional, and logic paradigms.
The first high-level programming language can be traced to Konrad Zuse's Plankalkiil programming system
in Germany in 1946. Zuse developed his Z-machines Zl, Z2, Z3, and Z4 in the late 1930s and early 1940s,
and the Plankalkill system was developed on the Z4 machine at ETH (Eidgenossisch Technische
Hochschule) in Ztirich, with which Zuse designed a chess-playing program.
The first high-level programming language that was actually used in an electronic computing device was
developed in 1949. The language was named Short Code. There was no compiler designed for the language,
and programs written in the language had to be hand-compiled into the machine code.
The invention of the compiler was credited to Grace Hopper, who designed the first widely known
compiler, called AO, in 1951.
The first primitive compiler, called Autocoder, was written by Alick E. Glennie in 1952. It translated
Autocode programs in symbolic statements into machine language for the Manchester Mark I computer.
Autocode could handle single letter identifiers and simple formulas.
The first widely used language, Fortran (FORmula TRANslating), was developed by the team headed by
John Backus at IBM between 1954 and 1957. Backus was also the system co-designer of the IBM 704 that
ran the first Fortran compiler. Backus was later involved in the development of the language Algol and the
Backus-Naur Form (BNF). BNF was a formal notation used to define the syntax of programming languages.
Fortran II came in 1958. Fortran III came at the end of 1958, but it was never released to the public. Further
versions of Fortran include ASA Fortran 66 (Fortran IV) in 1966, ANSI Fortran 77 (Fortran V) in 1978,
4
ISO Fortran 90 in 1991, and ISO Fortran 95 in 1997. Unlike assembly languages, the early versions of
Fortran allowed different types of variables (real, integer, array), supported procedure call, and included
simple control structures.
Programs written in programming languages before the emergence of structured programming concepts
were characterized as spaghetti programming or monolithic programming. Structured programming is a
technique for organizing programs in a hierarchy of modules. Each module had a single entry and a single
exit point. Control was passed downward through the structure without unconditional branches (e.g., goto
statements) to higher levels of the structure. Only three types of control structures were used: sequential,
conditional branch, and iteration.
Based on the experience of Fortran I, Algol 58 was announced in 1958. Two years later, Algol 60, the first
block-structured language, was introduced. The language was revised in 1963 and 1968. Edsger Dijkstra is
credited with the design of the first Algol 60 compiler. He is famous as the leader in introducing structured
programming and in abolishing the goto statement from programming.
Rooted in Algol, Pascal was developed by Niklaus Wirth between 1968 and 1970. He further developed
Modula as the successor of Pascal in 1977, then Modula-2 in 1980, and Oberon in 1988. Oberon language
had Pascal-like syntax, but it was strongly typed. It also offered type extension (inheritance) that supported
object-oriented programming. In Oberon-2, type-bound procedures (like methods in object-oriented
programming languages) were introduced.
The C programming language was invented and first implemented by Dennis Ritchie at DEC between 1969
and 1973, as a system implementation language for the nascent Unix operating system. It soon became one
of the dominant languages at the time and even today. The predecessors of C were the typeless language
BCPL (Basic Combined Programming Language) by Martin Richards in 1967 and then the B written by
Ken Thompson in 1969. C had a weak type checking structure to allow a higher level of programming
flexibility.
Object-oriented (00) programming concepts were first introduced and implemented in the Simula
language, which was designed by Ole-Johan Dahl and Kristen Nygaard at the Norwegian Computing Center
(NCC) between 1962 and 1967. The original version, Simula I, was designed as a language for discrete
event simulation. However, its revised version, Simula 67, was a full-scale general-purpose programming
language. Although Simula never became widely used, the language was highly influential on the modern
programming paradigms. It introduced important object-oriented concepts like classes and objects,
inheritance, and late binding.
One of the object-oriented successors of Simula was Smalltalk, designed at Xerox PARC, led by Alan Kay.
The versions developed included Smalltalk-72, Smalltalk-74, Smalltalk-76, and Smalltalk-80. Smalltalk
also inherited functional programming features from Lisp.
Based on Simula 67 and C, a language called "C with classes" was developed by Bjarne Stroustrup in 1980
at Bell Labs, and then revised and renamed as C++ in 1983. C++ was considered a better C (e.g., with
strong type checking), plus it supported data abstraction and object-oriented programming inherited from
Simula 67.
Java was written by Ja mes Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun
Microsystems. It was called Oak at first and then renamed Java when it was publicly announced in 1995.
The predecessors of Ja va were C++ and Smalltalk. Java removed most non-object-oriented features of C++
and was a simpler and better object-oriented programming language. Its two-level program processing
concept (i.e., compilation into an intermediate bytecode and then interpretation of the bytecode using a
small virtual machine) made it the dominant language for programming Internet applications. Java was still
5
not a pure object-oriented programming language. Its primitive types, integer, floating-point number,
Boolean, etc., were not classes, and their memory allocations were from the language stack rather than from
the language heap.
Microsoft's C# language was first announced in June 2000. The language was derived from C++ and Java.
It was implemented as a full object-oriented language without "primitive" types. C# also emphasizes
component-oriented programming, which is a refined version of object-oriented programming. The idea is
to be able to assemble software systems from prefabricated components.
Functional programming languages are relatively independent of the development process of imperative
and object-oriented programming languages. The first and most important functional programming
language, Lisp, short for LISt Processing, was developed by John McCarthy at MIT. Lisp was first released
in 1958. Then Lisp 1 appeared in 1959, Lisp 1.5 in 1962, and Lisp 2 in 1966. Lisp was developed
specifically for artificial intelligence applications and was based on the lambda calculus. It inherited its
algebraic syntax from Fortran and its symbol manipulation from the Information Processing Language, or
IPL. Several dialects of Lisp were designed later, for example, Scheme, InterLisp, FranzLisp, MacLisp, and
ZetaLisp.
As a Lisp dialect, Scheme was first developed by G. L. Steele and G. J. Sussman in 1975 at MIT. Several
important improvements were made in its later versions, including better scope rule, procedures (functions)
as the first-class objects, removal of loops, and sole reliance on recursive procedure calls to express loops.
Scheme was standardized by the IEEE in 1989.
Efforts began on developing a common dialect of Lisp, referred to as Common Lisp, in 1981. Common
Lisp was intended to be compatible with all existing versions of Lisp dialects and to create a huge
commercial product. However, the attempt to merge Scheme into Lisp failed, and Scheme remains an
independent Lisp dialect today. Common Lisp was standardized by the IEEE in 1992.
Other than Lisp, John Backus's FP language also belongs to the first functional programming languages.
FP was not based on the lambda calculus, but based on a few rules for combining function forms. Backus
felt that lambda calculus's expressiveness on computable functions was much broader than necessary. A
simplified rule set could do a better job.
At the same time that FP was developed in the United States, ML (Meta Language) appeared in the United
Kingdom. Like Lisp, ML was based on lambda calculus. However, Lisp was not typed (no variable needs
to be declared), while ML was strongly typed, although users did not have to declare variables that could
be inferentially determined by the compiler.
Miranda is a pure functional programming language developed by David Turner at the University of Kent
in 1985-1986. Miranda achieves referential transparency (side effect-free) by forbidding modification to
global variables. It combines the main features of SASL (St. Andrews Static Language) and KRC (Kent
Recursive Calculator) with strong typing similar to that of ML. SASL and KRC are two earlier functional
programming languages designed by Turner at the University of St Andrews in 1976 and at the University
of Kent in 1981, respectively.
There are many logic-based programming languages in existence. For example, ALF (Algebraic Logic
Functional language) is an integrated functional and logic language based on Hom clauses for logic
programming, and functions and equations for functional programming. Godel is a strongly typed logic
programming language. The type system is based on a many-sorted logic with parametric polymorphism.
RELFUN extends Horn logic by using higher-order syntax, first-class finite domains, and expressions of
nondeterministic, nonground functions, explicitly distinguished from structures.
6
Discovering Diverse Content Through
Random Scribd Documents
Sohase érezte szellemében ama feszitő erőnek működését, mely
örökké mozog, dolgozik, mely ki készül törni, ki készül áradni s még
rombolni is kész, ha elnyomják s szilárd és szabályos uton való
mozgását meggátolják. Állandóan sohase érezte az alkotásnak s a
lázas munkásságnak szükségét arra a czélra, hogy az emberi
nemzetségnek vagy legalább saját nemzetének értelmi, műveltségi s
szellemi kincseit szaporitsa. Irodalmi foglalkozáshoz nem volt kedve.
Csak olyankor dolgozott, a mikor külső szükség tolta, a mikor
nemzetének közéleti érdeke egyenesen rákényszeritette. Akkor is
azért, mert határtalanul érezte felelősségét s mert emberi és hazafi
kötelességét teljesiteni szempillantásig se habozott.
Elve az volt: a mi kötelesség, azt teljesiteni kell, akár van sikere,
akár nincs.
Iróként irni, irodalmat egyénileg művelni pedig nem egyéni
kötelesség. Az csak különös egyéni hajlam, vagy istennek különös
adománya. A nemzet iróit tiszteli és becsüli, az értékes irodalmi
alkotásokért ugy rajong, ugy lelkesül, mint senki más, vagy legalább
senki jobban, de ő maga nem dolgozik, nem alkot. Vagy csak
véletlenül és mellékesen.
Miért? Mi ennek az oka?
A köznapi ész könnyen megfelel erre. Deák Ferencz szerény volt.
Sőt a szerénység mintaképe marad az idők végeig.
Ez a felelet egyszerü is, könnyü is. Sőt többet mondok: még
teljesen igaz is.
De mi hát a szerénység?
Nem akarok bölcselkedni. Arról a szerénységről van szó, mely a
közélet vezető férfiának lehet tulajdonsága. Arról, mely Deák
jellemében egyik főbb alkotó rész.
Deák nem volt hiu. Nem volt nagyravágyó.
A hiuság csak egy és egyféle, csak mértéke más. De már a
nagyravágyás nem egyféle. A mikor Deákról beszélünk, csak nemes
nagyravágyásról lehet szó. Olyanról, melyhez a legszerényebb
férfinak is joga van s melyre törekedni a közélet legszerényebb
férfiának is elvitázhatlan szent kötelessége. A mi nem más, minthogy
a közélet cselekvő férfiának minden munkáját, sikerét és buzgalmát
a kor és a szokás és a társadalom gyakorlata szerint külsőleg is és a
nyilvánosság előtt is teljes elismerésben és méltánylásban
részesitsék. És pedig vagy az állami hatalmak vagy maga a nemzet,
vagy a kettő egyetértve. Ez a nemes nagyravágyás. Erre szüksége
van a közélet emberének. Jövendő munkásságának sikeréhez
szükséges ez.
Más a hiuság!
A hiuság nem egyéb, mint vágy és remény mindenhatóvá lenni.
Én vagyok a legszebb, legerősebb, leggazdagabb,
leghatalmasabb, legszerencsésebb. A ki ezt hiszi magáról: az a hiu.
Ez a hit a hiuság.
Van hiuság, a mely tiszteletreméltó. Van, a mely nevetséges s
van a mely utálatos. Az a kérdés csak: mi a tárgya s mi a mértéke.
A ki hazáját és nemzetét akarja boldogitani s szentül hiszi, hogy
semmi másra, csak arra törekszik; a ki czélját szentnek, eszközeit
okosnak, erejét elégnek és sikerét biztosnak tartja csak azért, mert ő
és nem más vezeti a közügyeket: az is hiu. De hiusága még akkor is
tiszteletreméltó, a mikor nincs igaza s diadal helyett bukás a
végzete.
De a ki csak véletlenül gyült pénzére, ékszerére, pipájára,
bajuszára, piperéjére s efféle haszontalanságokra büszke s minden
nagyravágyása csak effélékre tör: annak hiuságát méltán nevetik az
emberek. S az üres lelkek még jobban nevetik, mint a bölcsek.
A kik oly dolgokra hiuk, melyek sértik az igazságot s a nemesebb
érzést: azok hiusága utálatra méltó.
A hiuság voltaképen nem egyéb, mint az önszeretet. Ha nagy
mértékben megvan: önimádásnak hivják. Ha korlátozni nem lehet:
bűnökre is képes. A minthogy minden erénynek s bűnnek a
legmélyebb és legalsóbb forrása a hiuság.
Megvan az állatokban is, habár igen sokszor nem vesszük észre.
Az életnek és hatalomnak vágya e nélkül gyönge. Nagy tettekre,
rendkivüli dolgokra, halálos hősiségre senki se vállalkozik e nélkül. A
nagy erélyt az erős hiuság szüli.
Deák Ferencz lelkéből hiányzott. Legalább nem volt meg oly
mértékben, mely szükséges lett volna rá is, hazánkra nézve is. S ha
valaki egykor azt a tüneményes államférfit, a kit Deák Ferencznek
neveztünk, egészében birálja meg: kétségtelenül azt fogja mondani:
kevés volt erélye, mert kicsiny volt hiusága. Mulasztott, mert
hazájának nagyobb áldása lehetett volna. A hiuság nagyobb
terjedelme is gyöngeség, melyet talán nem lehet orvosolni, de a
szükségesnél kisebb mértéke is gyöngeség, melyet azonban erős
elszántsággal orvosolni lehet. Ha pedig lehet: akkor kell is orvosolni.
Hiuságának csekély voltában látom az okot arra nézve is, hogy
nem lett iróvá.
Vajjon mit is irt hát Deák?
Irodalmilag is jelentékeny nagyobb művei a következők:
Követjelentése az 1833–36-iki országgyülésről.
Ugyancsak követjelentése az 1830–40-iki országgyülésről.
Két felirata az 1861-iki országgyülés irományai közt.
Végül: Adalékok a magyar közjoghoz. Ezt az 1864. és 1865. közti
télen irta.
Nagyobb munkája nincs több. Alakja és alkalomszerüsége, sőt
tulnyomó részben tartalma után is mind az öt az állami közéletre és
vitás közjogi kérdésekre vonatkozó ugynevezett publiczisztikai mű.
Ezeken kivül vannak beszédei, melyeket Kónyi Manó
bámulatraméltó fáradsággal és gonddal gyüjtött össze. E beszédek
több vaskos kötetre rugnak. Ujabb kiadásából megjelent három
terjedelmes kötet, mely azonban Deák beszédeit csak 1866-ig
foglalja magában. Valószinüleg még negyedik és ötödik kötet is meg
fog jelenni.
Végül ott vannak levelei.
Ezekből 158-at Ráth Mór 1890-ben összegyüjtve kiadott.
Leginkább olyanokat, a melyek már negyven-ötven év óta különböző
lapokban és könyvekben napvilágot láttak s melyeket a kiadó barátai
s ismerősei s Deák egyik-másik rokona bocsátott rendelkezésére.
A levelek értéke nem egyenlő.
Vannak köztük örökbecsü s örök szépségü irodalmi alkotások.
Olyanok, a melyek messze tuláramlanak a közéleti működés
határgátjain s beszáguldozzák a bölcselet és költészet birodalmát.
Ezeket maga Deák is gonddal, figyelemmel, lelkének egész
hatalmával szerkesztette.
De vannak e levelek közt alkalomszerüek s tartalmuk szerint
teljesen jelentéktelenek is.
Vajjon ennyi levele volna csak Deáknak?
Nem.
Deák 1856. évi januárban azt irja sógorának Oszterhuber
Józsefnek, a hó egyik napjáról: most végeztem be nyolczszázadik
levelemet, melyet a Vörösmarty-árvák érdekében irtam, de hiszem,
lesz is sikere.
Nyolczszáz levél és csupán csak egy ügyben!
Ebből a nyolczszázból alig kettőt-hármat vett föl gyüjteményébe
Ráth és Ráth gyüjteménye mégis testes nagy kötet.
E levelek közt sok a nagyon szép, sok a valódi remek. Deák
Ferencz esze és irói lángelméje fejti ki ezekben azt a kérdést: mije
volt Vörösmarty a magyar nemzetnek s mivel tartozik nagy
költőjének művelt és nagy nemzet?
Maguk a kérdések is szépek és gazdagok.
Hol vannak a levelek?
Sok százat valószinüleg sohase látunk belőlük. Keletkezésük óta
innen-onnan fél század eltelt már. Nagy idő arra, hogy a levelek nagy
része biztosan elkallódjék. Sok száznál azt se tudjuk, kihez voltak a
levelek intézve, tehát még csak nem is kereshetjük őket biztos
nyomon. A véletlenre vagyunk utalva: mennyi lát ezekből valaha
napvilágot?
Kónyi Manó barátomnál kell lenni egy csomónak. Nem
kérdeztem, nem is mondta, de csaknem biztosan tudom. Hiszen
több, mint egész évtizedre terjedő kutatásai közben ezekből is
kétségtelenül jutott kezébe igen sok. S a mikor ő kutatott Deák
művei után, akkor még nem is közel ötven év, hanem annak csak
fele választott el Vörösmarty halálától.
De még ezeken túl is sok százra vagy talán több ezerre is
emelkedik Deák leveleinek száma. Ráth gyüjteménye az 1822-ik
évvel kezdődik s utolsó leveleit 1875-ben irta. Irt hát ötvenhárom
éven keresztül. Ha minden héten csak egyetlen levelet is irt,
leveleinek száma közel háromezerre rug. Jó tizenöt kötet ez, mely ha
együtt volna, egyéniségének, családjának, vármegyéjének s
nemzetének történetét több, mint félszázadra világitaná meg.
S mennyi irodalmi kincsünk lenne ezekben!
Azonban hetenkint többet irt egy levélnél.
Antal bátyját például és sógorát, Oszterhubert, rendszeresen
értesitette Pozsonyból az országos és fontosabb személyi dolgokról.
Bátyját 1833-tól 1842 közepéig, sógorát pedig 1833-tól a téli
hónapokban 1868 végéig.
A bátyjához irt levelekből nem sok maradt meg. Bátyja ugyan
gondosan őrizte ezeket, de halála után Deák Ferenczre szálltak, a ki
ezeket utóbb mind elégette. De azért valami módon megmaradt egy-
két darab, valamint a sógorához intézettekből is az 1848 előtti
időkről több mint tiz darab.
Mindezek sohase láttak napvilágot, de biztos kézben vannak.
Láttam s átnéztem őket. Egykor közkincscsé fognak válni. Tartalmuk
rendkivül becses. Olyan, mint Wesselényi Miklóshoz s Kossuth
Lajoshoz irottaké Ráth gyüjteményében.
Természetes, hogy nemcsak Antal testvérével és nemcsak
sógorával levelezett. Jozéfa testvérével s annak nagyszámu
gyermekeivel s unokáival is állandó s rendszeres levelezésben volt
serdülő kora óta 1875-ig. Hány száz levél volt s talán van ma is ezek
birtokában!
Ott vannak anyai rokonai s közelebbi és távolabbi barátai,
zalavármegyei benső jó ismerősei, tanulótársai s vármegyei
tiszttársai és az idegenek! Ezerféle magándolgaikban fordultak
hozzá. Köszöntők, üdvözletek, családi ünnepről vagy gyászról szóló
jelentések, kérelmek, esedezések tömegesen jöttek hozzá naponkint.
Kivált 1861 óta, leginkább pedig 1867 eleje óta!
Deák figyelmes volt, udvarias, sőt előzékeny a levélirásban. Felelt
mindenkinek a levelére mindjárt. A felelete a dolog természete
szerint rövid vagy hosszu, de mindig kimeritő volt. S élemedett, sőt
öregedő korában még gondosabb volt a levélirásban, mint az ifjukor
mulatságai közt.
Hova lettek a levelek?
Ráth gyüjteményében öt százaléka sincs meg ezeknek.
Deáknak jó csomó levele van az én birtokomban. Sajtó alá még
nem került. Minden levél tartalma – kevés kivétellel – magándolog.
De Deák irta: ez teszi közérdeküvé. Ha egyebet nem, Deák
egyéniségét közelebb hozzák hozzánk a levelek. Deák egyéniségének
tökéletes ismerete pedig a nemzet történetéhez tartozik.
Azonban maradjunk szorosan a kérdés mellett: miért nem
dolgozott többet Puszta-Szent-Lászlón?
Nézzük csak erre nézve saját felfogását. Nem mondom, hogy az
ő felfogását tökéletesnek kell elfogadnunk, de azért az mégis igen
fontos.
1827. évi október 16-án azt irja Vörösmarty Mihálynak:
»Én fenn repdeső gondolataidat kövérségemből eredett lelki
lomhaságom miatt elérni képes nem vagyok.«
Egy-két nap különbséggel épen akkor volt Deák huszonnégy
éves.
Huszonnégy éves életkorban épen befejezi növését a férfi. Az
ifjuságnak akkor áll tetőpontján. Erejének teljessége akkor van meg.
Aztán kezdődik a férfikor. A lélek is akkor a legtökéletesebb s
érzésekben, ábrándokban, sőt még gondolatokban is a
leggazdagabb. Felfogása gyors, tiszta, éles.
De hát Deák már huszonnégy éves korában kövér lett volna?
Igaz: vannak kövér ifjak, de kevés számban. A huszonnégy éves
ifju rendszerint nyulánk, karcsu, se nem kövér, se nem sovány
szokott lenni.
Bátyja Antal csaknem ugyanez időben, 1827. évi május 30-án irja
Pozsonyból sógorának:
»Klárit, Ferkót ezerszer csókolom s jó egészséget kivánok nekik.
Ferkó ugyan ebben nem szenved szükséget, mert hallom, egyre
hizik, de Klárinak – gondolom – sokat kell kivánni, hogy legalább
valamit is kapjon belőle.«
Tudniillik az egészségből és hizásból.
Maga Deák azt mondja 1827-ben, hogy kövér volt, Antal bátyja
pedig ugyanakkor azt mondja, hogy Ferkó öcscse egyre hizik. Két
tanu s mindkettőnek szava szentirás. Kétségtelen tehát, hogy Deák
Ferencz már 1827-ben kövér volt.
De Deák azt is irja Vörösmartynak, hogy ő lelki lomhaságban
szenved s hogy ennek oka kövérsége.
Kétségtelen, hogy Deák ezt szentül hitte, mert az élet folyamán
át e nézetét többször kijelentette. De hát lomha volt-e lelkileg? És
csakugyan a kövérség okozta-e a lelki lomhaságát?
E kérdésekre nem mernék jóváhagyólag felelni. Hogy lelkileg
nem volt lomha: erről később még szólok majd. S hogy a kövérség
okoz-e lelki lomhaságot: erre se lehet könnyedén felelni.
A kövérség mértékét és természetét mindenesetre figyelembe
kell venni. Egészséges-e a kövérség vagy beteges s mily foku: ez a
kérdés.
Én Deákot mintegy ötven éves korától kezdve ismertem, tehát
több mint husz éven át jól ismertem, mert jól megfigyeltem. Utolsó
éveit kivéve bizony nem beteges, hanem igen is egészséges volt az ő
kövérsége. Széles váll, hatalmas csontok, zömök termet, nagy
koponya: sok izmot követel.
Mi volt testének sulya: nem tudom. Nem hiszem, hogy 105
kilónál utolsó halálos betegsége előtt többet nyomott volna. Ha
csakugyan ennyit nyomott, legföljebb 15 kilót vehetünk
kövérségszámba. Ez pedig, nem nagyfoku kövérség. A 15 kilón felüli
izom és zsir nagyon jól áll oly hatalmas csontozaton, a milyen
Deáknak volt.
Hogy ifju korában nem nyomott ennyit se: kétségtelennek
tartom. Hiszen harmincz éves korában Pozsonyban Wesselényi báró
után a legizmosabb, legerősebb férfi volt az országgyülés tagjai közt.
Ha kövérsége nagyfoku vagy beteges lett volna: ily erőssé, izmossá
semmi esetre se válik. Arczképe, az első, harminczhét éves korából
való s ez az arczkép, nyak és váll semmikép se mutat nagy
kövérséget.
De a nem nagy foku és az egészséges kövérség önmagában nem
is okoz lelki lomhaságot. Biztosan tudom magamról. Én 58 éves
koromban kezdtem meglehetős nagy foku kövérséggel irodalmi
műveket rendszeresen irni s azóta, legalább eddig, sokkal nagyobb
munkakedvem van, mint azelőtt, a mikor pedig soványabb voltam.
Hallgassuk meg azonban Deák tanubizonyságát későbbi időről is.
Azt irja 1846. évi szeptember hó 12-én Wesselényi Miklós
bárónak:
»Bajom sokféle változásai s ezer alaku tünetei között
legnehezebb viselnem azt, hogy kedélyem általában levert, munkára
rest és tehetetlen vagyok, részvétlen, örömtelen s néha ok nélkül is
ingerült. Ha ezen lelkiállapot nálam tartós leend, a politikai tér
előttem el lesz zárva, mert hasznavehetetlen leszek.«
E levelében a restség oka gyanánt már nem a kövérséget emliti,
hanem az általános kedvetlenséget, mely valami idegességből
származik.
A következő évben, 1847. évi január hó 26-án, ugyan Weselényi
báróhoz irja:
»Attomyr… megtiltott minden fejbeli munkát, minden irást s még
a komolyabb olvasást is. Most tehát csak paraszt ember vagyok s
nagyapáink módjára könyv és toll nélkül élem le napjaimat.«
Ez az Attomyr orvos volt Pozsonyban, még pedig, ha nem
csalódom, homeopatha orvos. Ezzel Pozsonyban ismerkedett meg
Deák az 1839-iki országgyülésen s gyakran folyamodott azóta hozzá.
Ime, a munkátlanság oka itt már idegesség és orvosi rendelet. A
mult század negyvenes éveiben 1843-tól kezdve sokat betegeskedett
Deák egészen 1848-ig. Betegségének eredetéről alig hihető
hagyományt ismerek, melyet, ha sor kerül rá, másutt beszélek el.
Mindez még nem Puszta-Szent-Lászlón töltött nyaraló éveire
vonatkozik. De már azokra vonatkozik az a levele, melyet 1862-ik évi
május hó 3 án Lónyay Menyhérthez intézett. Ebben ezt irja:
»Te fiatal vagy és erőteljes, karcsu, mozgékony, tevékeny és
szorgalmas, én pedig vén vagyok és vastag és lusta.«
»Te szeretsz gondolkozni és dolgozni, én pedig nem szeretek és…
rövid időn elutazom, falun pedig sem irni, sem olvasni, sem
gondolkozni nem akarok.«
Bizonyos pajzánság van e levélben is, mint abban, melyet 1827-
ben Vörösmartyhoz intézett. Szóról-szóra egész komolyan nem
szabad vennünk. A mikor irta, még nem volt Deák egészen hatvan
éves. Az a szava pedig, hogy falun se irni, se olvasni, se gondolkozni
nem akar, épen nem azt jelenti, hogy nem is tud s nem is fog. Csak
azt jelenti, hogy nem akar, tehát ha ok és ösztönző alkalom nincs rá,
nem is fog. De itt megint hivatkozik kövérségére, vastagságára.
Bővebben ir erről Vachott Sándornéhoz 1862. évi julius hó 19-én.
»Minden embernek van valami szenvedélye, mihez ragaszkodik.
Ilyen szenvedély nálam az, a mit uri társalgásban kényelmességnek
neveznek, a mit a keresztény anyaszentegyház a hét főbűnök közé
sorolt, a minek valóságos magyar neve: restség. E szenvedélyem
félszázad óta daczol mindennel, magam akaratával, mások
neheztelésével. Sokat küzdöttem ellene sikertelenül, most már
felhagytam a küzdéssel s azóta békében élünk egymással.«
Tehát a restség! Maga Deák komoly és pajzán leveleiben a
restség szenvedélyének tulajdonitja munkátlanságát. Maga Antal
bátyja is sokszor emlegeti sógorához intézett leveleiben, hogy Ferkó
öcscse ritkán ir, röviden irja leveleit, mert ismert commoditása nem
engedni, nem is türi a serénységet. A commoditás pedig magyarul
azt jelenti: kényelmesség.
Nagyon nehéz e kérdésben végleg dönteni.
Talán igaza volt Deáknak, hogy ő gyakran rest és kényelmes volt
akkor is, mikor a betegség nem bántotta. De bizonyos, hogy gyakran
nemcsak serényen végezte a munkát, hanem alig hihető óriási erővel
és szorgalommal is.
Csak egy-két példát hozok fel.
Vörösmartyt 1855. évi november 21-én temették el. Az özvegy
Deákhoz fordult a vagyontalanul maradt család érdekében. Deák
fölkarolta a nagy költőnek, legjobb, legbensőbb barátjának ügyét.
Elfogadta a kiskoru gyermekek gyámságát és gondnokságát.
Nemzeti adományt szánt az árváknak. E végből fölkereste a
teljhatalmu kormányzót, Albrecht főherczeget. Ez ridegen
elutasitotta. Azután az akadémia utján fordult a kormányzóhoz.
Ennek se lett sikere. Akkor kapta magát és magánuton barátjaihoz
irt levelet a nemzeti adomány tárgyában.
1856 évi január közepéig nyolczszáz levelet irt. A napot pontosan
nem tudom, de mindenesetre január 20-ika előtt kelt az a levele,
melyben sógora előtt a nyolczszáz levélről emlitést tesz.
Most tegyünk egy kis számitást.
Bizonyos, hogy deczember 1-e előtt nem kezdhette meg
levelezését. Hiszen a Vörösmartynéval, az Albrecht főherczeggel s az
akadémiával való tárgyalás november 22-től a temetés utáni naptól
kezdve a hónap végéig 30-ikáig okvetlenül eltartott.
Deczember 1-től január 20-ig 51 nap. Közbeesik a Karácsony és
uj év s legalább 7–8 vasárnap. Száz üdvözlet, látogatás, levél,
felhivás s egyéb tennivaló éri Deákot, ha elzárkózik is lakásán. És 51
nap alatt mégis megir és postára ad nyolczszáz levelet. Tehát
naponkint irni kellett 15–16 levelet.
S milyen leveleket!
Ráth gyüjteménye ez időről csak három levelet közöl. Kettőt gróf
Mikó Imréhez, egyet pedig Horvát Pius apátplébánoshoz. Egyik
rövidebb, másik hosszabb.
A nyolczszáz levél mindegyike nem egyenlő nagy. Tartalmuk egy
tárgy körül mozog, de valamennyié szép és gondos. Soknak tartalma
szórul-szóra ugyanaz. Ezek szövege idegen kéz irása. Csak az aláirás
Deáké. Soknak tartalma hosszu. Ezeket maga Deák egészben
sajátkezüleg irta.
Naponként 15–16 levél! S nemcsak egy-két napon, hanem
egyfolytában ötven vagy ötvenegy napon át!
Lelki lomhaság ez? Restség, lustaság, dologtalanság ez?
Ott van például még az 1861-iki országgyülés második felirata. Ez
augusztus 6-án már készen volt, mert 7-én Deák megmutatta egy
bizottságnak. Julius 23-ika előtt Deák nem kezdhette meg készitését,
mert csak előző napon terjesztette az elnök az országgyülés elé azt a
királyi leiratot, melyre felelet volt a második felirat. Julius 23-tól
augusztus 6-ig tizenöt nap.
A felirat több mint százezer betüből áll. Mennyi ez? A
nagyközönség erre világosan nem tud magának megfelelni. Nyujtok
némi tájékozódást.
Hirlapjainkban a szokott nagyságu, nem rövid és nem épen
hosszu vezérczik 4500 betüt foglal magában, a jó nagy szokásos
tárcza pedig kétszer annyit, legfölebb tizezer betüt. Az a felirat tehát
akkora, mint 23 szokásos vezérczikk vagy 11–12 tárcza. S Deák ezt
megirta tizenöt nap alatt.
Azonban országgyülési felirat és vezérczikk két különböző dolog.
A vezérczikket gyakorlott iró könnyen és gyorsan irja, 4500 betüs
vezérczikkhez elég két órai idő. A szavakat, mondatokat,
meghatározásokat, kijelentéseket nem kell különös gonddal
megválogatni és szerkeszteni. A vezérczikk czélja csak az, hogy az
olvasó egyszer elolvassa s okulást, mulatságot vagy értesülést, vagy
tájékozódást szerezzen belőle rövid időre.
A felirat diplomatikai okirat. Abban az egész országgyülés
többsége fejti ki nézetét a törvényekről, a törvényhozási szükségek
természetéről s a teendő intézkedések mivoltáról. Az 1861-iki
országgyülés feliratai különösen fontosak voltak. Az egész nemzet
várakozása s Európa szeme fügött azokon. Egyetlen szót vagy
meghatározást se volt szabad abban elhibázni. A szerkezetnek is
olyannak kellett lenni, mintha kőbe vésték volna az egészet.
Hiszen alapokirat volt. Jelentősége a nemzet történelméhez
tartozik.
S Deák mégis elkészitette tizenöt nap alatt.
Kisértse meg ezt a munkát akárki. Nem beszélek arról, hogy
hasonló fontos és magasztos művet tud-e más alkotni, maga az
anyagi munka óriási.
Ez bizony nem restség, nem lelki lomhaság.
Nem is volt Deák rest, akármiként állitja leveleiben. Több példa is
áll rendelkezésünkre. Például követjelentése az 1833–1836-iki
országgyülésről. Ez még nagyobb s talán magának Deáknak is még
nehezebb munka volt. S bámulatraméltó szorgalommal és
buzgósággal ezt is gyorsan szerkesztette.
Deák jellemvonása más s nem a restség. A szereplés után való
vágy s a hiuság tulságosan szerény mértéke. Ez vonul végig egész
életén, a hogy ezt az életet ismerjük.
S még egy más fontos érzés. A természet szeretete, a természet
szépségein való álmodozás.
Kölcsey azt vette észre Deák Antal arczán, hogy abban a
férfiuban költő lakik. Kölcseynek igaza volt. Deák Antal csakugyan
költő volt s irodalmi alkotásai csakugyan voltak. Leveleiben ugyan
kevés költői száguldozást látok, de azért ilyet is látok. A komoly és
vidám dévajságnak, melyet az irodalom humornak nevez, ő épen
annyira mestere volt, mint a haza bölcse. Sőt még talán jobban is. A
természet szépségei a törvényhozás mezejéről őt is mindig vonzották
haza. 1826-ik évi november hó 10-éről Deák Ferenczhez e sorokat
irja az országgyülésből:
»Itt vagyok tehát ismét Pozsonyban, de elgondolható kedves
öcsém, hogy a hol a csendes édes nyugodalmat a görcsös köveken
zörgő hintóknak robajja; az eke után halkan ballagó béresnek
perdölő füttyét a zsibongó sokaság riasztó lármája, s a kényén
legelésző nyájnak vidám kolompolását az orditó harangok durva
zugása váltja fel: a falusi magányt kedvelő s ujra ismét a mezei
munkához szokott ember minő érzésekre fakadhat? De mit
használnak mindezek a poetikai elragadtatások? Elég az, hogy a sors
mérte ki nekem ezt a sorsot s ugyan a sors adhat is más sorsot. Ez
az én mostani rendeltetésem!«
Költő léleknek minő valódi felsóhajtása ez?
Irt regéket. Nem is hiszem, hogy nem belső barátjának, Kisfaludy
Sándornak vagy Berzsenyi Dánielnek példája buzditotta erre. Azt irja
1841-ben sógorának, tartson kéznél 500 forintot is s igy folytatja:
»Pesten levő regéimet ki szeretném nyomtatni, és e végre kellene
legalább is, a mint gondolom, 500 forint.«
Hova lettek vajjon e regék, Deák Antal költői alkotásai?
Hogy a költői verses nyelvvel miként tudott bánni Deák Antal:
nem tudom. Hogy művei értékesek lehettek: szentül hiszem. Nagy
elme, nagy és nemes érzés s a léleknek sok tartalma volt Deák
Antalban.
Gyorsan bekövetkező halála miatt a regék kinyomatása elmaradt.
Valószinü, hogy halála után Deák Ferencz kezébe kerültek a művek,
ő pedig azokat a többi kehidai irattal együtt 1850 után
megsemmisitette. Erről a dologról másutt bővebben irok.
Ime egy kis bepillantás Deák Antal lelkébe. Ez a lélek azonban
megvolt Deák Ferenczben is. Azt irja barátjának, Wesselényi Miklós
bárónak Kehidáról 1839-ik évi junius 27-ről:
»Pozsonyban három nap hosszabb volt, mint itthon hat hét,
pedig bizony ott sem volt időnk unatkozni. Most ismét paraszt ember
vagyok. Bátyám holnap megy Füredre egy hónapot ott töltendő s én
veszem kezembe az eke szarvát. Kerületi ülések helyett a rétre járok,
nem a szavazatokat számlálgatom, hanem a kaszásokat; nem
üzenetekről, hanem a mezei munka czélszerü elrendeléséről
aggódom. Itt nem a rossz válaszok boszantanak, hanem a rossz idő,
mely a munkát hátráltatja s ámbár a déltájban tornyosuló felhők,
mikor sok széna van renden, gyakran aggodalmat okoznak, ez mégis
sokkal kisebb, mint a mit a politikai horizonnak sokszor vészszel
teljes felhői bennünk Pozsonyban támasztottak.«
Ezek Deák Ferencz sorai.
Hogy jobban megérthessük, meg kell mondanom, hogy a kehidai
és söjtöri uradalmakban fő gazdasági ág volt a juhtenyésztés; – a
szénakaszálás tehát a legfontosabb gazdasági munka volt. Kehidán
nyári felhőszakadások alkalmával a Zala vize el is szokta iszapolni és
hordani a renden levő szénát.
1840-ben az országgyülés főkérdése a szólásszabadság sérelme s
Kossuthnak és az ifjaknak bebörtönzése s kiszabaditása volt. E
kérdésben viaskodott az alsó tábla a mágnások táblájával oly hosszu
időn át. A két tábla üzenetekben – nuncziumokban – beszélt
egymással. Erre czéloz Deák az »üzenetek« szóban. »Válaszok« alatt
meg a királyi leiratokat érti.
Kitünik e levélből, hogy a haza bölcse, ha Pozsonyból vagy
Pestről szabadulhatott, nem feküdt neki az irásolvasásnak, hanem
egész nap a réteken, földeken, mezőkön és erdőkben andalgott.
Szerette a természetet. Elmerült a szabad természet szülte
ábrándokban.
Ezért irta Lónyaynak, mint föntebb már idéztem, hogy ő falun se
irni, se olvasni, se gondolkodni nem akar.
Ő is, más is restségnek, lelki lomhaságnak nevezte részint
komolyan, részint dévajul e lelki állapotot.
Pedig nem az volt.
A mezei gazdának, a földes uraságnak őseitől örökölt s
gyermekkorától megerősödött szokása volt. A szabad napnak, a
szabad szellőnek, a zöld és virágos mezőnek, a szabad természetnek
szerelme ez. Álom, ábránd, gyönyörüség, nagy lelkek andalgása,
mint a berekben az éneklő madár röpködése.
Deák dolgozott. Gyakran emberi erőt csaknem felülmuló munkát
végzett. De csak akkor, ha a hazának szentséges érdeke, ha a
közszükség parancsolta. Csak akkor dolgozott, a mikor a munka
kötelesség volt. Akkor se a kövérség, se a kényelmesség, se a
betegség s az idegek ernyedése, se a természet imádása a munkától
vissza nem tartotta.
– – Befejezem munkám e részét.
VIII.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com