Computer programming

A.Y. 2020/2021
Overall hours
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
Course syllabus and organization

Edition 1

Lesson period
First semester
Synchronous video lessons
Course syllabus
[TWG = The Way to Go: A Thorough Introduction to the Go Programming Language by Ivo Balbaert = Ivo Balbaert: Programmare in go. Pearson, ISBN 8891909661]
1. Course introduction; Computer architecture; Computer science; Programming languages ​​(machine language, assembly, high level); Computer as a programmable machine
2. The von Neumann machine. Information (bits, bytes, ...). Loader, fetch-decode-execute. CPU architecture: ALU and CU. An example of a CPU; assembly languages
3. Software lifecycle. Programming tools. History of go. The first program in go [TWG4]. The go tool. Compilation. Execution. Formatting. Documentation [TWG3]
4. Discussion of lexical and syntactic aspects. Comments [TWG4]. Types. Classification of types (basic types, compound types, interfaces). Variables: name, type, value, scope. Multiple declaration, assignments, short-assignment [TWG4]
5. Basic I / O. Basic numeric types (int, float64). Numerical expressions. Conversions. Introduction to the complex type. Unused variables and blank variable [TWG4]
6. Binary selection (if). Local variables. The bool type and the Boolean operators. Exercises [TWG5]
7. The iteration (for): unary, ternary, zeroary versions. Exercises [TWG5]
8. Digital representation of data. Positional notation. Representation of negative integers. Representation range, overflow. Overview of the representation of the reals: fixed and mobile point (IEEE 754 standard). Characters (ASCII, Unicode, UTF-8) [Handouts]
9. Fixed-length numeric basic types. Rune type. String type: differences between raw and utf-8. Len function. Fourth form of the for (range) cycle [TWG4, TWG5]
10. Exercises: nested cycles. Break and continue instructions [TWG5]
11. Multi-way selection (switch) [TWG5]
12. Arrays and slices. Initializers. Application of the for ranges. Append function [TWG7]
13. Exercises. Command-line arguments. Strconv package
14. Functions: parameters, signature. Passage by value. Returned values. Values ​​returned with a name. [TWG6]
15. Exercises
16. Sorting and binary research
17. Generation of pseudo-random numbers. Math package. Exercises
18. Maps. Application of the for ranges. Exercises [TWG8]
19. Recursion. Execution stack [TWG6]
20. Exercises using recursion
21. Pointers: operators * and &. [TWG4]
22. Exercises with pointers
23. Structures [TWG10]. Methods [TWG10] (outline)
24. Exercises on structures and methods
25. Closures. Example: sort, binary search
26. Advanced I / O. File [TWG12]
27. Exercises; defer [TWG6]
28. Packages and structure. Visibility of the variables
29. Testing [TWG13]
30. Interfaces [TWG11]
31. Implementation of a search engine (reverse indices)
32. Go routines and channels [TWG14]
33. Exercises on concurrency
34. The C language. Using gcc. Syntactic differences: point-and-comma, brackets 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.
35. Absence of strings, slices, maps; use of char[] for strings. Elementary types and compiler dependency; use of specific types (stdint.h, bool.h). Implicit cast. Definition of macros. Library functions. Command line parameters
36. Pointers, pointer arithmetic. Memory management: malloc, free
Prerequisites for admission
Teaching methods
Lessons + labs
Teaching Resources
- Ivo Balbaert: Programmare in go. Pearson, ISBN 8891909661.
- The Go Programming Language. Donovan, Kernighan
Assessment methods and Criteria
Exam session structure; every session consists of
- an individual lab programming test; 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;
- a written test;
the students who pass both tests is proposed a mark (obtained by averaging the marks obtained in each test); students with a proposed mark between 21 and 27 can decide whether to directly finalize the exam with that mark or to just refuse the mark and re-do the exam in the future; students with a proposed mark smaller than 21 must also pass an oral test to verify their skills; students with a mark larger than 27 can either finalize the exam with the proposed mark, or make an oral test (aiming at improving the mark; obviously the outcome of the oral test can be arbitrary --- it can lead to an increased or decreased mark, or even to a failure).
The various parts composing an exam must be necessarily performed in the same session.
INF/01 - INFORMATICS - University credits: 3
Laboratories: 48 hours
Turno A
Professor: Morpurgo Anna Chiara Giovanna
Turno B
Professor: Trentini Andrea Mario
Turno C
Professor: Capra Lorenzo
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:
- [F9X-31](
INF/01 - INFORMATICS - University credits: 3
Laboratories: 48 hours
Professor: Ahmetovic Dragan
Turno D
Professor: Ahmetovic Dragan
Turno E
Professor: Ahmetovic Dragan
Turno F
Professor: Ahmetovic Dragan
INF/01 - INFORMATICS - University credits: 9
Lessons: 72 hours
Professor: Ceselli Alberto