teaching functional programming and erlang: the galician ...erlang.se/euc/05/1400victor.pdf ·...

34

Upload: others

Post on 15-Jun-2020

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Teaching Functional Programming and Erlang:The Galician Experience

Victor M. Gulias

[email protected]

LFCIA-MADS Group, Department of Computer ScienceUniversity of A Coru~na, Spain

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 2: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

1 The Environment

2 Functional Programming at UDC

3 Experiences Teaching Erlang

4 Conclusions

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 3: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Quick lesson of Geography...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 4: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Quick lesson of Geography...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 5: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Quick lesson of Geography...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 6: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Do you know Spain?

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 7: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Do you know Spain?

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 8: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Do you know Spain?

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 9: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Do you know Spain?

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 10: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Do you know Spain?

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 11: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Perhaps you have heard about Galicia before...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 12: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

but, do you really know Galicia?

Misconceptions about Galician people (w.r.t. Spanish people)1 Di�erent popular parties

(no bull�ghting ! lots of gastronomic parties)2 Di�erent popular music

(no ' amenco' ! music from pipes, similar to Irish)3 Di�erent language

(Galician, similar to Portuguese, in addition to Spanish)4 Di�erent food

(no 'paella' ! octopus Galician style)5 Di�erent weather

(it rains frequently, but temperature � 0o C)

Strong celtic in uence: Ireland, Scotland...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 13: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

The Galician Universities

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 14: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

The Galician Universities

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 15: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Universidade da Coru~na

Established in 1989

(from older University of Santiago de Compostela)

> 25.000 students

Two cities (A Coru~na and Ferrol), seven campuses

http://www.udc.es

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 16: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

The Faculty of Informatics

Established in 1986 (before University of Coru~na!)

about 2.500 students (10%)

Three di�erent programmes in Computer Science:Engineering (�ve years)Technical Engineering (3 years)

Several doctorate programmes for graduate students

http://www.fic.udc.es

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 17: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

A quick visit to the Faculty of Informatics...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 18: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

A quick visit to the Faculty of Informatics...

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 19: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

The Role of Functional Programming in the Studies

Declarative paradigm plays relevant role in our studies

Mandatory course on Declarative Programming in 2nd year

one semesterthree hours in classroom, two hours in laboratory per weektwo di�erent programming models:

Logical (Prolog)Functional (Objective Caml)

Students use O'Caml as impl. language for other courses

