Introduction to High-level Programming with Scala

Tony Morris

Abstract

This document is intended as a guide to a 60 — 75 minute presentation on introducing computer programming concepts to industry programmers using the Scala programming language. Although many of these concepts are general enough to apply to all forms of computer programming, this document also introduces some basic Scala syntax and foundational programming theory.

Some of the points made in this document assume an audience familiar with the Java programming language.


Table of Contents

Formalities
Questions
Objectives
Keep it DRY
Suppose we had...
So then we had...
But then we also had...
Refactoring Wizardry
The DRY Continuum
A Brief Introduction to Functional Programming
Remember this crazy guy?
Fundamentalism
Referential Transparency
For example
To care or not to care
Which First?
So what?
Where Does Scala Fit?
Basic Syntax of Scala
val,var,def,lazy val
if/else
First-class Functions
Function literal
Other Keywords
Type Parameter Variance
Imports
Basic Features of Scala
Type Inference
Static Verification
First-class Functions
Algebraic Data Types
The Expression Problem
One or None
Visitor
ADTs Instead
Describing structure
List
Option
Either
Either
Others
Partial Application
Replace Parameter With Method
Java Gets No Curry
Constructors as the Example
Partially Applying Scala
Implicit Arguments
Real World Snippets
Instinct BDD Framework
Reductio Website
Want to Learn More?
If we have time but we probably won't
Are we still here?
I feel very little right now
Higher Kinds
Lazy Annotations
High Level Abstractions
Some High-level Code Snippets (for fun)
Functors and Monads
Questions
A. Yeah but how can we write medium/large applications?
B. Scala Exercises For Beginners
<xi:include></xi:include>

Formalities

Questions

  • Questions. Please stop me and ask them.

  • However, some questions give rise to more questions! These must be deferred due to time constraints.

  • "What do you think about the paint job on Russell's Teapot?[1]

  • However, please see me after this session, or email me with your question.

Objectives

  • What will you take from this?

  • Depth versus excitement. Not even Gary Kasparov could teach you to play chess in such a short time-frame.

  • But he could certainly plant some seeds!

  • Beware of under-qualified internet commentators and snake oil vendors offering misleading advice.

  • I am more optimistic than Dijkstra.[2]

  • It is not an objective to convince you of the importance of the concepts at hand or to present irrefutable and compelling cases — mostly due to time constraints.

  • Keep thinking. Keep asking questions.



[1] "If I were to suggest that between the Earth and Mars there is a china teapot revolving about the sun in an elliptical orbit, nobody would be able to disprove my assertion provided I were careful to add that the teapot is too small to be revealed even by our most powerful telescopes. But if I were to go on to say that, since my assertion cannot be disproved, it is an intolerable presumption on the part of human reason to doubt it, I should rightly be thought to be talking nonsense. If, however, the existence of such a teapot were affirmed in ancient books, taught as the sacred truth every Sunday, and instilled into the minds of children at school, hesitation to believe in its existence would become a mark of eccentricity and entitle the doubter to the attentions of the psychiatrist in an enlightened age or of the Inquisitor in an earlier time." — Bertrand Russell (1872 — 1970)

[2] It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.