CS302: Paradigms of Programming

“Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.”

- Greenspun's tenth rule of programming 

Offering: Feb-Aug 2020 (Physical+Virtual)

Class strength: 59 58

Feedback: Course/offering

About the course

Why do we have so many programming languages? Can I even try to get acquainted with a good enough subset? What are the relative advantages of each different paradigm of programming?

This course tries to provide the answers to such questions and more, by studying the fundamental paradigms (imperative, functional, object-oriented, logic) using which a large number of programming languages have been designed. The goal is to focus on the underlying concepts and principles, rather than mastering several languages from each paradigm. By the end of the course, students should be able to appreciate the differences among thinking in each paradigm, while also getting a glimpse of the design and practical issues associated therein. A latent aim of the course is to also motivate the students in studying advanced nuances in the design of languages and their runtimes, and arguing about their mathematical nature.

Textbooks:

1. Harold Abelson, Gerald Jay Sussman and Julie Sussman. “Structure and Interpretation of Computer Programs”, Second Edition, Universities Press, 2005 (for most of the concepts and for Scheme).
2. Ravi Sethi. “Programming Languages: Concepts and Constructs”, Second Edition, Pearson Education, 2006 (for Lambda Calculus and Prolog).
3. Miran Lipovańća. “Learn You a Haskell for Great Good!”, Freely Available Online Edition, 2011 (for, you guessed right, Haskell).

Reference:

  • Michael L. Scott. “Programming Language Pragmatics”, Fourth Edition, Morgan Kaufmann, 2015.

Course structure

  • Credits: 3-0-2-4

  • Prerequisite: IC150 (Computation for Engineers)

  • Audience: No escape for CSE 6th sem; elective for EE 6th and 8th sem

  • Instructor: Manas Thakur

  • TAs: Niveda Pareek (d19061); Aashish Kumar (b16001); Nikhil Gupta (b16023); Vishal Anand (b16040); Nikhil T R (b16066)

  • Slots:

    • Theory: (B3) Mon 9am, Wed 1pm, Thu 11am; classroom: A10-1B

    • Lab: (L1) Mon 2:30pm; venue: PC Lab (North campus)

    • Zoom (Tue Wed Thu 10am)

  • Discussions on-boarded to Microsoft Teams (due to Covid-19)

Schedule

Content Material Remarks
Week 1 Feb 17, 19, 20:
  • Introduction and logistics

  • Bindings and environment

  • Substitution model

  • Orders of evaluation

Feb 17:
  • C1: John Backus’ Turing Award Lecture

Slides:
Week 2 Feb 24, 26, 27:
  • Recursion, iteration, tail-call optimization

  • Block structure and scoping

  • Higher order functions

  • Closures, Lambdas

Feb 24 29:
  • Lab1: FP with numbers
    (and Church numerals)

Follow the board
  • Institute foundation day on 24 –
    lab rescheduled to 29 at 10 am

Week 3 Mar 2, 4, 5:
  • (Untyped) Lambda calculus

  • Currying

  • Programming with lists

Mar 2:
  • Lab2: Representing data using functions

Follow the board
Week 4 Mar 11, 12:
  • Trees as lists

  • Higher order list functions

Mar 9:
  • C2: John Hughes’
    “Why Functional Programming Matters”

Follow the board
  • COVID-19 disrupts regular
    classes after 14

Week 5 Mar 23, 25, 26:
  • Purity and referential transparency

  • Overview of object-oriented programming

  • Dispatching; message passing

Mar 23:
  • C3: Russ Olsen's
    “Functional Programming in 40 Minutes”

Slides:
  • Switched to Zoom classes from 23 –
    YouTube link available on demand

Week 6 Mar 30; Apr 1, 2:
  • Assignments and local state

  • Environment model

  • OO case study: Java

Mar 31:
  • Lab3: Programming with local state

Slides:
Week 7 Apr 6, 8, 9:
  • Sequences as conventional interfaces

  • Streams as delayed lists

  • Infinite streams

Slides: Code:
Week 8 Apr 13, 15, 16:
  • Iterations as stream processes

  • Defining syntax using macros

  • Doubt session

Apr 19:
  • C4: Venkat Subramaniam's
    “Let's Get Lazy”

Code:
Week 9 Apr 20, 22:
  • let, let*, letrec, memq, assoc

  • Simulating a DFA

  • Continuations

Code:
  • Summer break from 24

Week 10 Jul 14, 15, 16:
  • Language design with evaluators

  • The Eval/Apply interpreter for Scheme

Slides: Notes:
  • Classes resume from 14

Week 11 Jul 21, 22, 23:
  • Variations on the Scheme interpreter

  • (1) Variable number of arguments

  • (2) Lexical vs dynamic scoping

  • (3) Eager vs lazy evaluation

Slides: Code:
Week 12 Jul 28, 29, 30:
  • Intro to logic programming

  • Unification and backtracking

  • Cuts, negation as failure

  • Prolog applications

Slides: Notes:
Week 13 Aug 4, 5, 6:
  • Haskell week

  • Currying

  • Pattern matching

  • (Not) All the ways of creating lists

  • Types: ADTs and Type classes

Slides:
Week 14 Aug 11, 12, 13:
  • Doubt session

  • More about Haskell

  • Conclusions

Links: THE END

Special Revision Session (Jan 2021):

// Classes: GMeet; Discussions: Slack (use @students.iitmandi.ac.in ID)

  • Jan 06: Weeks 1-3

  • Jan 11: Weeks 4-6

  • Jan 14: Weeks 7-9

  • Jan 18: Weeks 10-12

  • Jan 21: Weeks 13-14

Evaluation

// Revised after the hiatus caused by Coronavirus

Theory (50%):

  • Comprehension (5)

  • Open book test (5)

  • End sem (40)

Practice (50%):

  • Labs (1+1+3)

  • Assignments (10+10+15+10)