CS 6371: Advanced Programming Languages - Spring 2014, Assignments of Programming Languages

An overview of CS 6371: Advanced Programming Languages, taught by Dr. Kevin Hamlen at the University of Texas at Dallas in Spring 2014. The course covers advanced topics in programming languages, including language design, formal semantics, and the differences between type-safe and functional programming. Students will learn to use OCaml, an advanced programming language, and will design and implement a new programming language. The document also includes information about course logistics, grading, and homework policies.

Typology: Assignments

2021/2022

Uploaded on 08/01/2022

fabh_99
fabh_99 🇧🇭

4.4

(53)

543 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 6371: Advanced Programming
Languages
Dr. Kevin Hamlen
Spring 2014
Fill out, sign, and return prereq forms:
Course number: CS 6371
Section: 1
Prerequisites:
CS 5343: Algorithm Analysis & Data Structures
CS 5349: Automata Theory
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download CS 6371: Advanced Programming Languages - Spring 2014 and more Assignments Programming Languages in PDF only on Docsity!

CS 6371: Advanced Programming

Languages

Dr. Kevin Hamlen

Spring 2014

• Fill out, sign, and return prereq forms:

  • Course number: CS 6371
  • Section: 1
  • Prerequisites:
    • CS 5343: Algorithm Analysis & Data Structures
    • CS 5349: Automata Theory

Today’s Agenda

• Course overview and logistics

• Course philosophy and motivation

– What is an “advanced” programming language?

– Type-safe vs. Unsafe languages

– Functional vs. Imperative programming

• Introduction to OCaml

– The OCaml interpreter and compiler

– An OCaml demo

Course Logistics

  • Class Resources:
    • Course homepage: www.utdallas.edu/~hamlen/cs6371sp14.html
    • My homepage: www.utdallas.edu/~hamlen
    • Tentative office hours: 1 hr immediately after each class(?)
    • Email: hamlen AT utdallas DOT edu
  • Grading
    • Homework: 25%
    • In-class quizzes: 15%
    • Midterm exam: 25%
    • Final exam: 35%
  • Homework
    • 9 assignments: 6 programming + 3 written
    • Homework must be turned in by 1:05pm on the due date. Programming assignments submitted through eLearning; written assignments submitted in hardcopy at start of class.
    • Late homeworks NOT accepted!
  • Attendance of at least 2 of first 3 classes is MANDATORY.

Homework Policy

  • Students MAY work together with other current students on homeworks
  • You MAY NOT consult homework solution sets from prior semesters (or collaborate with students who are consulting them).
  • CITE ALL SOURCES
    • includes webpages, books, other people, etc.
    • citation is required even if you don’t copy the source word-for-word
    • there is nothing wrong with using someone else’s ideas as long as you cite it
    • you will not lose any marks or credit as long as you cite
  • Violating the above policies is PLAGIARISM (cheating).
  • Cheating will typically result in automatic failure of this course and possible expulsion from the CS program.
  • It is much better to leave a problem blank than to cheat!
    • Usually ~60% is a B and ~80% is an A.
    • However, cheating earns you an F. It’s not worth it!

Difficulty Level

  • Warning: This is a tough course
    • cutting-edge, PhD-level material
    • difficulty ranked 9/9 on average by past students
  • No required text book
    • very few (approachable) texts cover this advanced material
    • no large pools of sample problems exist to my knowledge
    • useful texts:
      • book by Glynn Winskel on reserve in UTD library
      • online text and several online manuals linked from webpage
    • Warning: Many online web resources devoted to this material are INCORRECT (e.g., certain Wikipedia pages). Do not depend on them.
  • What you’ll get out of taking this course
    • excellent preparation for PhD APL qualifier exam
    • solid understanding of language design & semantics
    • modern issues in declarative vs. imperative languages
    • deep connections between abstract logic and programming

About me…

  • Ph.D. from Cornell University (2006)
    • B.S. in CS & Math from Carnegie Mellon
  • Research: Computer Security, PL, Compilers
  • Work experience: Microsoft Research
  • Personal
    • married, one child (a boy, 1 year old)
    • Christian
  • Programming habits
    • C/C++ (for low-level work)
    • assembly (malware reverse-engineering)
    • C#, Java (toy programs)
    • Prolog (search-based programs)
    • OCaml, F#, Haskell, Gallina/Coq (everything else)

What is an “Advanced”

Programming Language?

C/C++: Unsafe Languages

• Find the bug: #include <stdio.h>

int main() { char name[1024]; printf(“Enter your name: ”); gets(name); printf(“Your name is: %s\n”, name); return 0; }

Java: A Type-safe, Imperative

Language

  • Find two bugs:

import java.io.; import java.util.;**

class Summation { public static void main(String[] args) { List list = new LinkedList();

for (int i=0; i<args.length; ++i) list.add(args[i]);

int sum = 0; while (!list.isEmpty()) sum += ((Integer)list.remove(1)).intValue();

System.out.println(sum); } }

Java: A Type-safe, Imperative

Language

  • Find two bugs:

import java.io.; import java.util.;**

class Summation { public static void main(String[] args) { List list = new LinkedList();

for (int i=0; i<args.length; ++i) list.add(args[i]);

int sum = 0; while (!list.isEmpty()) sum += ((Integer)list.remove(1)).intValue();

System.out.println(sum); } }

Cast Exception!

OutOfBounds Exception!

Goals of Functional Languages

• In an “Advanced” Programming Language:

– The compiler should tell you about typing errors in

advance (not at runtime!)

– The language structure should make it difficult to

write programs that might crash (no unsafe casts!)

– 80% of your time should be spent getting the

program to compile, and only 20% on debugging

– should be tractable to create a formal, machine-

checkable proof of correctness for mission-critical

core routines, or even full production-level apps

In OCaml…

  • You almost never need to cast anything
    • The compiler figures out all the types for you
    • If there’s a type-mismatch, the compiler warns you
  • OCaml is fast
    • Somewhere between C (fastest) and Java (slow)
    • Very hard to measure precisely. (So-called “benchmark”

programs typically rely on math libraries that aren’t even

implemented in the languages that call them!)

  • Functions are “first-class”:
    • you can pass them around as values, assign them to variables, …
    • you can build them at runtime (Runtime Code Generation)
  • But: The syntax is very weird if you’ve only ever

programmed in imperative languages!