Programming Technology, Automata and Formal Languages,Arti�cial Intelligence, Compilers, etc.Students consider easier than other more popular optionsSome lecturers forbid funtional languages (\just too easy")

4th (or 5th) year students ! Optional course on

Functional Programming

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 20: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Why Objective Caml?

80s: LFCIA group with strong mathematical background

(category theory)

CAML originally based on Categorical Abstract Machine

Several interactions with INRIA's researchersCAML introduced in lectures replacing SML or Miranda

CAML evolved ! Objective Caml

Nice features for teaching

E�cient (with a native code compiler)Portable (Windows and Linux, among others)Most of the state-of-the-art features of a functional language:(static type inference, anonymous functions, parametricpolimorphism, powerful module system, partial application, ...)

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 21: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

The Functional Programming Course

Optional course

Fourth year (spring)

3 hours in classroom, 2 hours in laboratory (formally)

14 weeks (equiv. 5.0 ECTS)

Popular: about 40 people per year (25% of 4th-year students)

(even though the schedule 8-10pm mon, 9-10pm wed, 8-10pm fri)

Since 1999 in charge of the course; now only Erlang part

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 22: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Overview of the FP Course

1 Quick review of functional programming concepts

2 Introduction to �-Calculus.

3 Type Systems.

4 Implementation Details of Functional Compilers.

5 Functional programming in the real-world.

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 23: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Overview of the FP Course

1 Quick review of functional programming concepts

First two-three weeksRefresh of previous knowledge (O'Caml)

Values, types and expressions;Identi�ers, de�nitions and scope;Predicates, conditional expressions and pattern-matching;Recursion;Lists;Polymorphism, High-order functions, partial application;User-de�ned and abstract datatypes;Modules and Functors

2 Introduction to �-Calculus.

3 Type Systems.

4 Implementation Details of Functional Compilers.

5 Functional programming in the real-world.

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 24: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Overview of the FP Course

1 Quick review of functional programming concepts2 Introduction to �-Calculus.

three-four weeksTopics:

Pure �-calculus;Substitution and reduction rules;Normalization;Lazy vs. eager evaluation;Fix-point combinators and recursion;Extending the �-calculus.

Small interpreter in O'CamlShort presentation of Haskell

3 Type Systems.

4 Implementation Details of Functional Compilers.

5 Functional programming in the real-world.

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 25: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Overview of the FP Course

1 Quick review of functional programming concepts

2 Introduction to �-Calculus.3 Type Systems.

three-four weeks�-calculus with typesType Inference.Students add static typing to their interpreters

4 Implementation Details of Functional Compilers.

5 Functional programming in the real-world.

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 26: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Overview of the FP Course

1 Quick review of functional programming concepts

2 Introduction to �-Calculus.

3 Type Systems.4 Implementation Details of Functional Compilers.

one-two weeksSpeci�c talks (depending on students' interest)

Garbage collection algorithmsInternal representation and comm. with low-level languagesPattern-matching implementation...

5 Functional programming in the real-world.

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 27: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Overview of the FP Course

1 Quick review of functional programming concepts

2 Introduction to �-Calculus.

3 Type Systems.

4 Implementation Details of Functional Compilers.5 Functional programming in the real-world.

ErlangAt the beginning, two-hour seminarNowadays, two/three-week courseCovers basic and continuation Erlang courses) Di�erent approach (student background)

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 28: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Erlang Part in the FP Course

Recommended readings:P.Wadler. Why no one uses functional languages?P.Wadler. Functional Programming: An angry half-dozenJ.Armstrong. Erlang | A survey of the language and itsindustrial applications

Basic Reference:J.Armstrong et al. Concurrent Programming in Erlang

Sequential ProgrammingEasy. Focus on di�erences: atoms, bindings, types, records, ...Some recurrent examples/exercises from the O'Caml part

Concurrent and Distributed Programming

Design PatternsFamiliar concept from other coursesgeneric server abstractionintroduction to gen server behaviour

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 29: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Students' General Impressions about Erlang

First impression: primitive

no static typing, no modules, no partial application, etc....but very curious about industrial application of the language

After a �rst contact: \type freedom" e�ect

start loving the language...but typing in uence is there: \informal" function signatureslater, this will be the more important problem of Erlang

They are frighten when hear \message passing" (Panic!)

Previous bad experiences with low-level libraries (PVM, MPI)Impressed with Erlang RTS managing the communicationsThey can focus on the problem and pay less attention to details

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 30: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Students' General Impressions about Erlang (ii)

Students feel comfortable with abstraction

Appreciate the generalization of a serverAppreciate the de�nition of skeletoms such as an abstractdivide-and-conquer algorithmAppreciate the implementation of distributed versions ofclassical abstractions (for example, a disttributed map)Some miss some features such as partial application

The notion of Design Pattern (behaviour, abstraction) isvery well accepted

They learn classical GoF Patterns at the same time

Mandatory 4th-year Information System Design courseModelling using UMLImplementation in Java

They ask why Erlang is not being used with (instead of) Java

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 31: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Students' General Impressions about Erlang (iii)

Students feel that design tools don't have Erlang in mind

We introduce familiar design artifacts (UML's state orsequence diagrams)We need more support tools

Erlang students miss the language when using concurrencyin other language

Erlang students get cleaner and better solutionsEven some use Erlang to prototype

At the end, some students continue working with Erlang

End of career project (master's thesis)Doctorate programmeWorking for our research group or for a company using Erlang

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 32: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Conclusions

FP (and Erlang) plays relevant role at UDC

Erlang is quite popular and successful among our students

\Ericsson", \complex real-time applications", \distributedprogramming" ! cool real-world stu�Those who learn Erlang, prefer it in front of other options(however, students hesitate at �rst glance)More Erlang: Master's thesis, doctorate programmes...Quantitative aspects:

about 40 people learn (an introduction) to Erlang per year2-3 Master's thesis per yearone large research project (VoDKA video-on-demand server)4 Ph.D. thesis VoDKA-related at di�erent stages3 recently created SMEs that use Erlang (strange in Galicia!)

Do you need brave Erlang developers?

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 33: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Thank you!

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience

Page 34: Teaching Functional Programming and Erlang: The Galician ...erlang.se/euc/05/1400Victor.pdf · eachingT Functional Programming and Erlang: The Galician Experience Victor M. Gulias

The EnvironmentFunctional Programming at UDCExperiences Teaching ErlangConclusions

Teaching Functional Programming and Erlang:The Galician Experience

Victor M. Gulias

[email protected]

LFCIA-MADS Group, Department of Computer ScienceUniversity of A Coru~na, Spain

Victor M. Gulias [email protected] Teaching Functional Programming and Erlang: The Galician Experience