Table of Contents
- About This Course
- What You'll Need
- Coursework and Grading
- Feedback
- Collaboration and the Honor Code
- Notices
Updated September 2, 2011, to include more Scala resources
Updated October 4, 2011, to provide links to the project requirements.
About This Course
Description
This course explores a surprising concept: programming as language
design. Good programming practice advises us to factor a common operation into
a separate function or method, to be invoked whenever that operation is needed.
A domain-specific language (DSL) takes this idea one step further by factoring
several common operations into their own programming language. Examples include
LaTeX, Kodu, and SQL.
This course systematically investigates why and how a programmer
might create a domain-specific language. Along the way, we will write programs
in many different languages for many different domains. The course will
conclude with a project that asks you to design and
implement your own domain-specific language. You'll never look at programming
the same way again!
Learning Objectives
This course has two broad aims, each with specific objectives:
- Aim 1: To familiarize you with the purpose, design, and
structure of domain-specific languages.
Objectives:
- Compare and contrast the benefits and drawbacks of a
domain-specific language versus a general-purpose language.
- Analyze a domain and identify its semantic model(s) and
linguistic abstractions.
- Implement models of computation as the semantic basis of
several domains.
- Evaluate language design choices, especially syntactic choices
for data and control.
- Aim 2: To give you the opportunity to explore a wide variety
of high-level language-implementation techniques.
Objectives:
- Learn to program in Scala and discuss the properties of
general-purpose programming languages that facilitate the implementation of
DSLs.
- Explore, compare, and contrast techniques for implementing an
internal versus an external DSL.
- Construct artifacts to support DSL users, including
error-handling and semantic tools.
Because DSLs are a powerful and flexible programming tool, we will
explore the topic systematically and thoroughly, building up concepts and code
that should be useful to you in your end-of-semester project and in your future
studies and careers.
Style and Approach
There are a near-infinite number of domain-specific languages. We're not
going to study them all. We're not really going to study the languages per
se. Instead we'll study a certain set of principles and techniques for
designing and implementing languages.
Language design and implementation is both art and science; temperament
and technique. The best way to learn it is by doing it. So, we're going to be
doing a lot of programming. Sometimes we'll spend quite a bit of time
investigating a single domain. The idea is that you'll know the principles we
explore in your bones. By the end of the course, you will have
implemented enough concepts, using a variety of techniques, that you'll have
built up an intuition for language design and implementation that should serve
you well in your future work. The process will be exhaustive and perhaps
exhausting.
We're going to cover diverse topics, and the students in the class have
a diverse set of previous experiences. As a result, at some point during the
semester, it's almost certain that:
- you'll be in over your
head. In this case, don't be afraid to ask for help. You're not alone;
other students will be grateful that you asked the question. Also, it's
probably not the only time we'll see this topic. Don't panic if you don't grasp
it at first. Just ask for help, be patient, and trust that the "aha" moment is
waiting for you.
- you'll be bored.
In this case, I ask that you respect the rest of the students and the course
itself. Help, if asked. Take the opportunity to explore a topic deeper. If
you'd like to do some more exploring (for example, by incorporating something
you learned in Compilers or Programming Languages), but aren't sure how, please
ask me — I'd be delighted to make some suggestions.
- you'll be the class
expert. In this case, you have the responsibility of transferring your
knowledge to the rest of the class. This will certainly be the case for your
end-of-semester project, and we'll all be eager to learn from you.
Your curiosity is your most important trait in this course. It'll
be challenging at times, but above all I hope it'll be fun. There's lots of
room to be creative, to show off, to take risks, and to learn new things.
What You'll Need
Resources
Scala. We'll be doing most of our coursework in Scala. Scala is installed on
knuth, but you'll probably want to install Scala on your own machine.
For the sake of uniformity, be sure to install version 2.8 or later. There a
lots of good resources for
learning Scala on the Scala website.
Books. There are no required books for this course, but there
are a few books that I recommend.
These books will be especially useful in the first several weeks, as
we gain experience programming in Scala:
- *Programming in
Scala, 2nd Edition by Martin Odersky, Lex Spoon, and Bill Venners. In
my opinion, this is the best book by which to learn Scala. It's co-authored by
Scala's creator, Martin Odersky. Artima, the publisher, offers PDF (~$30) and
hardcopy
(~$55) versions. ISBN: 978-0981531601. The first edition is available for
free!
- Programming
Scala by Dean Wampler and Alex Payne. O'Reilly, the publisher offers HTML
(free!), PDF (~$36, ISBN:
978-0-596-80652-1), and hardcopy (~$45,
ISBN: 978-0-596-15595-7) versions.
The following books are useful as references (i.e., to look up
particular topics, rather than to read cover-to-cover). You'll find them most
useful in the second half of the semeseter, as you begin working on your
projects:
- *Language
Implementation Techniques by Terence Parr. ISBN: 978-1934356456. A good
resource for implementing an external DSL, especially if you've already had
Compilers.
- DSLs in Action by Debasish Ghosh. ISBN: 978-1935182450.
This may be useful as your work on your project. It includes extended code
examples in Scala, Ruby, and Clojure.
- Domain Specific
Languages by Martin Fowler. ISBN: 978-0321712943. A good general
reference, with an emphasis on semantic models.
* I will place a copy of the starred books in
B102, for reference, since these will probably be the most useful to
you.
Communication
I will communicate information to you through the course
website and mailing list: cs-181b-l@hmc.edu. If you are enrolled in
the class, you should have been automatically added to the list. You are
responsible for checking the website and making sure that you are receiving
mail that is sent to the mailing list. You should check your mail at least once
a day, to keep up to date on the latest course announcements.
The mailing list is also where you can ask questions of your fellow
students. In particular, as we learn Scala, you may need timely answers to
programming questions. Your fellow students may be the best resource for this.
When writing to the mailing list, be sure not to include information that
violates the collaboration policy.
I will schedule regular office hours after the start of the
semester. I also encourage you to come talk with me any time my door is open,
which it will be whenever I am in my office and not in a meeting. You can also
email me to schedule a specific meeting time.
Coursework and Grading
Your grade in this course will be a combination of:
- Assignments (60%). Assignments will be both in-class
(e.g., quizzes, programming exercises, written responses) and out-of-class
(i.e., typical homework). You will sometimes be asked to work on these
assignments alone and sometimes you may choose to work with a partner. Almost
all of the assignments will require you to spend most of your time programming,
though there will be a few reading + writing assignments. You can expect to
spend 6-9 hours per week outside of class working on assignments. I anticipate
giving at most one assignment per week for the first 10 weeks of class. After
that, you'll be working on your project.
- Project (30%). You will complete one large project that
asks you to design, implement, and evaluate your own domain-specific language.
Though the project is due at the end of the semester, I will provide milestones
and guidlelines throughout the semester, to help you stay on track. I'll be
handing out lots more details — including expectations, grading
criteria, and project suggestions — when the time comes, about a month
into the semester.
- Participation (10%). A course like this one benefits
from lively debate and from our diversity of experience and interests. There
often is no right answer to a problem, so I expect that you will contribute
your opinions and reasoning both in and out of class. I also expect that you
will share your interests: Do you know of an interesting domain or found a cool
DSL? Let us know! During class, I will set aside times for us to discuss these
things. You can also send them to the class mailing list. Participation is a
naturally subjective quality, though it can be measured. I will measure your
participation in part by assigning quick thinking/writing exercises during
class, asking for feedback on assignments, and observing your interactions with
classmates. Half-way through the semester, I will ask you to assess your level
of participation. I will compare my assessment to yours, and if there is a
discrepancy, we will work it out. Rest assured, I want you to succeed. If you
are concerned about your level of participation or how I might perceive it,
please e-mail or visit with me.
Lateness policy
For homeworks, you have a total of four, 24-hour extensions. You can use
at most two extensions for any given assignment. You do not need to let me know
you are using the extensions; I will automatically apply them to any late work.
Please keep track of how many extensions you have used, and if you're unsure,
please ask me. I don't want you to lose credit for using an extension you don't
actually have. There are no extensions for the project deadlines.
Extenuating circumstances (such as illness) are dealt with on a
case-by-case basis. In general, you are only excused for situations you could
not have foreseen, and only if you explain the situation at your soonest
opportunity (either directly or via someone else, such as the Dean of
Students), before the due date. If an extenuating circumstance will
affect your work on the project, you must let me know as soon as you learn
about it.
Feedback
Feedback is an important part of any learning. During this course I will
be asking you to give me feedback on your learning in implicit ways (e.g.,
quizzes and assignments) as well as explicit ways (e.g., "How's the class going
for you?"). This is your class, and I want to make sure you get the most
out of it. Please let me know right away when something we discuss is not
clear. If you don't understand something, chances are that several other
students feel the same way. You are always free to interrupt me — don't
let me get away with glossing over any topic. I also welcome any feedback about
the structure, tone, and nature of this course. I ask that you give me this
kind of feedback outside of class — either in office hours or via email.
If you would like to give me anonymous feedback, you can send anonymous email.
Collaboration and the Honor Code
I expect you to abide by the Harvey Mudd Honor code (see page 17 of the student
handbook). All assignment solutions, code, and project materials should be
produced by you alone, or by you and a partner, where appropriate. You may
discuss algorithms at a high level with any student in the class. You may also
help any student find a small bug in their code. However, you may not copy
solutions from anyone, nor should you collaborate beyond high-level discussions
with anyone who is not your partner. I encourage you to help one another,
especially when learning Scala, but be sure to ask and answer questions in a
way that does not provide solutions to the homework problems.
If you have any questions about what behavior is acceptable, it is your
responsibility to come see me before you engage in this behavior. I am more
than happy to answer any questions you may have.
Notices
Writing Center
The Writing Center
provides a good opportunity for you to get feedback on your project write-up
and presentation. This is a resource that can be helpful to all writers, from
novices to experts, on all kinds of writing. The center is open Sunday through
Thursday evenings from 7-11 and Saturday afternoons from 3-5. It is located in
Parsons 161 in the basement just off the Galileo foyer. You may schedule an
appointment through their website, or you may simply drop in
during normal hours. If you'd like an appointment outside of normal hours, you
may email them with your request.
You are likely to find your writing center visit more valuable if you come
earlier than the night before your final draft is due.
Acknowledgments