General Information
Instructor:
Geoffrey Towell259 Park Science Building
526-5064
gtowell at brynmawr dot edu
http://cs.brynmawr.edu/~gtowell
Class:
Lecture | 9:55 - 11:15 TR | Park 337 |
---|---|---|
Lab | 12:55 - 2:15 Tue | Park 231 |
Office Hours | Monday 10AM - Noon. Thurs 12:01pm-1:01pm Also by appointment |
Park 259 |
Zoom | Meeting code: 232 840 6920. |
Password: given in class |
Course Description |
An introduction to the study of programming languages. Where do programming languages come from and how do
they evolve? And why should a programmer choose one over another? This course explores these topics by
covering programming language features and paradigms, including object-oriented, functional, and imperative.
The course will focus on general structures common to programming languages; focusing on why those
structures exist, the various ways in which those structures are implemented, and how to use them.
In addition, the course will look at programming techniques in two languages new to most students: Go and Rust. |
|
Computer Lab | Park 230 & 231 | Instructions for using the lab
computers Remote accessible lab computer status |
|
|
Text
Important Dates
- Sep 5, First class
- Oct 12, first midterm
Instructions for 2023 Midterm 1
questions from midterm1 of 2021
Answers for midterm1 of 2021
Answers for midterm1 of 2022 Note that these are student answers that got full marks (and were typed). This does not mean that the answers were perfect or even error free. - Nov 16, Second Midterm Some practice questions for second midterm from 2021 (where you see "kotlin", read "Rust")
- Answer for Rust.
- Translate to Rust and answer
- No adjustment
- skip entirely
- answer just for Rust. Ignore Dijkstra.
- use Rust
- skip
- use Rust
- Exam period, Final Exam
Some sample questions. Note that these questions are of the form you might see on the final, but they are questions that I rejected from the final. (Where you see "kotlin", read "Rust")
Final from 2021 The following translations should make the questions apply to this year- Q3. There is not a good translation.
- Q6. There is not a good translation.
- Q7. Substitute Rust for Kotlin
- Q9. Substitute Rust for Kotlin
- Q10. Substitute Rust for Kotlin
The second midterm from 2021 This test focused on functional programming in Kotlin which is a very different language than Rust. You should make the following adjustments to the numbered question. Indeed, while Rust can be written in a functional style, that will not be the emphasis of the Rust discussions
Assignments
There will be homework assignments approximately every other week. Homework will be electronically submitted. The homeworks will typically be small programming problems that are linked to class discussion. Programming is expected to take less than 5 hours per week (on average).All assignments must be turned in on time. If there are compelling reasons why you cannot turn in an assignment on time, you must ask for permission at least 48 hours in advance of the due date.
Despite my best efforts, homeworks may have sections that are not quite correct. If you find an error, let me know. If I agree that the issue is an issue and you have told me of the issue at least 48 hours prior to the due date then I will give bonus points as follows:
3 points for the first issue reported 2 points for the second issue reported 1 point for the third issue reportedOrdering is based on date of email receipt. One bonus per person per assignment.
All programming assignments must abide by the standards set forth here Design Principles Posted code samples will -- almost always -- adhere to these standards. To the extent the code samples do not, it will almost always be in the are of naming of variables. I can be lazy and I write a lot of code (most of which you do not see). (Code shown in class may not adhere to these principles, usually in the interest of brevity.)
All programming assignments must be accompanied by a README file. I will read, and often will respond, to all README text. See the file for a description of the expected contents.
- Homework 0 (ish) watch at least the first 30 minutes of The worst programming language ever. Bring "- one statement that you did not understand or thought was really funny" to class on Sep 12.
- Homework 1 Due Sep 12, before 11:59:59pm
- Homework 2 Due Sep 26, before 11:59:59pm
- Homework 3 Due Oct 26, before 11:59:59pm
- Homework 4 Due Nov 9, before 11:59:59pm
- Homework 5Due Nov 30, before 11:59:59pm. This need only include solutions for problems 3-6.
- Homework 6 Due Dec 14, before 11:59:59pm
Labs
Labs will often look like programming assignments, just smaller. All labs can be done on the CS department lab machines or on personal machines (assuming you have installed the appropriate software.)- Lab 1: Sep 5. Access and Login.
- Lab 2: Sep 12. factors from prime factors (and other things) in Java
- Lab 3: Sep 19. Go Practice
- Lab 4: Sep 26 Sorting and implementing interfaces in Go
- Lab 5: Oct 3Go Packages For my program, I go the following results
UNIX% go run candy.go 100 The average of candy bought to collect all cards is 516 UNIX% go run candy.go 500 The average of candy bought to collect all cards is 3402 UNIX% time go run candy.go 35 The average of candy bought to collect all cards is 144 9.88s user 0.58s system 103% cpu 10.122 total
The final run shows the CPU time taken my my program for 1 million trials of my program on my Mac - Pre-Midterm Lab
- Lab 6: Oct 24 Go and JSON
- Lab 7: Oct 31 Rust
- Lab 8: Nov 7 Rust and Ownership
- Lab 9/10: Nov 21 Iterators in Rust
Lectures
This course is intended to be fairly free-flowing with a lot of discussion. Therefore, I will not normally publish powerpoint lecture notes. I will try to restrict my commentary to topics covered in the text.
- Sep 5: Introductory remarks.
- powerpoint slides
- hello world in go
- hello world in rust
- counting unique "words" in Go.
- Watch at least the first 30 minutes of The worst programming language ever. Bring "- one statement that you did not understand or thought was really funny" to class on Sep 12.
- Sep 7: Scott 1.1-1.4
- Topic 3, Programming in Go
- rough notes
- Hello World
- Definite assignment in Java
- pass by value
- tuple assignment and functions
- fibonacci and if and loops
- arrays in Go
- slices
- slices
- structs in Go
- binding methods to structures
- function bining to classes in Java
- ++ expression in Java
- NO ++ expression in Go
- command line args
- Money types, methods and toString
- unused example more with slices
- unused example structs, structs inside structs
- Topic 4, Names, Scopes and Bindings. Ch 3 from Scott (not 3.4)
- rough notes
- Static declaration of Integers in Java
- Dynamic Method dispatch in Java
- Static Method dispatch in Go
- java recursion depth Testing recursion depth with Java is an exercise in frustration. The same code, with all the same settings can show changes by a factor of 2 between runs.
- go recursion depth See notes at top of program
- tail recursion in Go Althought he Go compiler does not implement TR (at least not in 2023)
- variable lifetimes in Go
- block nesting in Go
- function nesting in Go
- aliases in Go. More than one reference to same object.
- Pair of classes resulting in hiding in JavaAAAB
- Closures in Go
- Object Closures in Java
- Linked list in Go
- Topic 5:
Control Flow Chapter 6 in Scott
- rough notes
- Order of eval of passed params in Go
- slices and pointers in Go
- pointers in Go
- pointers in function calls in Go
- null pointers in Go
- Swift: a language with NO null pointer exceptions
- Definite assignment in Java
- labelled breaks
- the switch statement in Go
- switch in Java
- Tail recursion
- Covariance and java arrays
- intro to covariance
- Covariance and java generics
- Topics 6:
Functional Programming
Chapter 11 in Scott- rough notes
- Basic lambda expressions in Java
- Lambda Expressions for Sorting in Java
- Lambda expressions and forEach in Java
- curried functions in Go
- Linked lists in Elixir (Elixir is a pure functional programming language)
- Topic 7: Another programming approach: Rust
See Syllabus for readings- rough notes also some images
- Documentation in rust
- Rust by example In addition to the book, this is an excellent reference.
- Basic Hello worldin Rust
- Cargo Hello World in Rust
- Print a message given on the command line a number of times, also from the command line in Go in Rust
- Draw a random number in some range. Repeatedly draw new random number to "guess" the first number. On each guess remove part of the range in Rust
- Integer overflow is handled differently in debug and release in Rust
- Each side of if can return a value (the are blocks after all) in Rust Be careful here as both side must return things of same type!
- Strings in Rust are weird in Rust More on Strings
- Null safety in Rust This is one example of how Rust gets null safety. Similar classes like "Box" handle other issues.
- Ownership in Rust Its weird!
- Borrowing, mutably! in Rust
- First class functions in Rust and iterators!
- Topic 8:
Types: Scott: Ch 7
- rough notes
- Strong weak and static dynamic
- Enums in Java
- Go enumerated types
- enumerated types in rust
- type equivalence in Go
- type equivalence in Java
- type equivalence in rust Like Java, rust does not have default equivalence between structs. Type aliases are probably macro'ed out by the compiler, so they are OK.
- type casting in Go
- unsafe type casting is barely possible in Go
- unsafe type casting is easy in C
- unsafe type casting in Rust??
- Type inference in Go
- Generics can result in immutable data structures in Java
- Type Erasure in Java Generics
- Deep copying in Go
- deep copy in Java
- Topic 9:
Composite Types: Scott Ch 8
- rough notes
- Go: anonymous structure inclusions
- Go: Equality on array and struct
- Go: Copy on array/slice
- Go: slices hold references
- Go: Size of arrays and slices
- Rust: Size of arrays and slices
- Rust: row major arrays
- Go: row major arrays
- Go: structure size
- Go: pointer review
- making a 2-d slice
- Java: String intern
- Go: Building a useful binary tree
- Rust: a linked list implementation
- Topic 10:
Subroutines: Scott Ch 9
- rough notes
- Go: nested functions (Rust is similar)
- Java: nested functions
- Go: pass pointers
- Rust: passing pointers and ownership!
- Java: pass references
- Go: multiple returns
- Go: pass with closure
- Go: changing closure
- Rust passing and returning variable closures
- Go: variadic functions
- multiple return values in Go.
- Go: the defer command
- Go: Basic Exception handling
- Go: more exceptions
- Some simple events in Java
- Roll your own events and event handlers -- starting onto concurrency
- Object closures in java
- Topic 11: Not this year
- Topic 12:
Concurrency: Scott Ch 13:
skip: 13.1.2, 13.2.3 (except fork/join and Box 13.3) 13.3 except 13.3.5, 13.4.1, 13.4.2, 13.4.4, 13.4.5
- rough notes
- Starting threads and waiting for them to complete in Rust V1 rust, V2 rust, V3 rust
- Starting threads and waiting for them to complete in Go V3 Go
- Starting threads and waiting for them to complete in Java V3 Java
- Parallel problems -- counting Counter Go
- Parallel problems -- counting Counter Java
- Go: atomics
- Go: atomics again Even using atomics, thinking helps.
- counting using locks Slower than atomics, but sometimes you cannot use atomics
- counting using locks Slower than atomics, but there is a limited number of things on which you can use atomics
- smarter counting using locksAgain, thinking about resource contention can improve speed dramatically.
- Message Passing in Rust messages in rust There are 4 versions of main in this file
- main_1_1 -- send one message from one sender
- main_1_10 -- one sender sending several messages
- main_10_10 -- 10 senders each sending some number of messages
- main_2d -- 10 threads each sending and receiving from the main thread.
- Java: threads and events
- Java Thread lock This is bad
- Better threading in Java Using a thread pool
- Handling slow reads asynchronously
- Machine info in Go
Course Policies
Communication
Attendance and active participation are
expected in every class. Participation includes asking questions,
contributing answers, proposing ideas, and providing constructive
comments.
Please
stay in touch with me, particularly if you feel stuck on a topic
or assignment and can't figure out how to proceed. Often a quick
e-mail, or face-to-face conference can reveal solutions
to problems and generate renewed creative and scholarly energy. It
is essential that you begin assignments early.
Grading
Grades will be awarded based on the number of points earned and according to the percentage breakdowns shown.Homework | 30% |
Class Participation | 10% |
Lab | 5% |
Midterms (2) | 35% |
Final exam | 20% |
Mid-terms will be take-home and intended to be completed in the time of a single class session. All exams will be open everything. The only restriction is that you may not discuss the exam, in any way, with anyone until 24 hours after the exam (unless you are told otherwise by me).
Incomplete grades will be given only for verifiable medical
illness or other such dire circumstances. Incomplete grades must be approved through the Dean's
office.
ALL work submitted for grading should be entirely YOUR OWN (except for labs). Sharing of programs, code snippets, etc. is not permitted under ANY circumstances. That said, I encourage you to discuss assignments at an algorithmic level with other students. That is, talk about the problem, and general approaches to problems. Do not share or discuss actual code.
Links
- Kernighan's book on programming style. Most of the examples in this book are in languages rarely if ever used, but the lessons still apply.
Learning Accommodations
Students requesting accommodations in this course because of the impact of disability are encouraged to meet with me privately early in the semester with a verification letter. Students not yet approved to receive accommodations should also contact Deb Alder, Coordinator of Accessibility Services, at 610-526-7351 in Guild Hall, as soon as possible, to verify their eligibility for reasonable accommodations. Early contact will help avoid unnecessary inconvenience and delays.This class may be recorded.
Creating a Welcoming Environment
All members of the Instruction Staff are dedicated to the cause of improving diversity, equity, and inclusion in the field of computing, and to supporting the wellness and mental health of our students.Diversity and Inclusion
It is essential that all members of the course community – the instructor, TAs, and students – work together to create a supportive, inclusive environment that welcomes all students, regardless of their race, ethnicity, gender identity, sexuality, or socioeconomic status. All participants in this course deserve to and should expect to be treated with respect by other members of the community. Class meetings, lab sessions, office hours, and group working time should be spaces where everyone feels welcome and included. In order to foster a welcoming environment, students of this course are expected to: exercise consideration and respect in their speech and actions; attempt collaboration and consideration, including listening to opposing perspectives and authentically and respectfully raising concerns, before conflict; refrain from demeaning, discriminatory, or harassing behavior and speech.Wellness
Additionally, your mental health and wellness are of utmost importance to the course Instruction Staff, if not the College as a whole. All members of the instruction staff will be happy to chat or just to listen if you need someone to talk to, even if it’s not specifically about this course. If you or someone you know is in distress and urgently needs to speak with someone, please do not hesitate to contact BMC Counseling Services: 610-526-7360 (610-526-7778 nights and weekends). If you are uncomfortable reaching out to Counseling Services, any member of the Instruction Staff will be happy to contact them on your behalf. We understand that student life can be extremely difficult, both mentally and emotionally. If you are living with mental health issues such as anxiety, depression, ADHD, or other conditions that may affect you this semester, you are encouraged to discuss these with the Instructor. Although the details are up to you to disclose, the Instruction Staff will do their best to support and accommodate you in order to ensure that you can succeed this course while staying healthy.Created on August 2023. Subject to constant revision.