Computer Programming

A.Y. 2023/2024
12
Max ECTS
120
Overall hours
SSD
INF/01
Language
Italian
Learning objectives
The goal is to introduce students to structured imperative programming and small-scale problem solving
Expected learning outcomes
The student should acquire the ability to write and tune a program that automatizes a simple task; moreover, (s)he should be able to understand how a small piece of code works, to find the reasons of a malfunction and to correct it appropriately
Single course

This course can be attended as a single course.

Course syllabus and organization

Edition 1

Responsible
Lesson period
First semester
Course syllabus
SYLLABUS DRAFT
[TWG = The Way to Go: A Thorough Introduction to the Go Programming Language by Ivo Balbaert = Ivo Balbaert: Programmare in go. Pearson, ISBN 8891909661]
- Introduction to the course. Computer architecture. What is computer science. Programming languages (machine language, assembly, high level). The computer as a programmable machine.
- von Neumann's architecture. Information (bits, bytes, ...). Loading the program into RAM, fetch-decode-execute. CPU architecture: ALU and CU. An example of a CPU with its assembly language.
- Software life cycle. Programming tools. Go story. The first program in go [TWG4]. The go tool. Compilation. Execution. Formatting. Documentation. [TWG3]
- Discussion of lexical and syntactic aspects. Comments [TWG4]. General structure of a go program: program, packages, sources. The standard library. [TWG4]
- Variables: name, type, value, visibility (scope). Types. Type classification (basic types, compound types, interfaces). Statement, multiple assignments and assignments, short-assignments. [TWG4]
- Basic I/O: fmt.Println, fmt.Print, fmt.Scan. Numeric base types (int, float64). Numerical expressions. Conversions. Unused variables and blank variables. [TWG4]
- Binary selection (if). The bool type and the boolean operators. Exercises. [TWG5]
- More on if: variables local to if (local to blocks; local to construct). Examples.
- The (for) cycle: unary, ternary, zerary version. Exercises. [TWG5]
- The characters (ASCII, Unicode, UTF-8). Runes. String type: differences between raw and UTF-8. len function. Fourth form of the for (range) loop. [TWG4]
- Functions: parameters, argument signature. Passing by value. Return values. Return values ​​with name. [TWG6]
- Exercises with simple loops and functions. Break and continue statements. [TWG5]
- Exercises with nested loops.
- Representation of information. Positional notation. Representation of negative integers. Representation range, overflow. Fixed-length integer types. Outline of the representation of reals: fixed and floating point (IEEE 754 standard). Introduction to the complex type. [Handouts, TWG4, TWG5]
- Multiary selection (switch). [TWG5]
- Exercises. strconv package and strings package. [TWG]
- Pointers: operators * and &. The new function. [TWG4]
- Type: aliases and definitions. Struct. Exercises with pointers and structs.
- Arrays and slices. Initializers. Application of for ranges. Append function. [TWG7]
- Exercises. Subslicing. fmt.Printf. Command line arguments.
- Pseudorandom number generation. Math package. Exercises.
- Maps. Application of for ranges. Converting string to [] rune. Exercises. [TWG8]
- Recursion. Execution stack. [TWG6]
- Exercises on recursion.
- Graphics with github.com/holizz/terrapin package. Simple examples. Fractals and Koch's curve.
- Packages and structure. Visibility. Documenting a package. Methods. [TWG9 (hints)]
- Interfaces (hints). Examples: Stringer, Reader, Writer. [TWG10, TWG11]
- Type conversion, type switch, variadic arguments. [TWG11, TWG6]
- Function types and closures (outline). Examples from libraries (sorting, shuffling, searching in strings). The example of numerical integration (Monte-Carlo method). [TWG6]
- Advanced I / O. File, panic and defer instructions. [TWG6, TWG12, TWG13]
- Practice: reading a text file with a predetermined format, regular expressions, handling of I/O and parsing errors.
- Example: a package for simple linked lists of strings.
- Unit and functional testing. (E2E) [TWG13]
- The C language. The gcc. Syntactic differences: semicolons, parentheses in control structures, declarations of variables, types and functions. Differences in flow control structures (switch, while, do-while). Use of simple instructions in control structures. Inclusion vs. import.
- Absence of strings, slices, maps. Using char [] for strings. Elementary types and compiler dependency; use of specific types (stdint.h, bool.h). Implicit cast. Definition of macro. Library functions. Command line parameters.
- Pointers, pointer arithmetic. Memory management: malloc, free.
Prerequisites for admission
None
Teaching methods
Lessons + labs. Attendance is not mandatory but strongly suggested.
Teaching Resources
- Ivo Balbaert: Programmare in go. Pearson, ISBN 8891909661.
- The Go Programming Language. Donovan, Kernighan
- http://boldi.di.unimi.it/Corsi/Inf2023/
Assessment methods and Criteria
Exam session structure; every session consists of
- an individual lab programming test (1h30); the test contains a "filter" exercise: if a student doesn't provide a correct implementation of the filter exercise, (s)he will not be further evaluated; the final score (18->30) will then be averaged with the score of the oral;
- an oral test to verify their skills (only for those who passed the lab test).
The various parts composing an exam must be necessarily performed in the same session.
Laboratorio
INF/01 - INFORMATICS - University credits: 3
Laboratories: 48 hours
Shifts:
Turno A
Professor: Morpurgo Anna Chiara Giovanna
Turno B
Professor: Trentini Andrea Mario
Teoria
INF/01 - INFORMATICS - University credits: 9
Lessons: 72 hours
Professor: Boldi Paolo

Edition 2

Lesson period
First semester
Course syllabus
The syllabus is shared with the following courses:
- [F3X-36](https://www.unimi.it/en/ugov/of/af20240000f3x-36)
Laboratorio
INF/01 - INFORMATICS - University credits: 3
Laboratories: 48 hours
Shifts:
Turno C
Professor: D'Amelio Alessandro
Turno D
Professor: D'Amelio Alessandro
Teoria
INF/01 - INFORMATICS - University credits: 9
Lessons: 72 hours
Professor: Vigna Sebastiano

Edition 3

Lesson period
First semester
Course syllabus
The syllabus is shared with the following courses:
- [F9X-31](https://www.unimi.it/en/ugov/of/af20240000f9x-31)
Laboratorio
INF/01 - INFORMATICS - University credits: 3
Laboratories: 48 hours
Professor: Bianchessi Nicola
Shifts:
Turno E
Professor: Bianchessi Nicola
Turno F
Professor: Bianchessi Nicola
Teoria
INF/01 - INFORMATICS - University credits: 9
Lessons: 72 hours
Professor: Ceselli Alberto