Programming Languages Principles and Paradigms 2e Allen Tucker Robert Noonan (Solu�ons Manual All Chapters, 100% Original Verified, A+ Grade) All Chapters Solu�ons Manual Supplement files download link at the end of this file.
1 Overview Exercises 1.1Here is a brief summary of the features and historical relationships among
Eiel, Perl, and Python:
(a)\The Eiel Development FrameworkTM is a complete software de-
velopment system, consisting of three major components: the Eif-
fel methodology for creating robust, ecient, and scalable object- oriented software; Eiel, the programming language and compiler that support and enforce the methodology; and EielStudioTM, a seamless, object-oriented software development environment designed for demanding enterprise applications." (from www.eiel.com) Eiel is a proprietary language, so its usage is not free. Eiel's histori-
cal relationships are identied in Figure 1.2: it is an object-oriented
derivative of Smalltalk, originally invented by Bertrand Meyer in the late 1980s.(b)\Perl takes the best features from other languages, such as C, awk, sed, sh, and BASIC, among others. Its database integration inter- face (DBI) supports third-party databases including Oracle, Sybase, Postgres, MySQL and others. It also works with HTML, XML, and other mark-up languages. Perl supports Unicode, as well as both procedural and object-oriented programming. Perl interfaces with external C/C++ libraries through XS or SWIG. There are over 500 third party modules available from the Comprehensive Perl Archive Network (CPAN)." (www.perl.org). Perl's historical relationships
are identied in Figure 1.2: it is an open source language, originally
invented by Larry Wall in the late 1980s.(c)\Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It oers strong support for integration with other languages and tools, comes with 1
21. OVERVIEW
extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code. Python runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm Handhelds, and Nokia mobile phones.Python has also been ported to the Java and .NET virtual machines.Python is distributed under an OSI-approved open source license that makes it free to use, even for commercial products." (from www.python.org). Python's historical relationships are identied in
Figure 1.2: it is an open source language, invented by Guido Van
Rossum in the late 1990s. Many feel that Python is especially well suited for teaching programming to beginners.
1.2There are many examples in C, C++, and Java that are particularly unreadable. For instance, the expressionA[i++]combines a reference to A[i]and a post-increment ofi. It could be split into two expressions to convey these two separate ideas. Here's another unreadable one, which
serves to double the value of anintvariable:x << 1;
1.3a.Algol was designed to be used simultaneously as a teaching language, a publication language, and a language for writing eective programs.For instance, many Algol programs were published in early issues ofCommunications of the ACM, a practice that subjected to the scrutiny of a peer review process that cannot be duplicated by today's languages. None of BASIC, COBOL, or APL had these particular features.b.A middlle-ground interpretation of Flon's statement would suggest that most languages have a long way to go in promoting clarity and correctness of expression. It would simultaneously suggest that many programmers have an equally long way to go in writing code that clearly expresses itself to a trained observer.
1.4In Java, the (overloaded) operator + denotes string concatenation as well as addition is an instance of orthogonality. Operator overloading, however, is not a core feature of Java, as it is in Ada. Other Java operators are generally not overloaded or overloadable.Non-orthogonality is widespread in C, C++, and Java. In C and C++, for instance, string concatenation is done using thestrcatfunction. However, in C++ the display of two strings s and t is written ascout << s << t.
1.5There's a nice summary of the early development of Fortran at
http://www.nag.com/nagware/np/doc/fhistory.asp
This summary mentions some of the in compatibilities between Fortran 66 and Fortran 77. It says, \Notable new features of Fortran 77 were the CHARACTER data type and the block IF (IF - THEN - ELSE - ENDIF). Fortran 77 was not a superset of Fortran 66, having numerous
3 (mostly minor) incompatibilities. For example, the "extended-range DO loop" was completely deleted from the standard." Complete elimination of incompatibilities between two dierent imple- mentations of a language is dicult to achieve. On the whole, however, incompatibilities across implementations are much less frequent or severe for modern languages than they were in the early days of Fortran.
1.6A summary of recent and current activities surrounding C standardization
can be found at http://www.open-std.org/jtc1/sc22/wg14/
Among other activities, this page reports that \The current C program- ming language standard ISO/IEC 9899 was adopted by ISO and IEC in
- Technical corrigenda TC1 and TC2 were approved followingly, TC2
in 2004." 1.7A C++ platform (compiler) is nonconformant if it supports features in a way that is incompatible with the C++ standard. On the other hand, language extensions are features supported by a platform that exceed those dened by the standard (but do not make the compiler nonconfor- mant). Many C++ compilers support extensions to the C++ standard, but are otherwise conformant with it. However, programs that utilize the extensions supported by one compiler may not port to a dierent platform. More information on C++ standardization can be found at
http://www.open-std.org/jtc1/sc22/wg21/ and
http://www.research.att.com/~bs/C++.html
1.8Sun Microsystems, developer of Java, seems to be resisting community eorts to standardize Java, which began in 1997. In April 1999, Sun proposed to formally standardize the JavaTM technology in ECMA (a formal standards developing body within ISO). But on December 7, 1999 Sun issued a press release announcing the withdrawl of its proposal from ECMA.At that time Sun decided to maintain control of all Java standard editions and turned over the community development aspects of Java to its Java Community Process (JCP). Since then, the JCP has made little progress toward developing an international standard for Java. However, Java is now Open Source.
For more discussion of these issues, see Sun's other JCP web pages and:
http://java.sun.com/developer/technicalArticles/Interviews/kluyt
qa.html1.9Since we wrote this question, Python has evolved from version 2.4 to version 2.5. According to the web sitepython.org, the following features
have been added:
1.The 'with' operator replaces the try/nally idiom that results in cleaner and safer code.
2.Generators gained send, throw and close methods. This turns gener- ators into a form of coroutine and makes them even more powerful.