没有合适的资源?快使用搜索试试~ 我知道了~
首页Programming Languages: Application and Interpretation
Programming Languages: Application and Interpretation
需积分: 10 67 下载量 66 浏览量
更新于2023-07-08
收藏 1.32MB PDF 举报
This book talks about the analysis, design and implementation of programming languages feature by feature.
资源详情
资源推荐
Programming Languages:
Application and Interpretation
Shriram Krishnamurthi
Brown University
Copyright
c
2003, Shriram Krishnamurthi
This work is licensed under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
If you create a derivative work, please include the version information below in your attribution.
This book is available free-of-cost from the author’s Web site.
This version was generated on 2007-04-26.
ii
Preface
The book is the textbook for the programming languages course at Brown University, which is taken pri-
marily by third and fourth year undergraduates and beginning graduate (both MS and PhD) students. It
seems very accessible to smart second year students too, and indeed those are some of my most successful
students. The book has been used at over a dozen other universities as a primary or secondary text. The
book’s material is worth one undergraduate course worth of credit.
This book is the fruit of a vision for teaching programming languages by integrating the “two cultures”
that have evolved in its pedagogy. One culture is based on interpreters, while the other emphasizes a survey
of languages. Each approach has significant advantages but also huge drawbacks. The interpreter method
writes programs to learn concepts, and has its heart the fundamental belief that by teaching the computer to
execute a concept we more thoroughly learn it ourselves.
While this reasoning is internally consistent, it fails to recognize that understanding definitions does
not imply we understand consequences of those definitions. For instance, the difference between strict
and lazy evaluation, or between static and dynamic scope, is only a few lines of interpreter code, but the
consequences of these choices is enormous. The survey of languages school is better suited to understand
these consequences.
The text therefore melds these two approaches. Concretely, students program with a new set of features
first, then try to distill those principles into an actual interpreter. This has the following benefits:
• By seeing the feature in the context of a real language, students can build something interesting with
it first, so they understand that it isn’t an entirely theoretical construct, and will actually care to build
an interpreter for it. (Relatively few students are excited in interpreters for their own sake, and we
have an obligation to appeal to the remainder too.)
• Students get at least fleeting exposure to multiple languages, which is an important educational at-
tribute that is being crushed by the wide adoption of industrially fashionable languages. (Better still,
by experimenting widely, they may come to appreciate that industrial fashions are just that, not the
last word in technological progress.)
• Because they have already programmed with the feature, the explanations and discussions are much
more interesting than when all students have seen is an abstract model.
• By first building a mental model for the feature through experience, students have a much better
chance of actually discovering how the interpreter is supposed to work.
iii
iv PREFACE
In short, many more humans learn by induction than by deduction, so a pedagogy that supports it is much
more likely to succeed than one that suppresses it. The book currently reflects this design, though the survey
parts are done better in lecture than in the book.
Separate from this vision is a goal. My goal is to not only teach students new material, but to also change
the way they solve problems. I want to show students where languages come from, why we should regard
languages as the ultimate form of abstraction, how to recognize such an evolving abstraction, and how to
turn what they recognize into a language. The last section of the book, on domain-specific languages, is a
growing step in this direction.
Design Principles
• Concepts like design, elegance and artistic sensibility are rarely manifest in computer science courses;
in the name of not being judgmental, we may be running the risk of depriving our students of judg-
ment itself. We should reverse this trend. Students must understand that artificial objects have their
own aesthetic; the student must learn to debate the tradeoffs that lead to an aesthetic. Programming
languages are some of the most thoroughly designed artifacts in computer science. Therefore, the
study of programming languages offers a microcosm to study design itself.
• The best means we have to lead students to knowledge is through questions, not answers. The best
education prepares them to assess new data by confronting it with questions, processing the responses,
and iterating until they have formed a mental model of it. This book is therefore structured more like
a discussion than a presentation. It leads the reader down wrong paths (so don’t blindly copy code
from it!). It allows readers to get comfortable with mistaken assumptions before breaking them down
systematically.
• The programming languages course is one of the few places in the curriculum where we can tease
out and correct our students’ misconceptions about this material. They are often misled on topics
such as efficiency and correctness. Therefore, material on compilation, type systems and memory
management should directly confront their biases. For instance, a presentation of garbage collection
that does not also discuss the trade-offs with manual memory management will fail to address the
prejudices students bear.
Background and Prerequisite
This book assumes that students are comfortable reasoning informally about loop invariants, have modest
mathematical maturity, and are familiar with the existence of the Halting Problem. At Brown, they have all
been exposed to Java but not necessarily to any other languages (such as Scheme).
Supplementary Material
There is some material I use in my course that isn’t (currently) in this book:
preparation in Scheme For the first week, I offer supplementary sessions that teach students Scheme. The
material from these sessions is available from my course Web pages. In addition, I recommend the
v
use of a simple introduction to Scheme, such as the early sections of The Little Schemer or of How to
Design Programs.
domain-specific languages I discuss instances of real-world domain-specific languages, such as the access-
control language XACML. Students find the concepts easy to grasp, and can see why the language is
significant. In addition, it is one they may themselves encounter (or even decide to use) in their
programming tasks.
garbage collection I have provided only limited notes on garbage collection because I feel no need to offer
my own alternative to Paul Wilson’s classic survey, Uniprocessor Garbage Collection Techniques. I
recommend choosing sections from this survey, depending on student maturity, as a supplement to
this text.
model checking I supplement the discussion of types with a presentation on model checking, to show
students that it is possible to go past the fixed set of theorems of traditional type systems to systems
that permit developers to state theorems of interest. I have a pre-prepared talk on this topic, and would
be happy to share those slides.
Web programming Before plunging into continuations, I discuss Web programming APIs and demonstrate
how they mask important control operators. I have a pre-prepared talk on this topic, and would
be happy to share those slides. I also wrap up the section on continuations with a presentation on
programming in the PLT Scheme Web server, which natively supports continuations.
articles on design I hand out a variety of articles on the topic of design. I’ve found Dan Ingalls’s dissection
of Smalltalk, Richard Gabriel’s on Lisp, and Paul Graham’s on both programming and design the
most useful. Graham has now collected his essays in the book Hackers and Painters.
logic programming The notes on logic programming are the least complete. Students are already familiar
with unification from type inference by the time I arrive at logic programming. Therefore, I focus on
the implementation of backtracking. I devote one lecture to the use of unification, the implications
of the occurs-check, depth-first versus breadth-first search, and tabling. In another lecture, I present
the implementation of backtracking through continuations. Concretely, I use the presentation in Dorai
Sitaram’s Teach Yourself Scheme in Fixnum Days. This presentation consolidates two prior topics,
continuations and macros.
Exercises
Numerous exercises are sprinkled throughout the book. Several more, in the form of homework assignments
and exams, are available from my course’s Web pages (where hyeari is one of 2000, 2001, 2002, 2003,
2004 and 2005):
http://www.cs.brown.edu/courses/cs173/hyeari/
In particular, in the book I do not implement garbage collectors and type checkers. These are instead
homework assignments, ones that students generally find extremely valuable (and very challenging!).
剩余375页未读,继续阅读
ZRobinz
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 利用迪杰斯特拉算法的全国交通咨询系统设计与实现
- 全国交通咨询系统C++实现源码解析
- DFT与FFT应用:信号频谱分析实验
- MATLAB图论算法实现:最小费用最大流
- MATLAB常用命令完全指南
- 共创智慧灯杆数据运营公司——抢占5G市场
- 中山农情统计分析系统项目实施与管理策略
- XX省中小学智慧校园建设实施方案
- 中山农情统计分析系统项目实施方案
- MATLAB函数详解:从Text到Size的实用指南
- 考虑速度与加速度限制的工业机器人轨迹规划与实时补偿算法
- Matlab进行统计回归分析:从单因素到双因素方差分析
- 智慧灯杆数据运营公司策划书:抢占5G市场,打造智慧城市新载体
- Photoshop基础与色彩知识:信息时代的PS认证考试全攻略
- Photoshop技能测试:核心概念与操作
- Photoshop试题与答案详解
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功