forked from gdecuzzi/2014-Flamel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution:language.tex
97 lines (81 loc) · 5.27 KB
/
solution:language.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
\section{Wollok: The Language}
\label{sec:wollokLanguage}
% Free form, variable number of sections, technical details.
% But in general do not mix solution and discussions/possible variation let that for discussion
Wollok is a brand new language, built to specifically give support to our pedagogical approach.
Many ideas have been inherited from our previous projects, such as Ozono or Loop.
The most important of these inherited characteristics is the ability to create objects and treat them polymorphically without the need of type annotations, classes or inheritance.
Also, as its predecessors and unlike other pedagogical tools, Wollok is a \emph{general purpose} language, \ie it is not tied to any specific domain.
\medskip
One of the main objectives of building a new language is to provide a smoother transition from the first phase of the course,
in which students use a simplified programming model and the second phase, in which they use a full-fledged OOP language.
With our previous programming tools students were required to discard, in the middle of the course, the programming model and enviromnent they already knew and were used to.
This transition has sometimes been traumatic, because the process to define an object has to be re-learnt and the tools they had been using up to that point are no longer available.
With our new approach, the tools they first learnt are going to continue being available through all the course, together with the new ones that are incorporated in later lectures.
This is also consistent with some modern industrial OO languages that allow to define both classes or standalone objects, such as Scala \cite{Oder04a}.
\medskip
Also we reduced to a minimum the syntax and the most basic constructs of the language.
While this objective was already present in our previous work, the implementation strategy of Wollok allows us to go much further in accomplishing this goal, \cf Sec. \ref{sec:implementation}.
The example in figure \ref{fig:helloWorld/wollok} shows how the classical hello world would look in Wollok.
To build this first program students are not required to know about typing, scoping or packaging.
The only required construct is the \lstinline[language=Wollok]{program} and the only command is a message send.
Both the receiver and the parameters are built-in objects which will be handled in the same way as user-defined objects.
The concepts required to understand this program are no more than program, object, message and argument passing.
\begin{figure}[ht]
\centering
\begin{lstlisting}[language=Wollok]
program {
console.println("Hello World!")
}
\end{lstlisting}
\caption{\small Sample initial Wollok program.}
\label{fig:helloWorld/wollok}
\end{figure}
\medskip
% Effect
\np{Esto requeriría una mención en la intro, o en general una explicación más detallada.}
Another concept we propose to emphasize in the first programming courses is the control of side effects,
\ie a programmer should be aware of the potential side effects of each portion of code.
The most basic feature in Wollok to control side effects is the ability to
differentiate variables (defined using \lstinline[language=Wollok]{var})
from constants (defined using \lstinline[language=Wollok]{val}).
One step forward is to incorporate an \emph{effect system} \cite{nielson_type_1999}, \cf Sec. \ref{sec:furtherWork}.
\medskip
% Misceláneos
% Profundizar y pulir el highlighting the conceptos primarios y la estratificacion de conceptos
To sum up, there are several simple features which help structure the way a student sees his programming activity.
\emph{Object literals} and \emph{collection literals} reduce boilerplate on object creation,
since we think that the excess of bureaucracy to create an object helps to build up
the belief that using objects or collections is far more complicated than using numbers or strings, which in turns leads to \emph{primitive obsession} \cite{fowler_refactoring:_1999}.
% Objetos no como un elemento de la IDE -Ozono: nueva referencia global, sino como un elemnto del lenguaje. Evita referencias globales.
Each Wollok file has to be defined as \emph{program}, \emph{library} or \emph{test}.
Only programs and tests can be run. Libraries can only be \emph{imported} from programs, tests or other libraries.
This concepts push students onto modularizing their programs into smaller units that can be reutilized.
Figure \ref{fig:polymorphism} shows some of the mentioned features.
The programs includes two objects which are treated polymorphically, collections and block closures.
Students should be able to build such a program after four lectures.
In the first lecture we introduce objects, messages, methods and references;
in the second one we focus on polymorphism;
and in the following two we work with blocks and collections.
\np{Acá falta hablar de la diferencia entre objeto y referencia}
\begin{figure}[ht]
\centering
\begin{lstlisting}[language=Wollok]
program myProgram {
val optimistic = object {
method hiThere() {
"Hi, what an amazing day !"
}
}
val pessimistic = object {
method hiThere() {
"Don't talk to me, it's a terrible day!"
}
}
val all = #[optimistic, pessimistic]
console.println(all.map[p| p.hiThere()])
}
\end{lstlisting}
\caption{\small Simple polymorphism example.}
\label{fig:polymorphism}
\end{figure}