Computer Programming
A.Y. 2024/2025
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
Lesson period: First semester
Assessment methods: Esame
Assessment result: voto verbalizzato in trentesimi
Single course
This course can be attended as a single course.
Course syllabus and organization
Single session
Responsible
Lesson period
First semester
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]
- 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.
- 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: The Way to Go: A Thorough Introduction to the Go Programming Language.
- Alan A. Donovan, Brian W. Kernighan: The Go Programming Language, Addison-Wesley.
- http://vigna.di.unimi.it/prog/
- Alan A. Donovan, Brian W. Kernighan: The Go Programming Language, Addison-Wesley.
- http://vigna.di.unimi.it/prog/
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;
- an oral exam.
The two parts composing the exam must be necessarily performed in the same session.
- 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;
- an oral exam.
The two parts composing the exam must be necessarily performed in the same session.
Laboratorio
INF/01 - INFORMATICS - University credits: 3
Laboratories: 48 hours
Professor:
Bressan Marco
Shifts:
Turno A
Professor:
Bressan Marco
Teoria
INF/01 - INFORMATICS - University credits: 9
Lessons: 72 hours
Professor:
Vigna Sebastiano
Professor(s)