Lecture Programming languages (2/e): Chapter 12b - Tucker, Noonan

In this chapter, we discuss the key features of imperative languages. Next, we focus on the role that function libraries have played. We conclude the chapter by considering three very different languages: C, Ada, and Perl. | Programming Languages 2nd edition Tucker and Noonan Chapter 12 Imperative Programming I really hate this darn machine; I wish they would sell it; It won’t do what I want it to, but only what I tell it. Programmer’s lament (anonymous) Contents What Makes a Language Imperative? Procedural Abstraction Expressions and Assignment Library Support for Data Structures C Ada Perl C “C was originally designed for and implemented on the UNIX operating system on the DEC PDP-11, by Dennis Ritchie. The operating system, the C compiler, and essentially all UNIX applications programs (including all of the software used to prepare this book) are written in C. . C is not tied to any particular hardware or system, however, and it is easy to write programs that will run without change on any machine that supports C.” Influences Multics, PL/I Application: typesetting documentation PDP-11: 16-bit minicomputer; 32 KB memory BCPL: typeless Portability: big-endian vs. little-endian machines Good code from a non-optimizing compiler Hardware support for: ++, --, +=, etc. General Characteristics Relatively low level language Macro facility Conditional compilation Lacks: iterators, generics, exception handling, overloading Assignments are expression; ex: strcpy Dynamic Allocation int *a; . a = malloc(sizeof(int) *size); /* ANSI C: a = (int *) malloc(sizeof(int) *size); C++: a = new int[size]; */ /* deallocation left to programmer */ Ex: Grep #include libraries line 6 is a function signature (or prototype) main processes command line arguments function find reads file search each line write line if match fgets Ex: Average compute min, max, average of a set of numbers formatting: scanf, printf conditional assignment 2nd argument to scanf must be an address caught by some compilers segment violation at run time Ex: Symbolic Differentiation simple calculus formulas no simplification represent expressions using abstract syntax Symbolic Differentiation . | Programming Languages 2nd edition Tucker and Noonan Chapter 12 Imperative Programming I really hate this darn machine; I wish they would sell it; It won’t do what I want it to, but only what I tell it. Programmer’s lament (anonymous) Contents What Makes a Language Imperative? Procedural Abstraction Expressions and Assignment Library Support for Data Structures C Ada Perl C “C was originally designed for and implemented on the UNIX operating system on the DEC PDP-11, by Dennis Ritchie. The operating system, the C compiler, and essentially all UNIX applications programs (including all of the software used to prepare this book) are written in C. . C is not tied to any particular hardware or system, however, and it is easy to write programs that will run without change on any machine that supports C.” Influences Multics, PL/I Application: typesetting documentation PDP-11: 16-bit minicomputer; 32 KB memory BCPL: typeless Portability: big-endian vs.

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.