Towards a Semiotic Framework for Programming Languages Andrea Valle - - PowerPoint PPT Presentation
Towards a Semiotic Framework for Programming Languages Andrea Valle - - PowerPoint PPT Presentation
Towards a Semiotic Framework for Programming Languages Andrea Valle && Alessandro Mazzei CIRMA: Centro Interdipartimentale di Ricerca sulla Multimedialit e l'Audiovisivo Universit degli Studi di Torino, Italy andrea.valle@unito.it
2 HaPoC - 2013
http://en.wikipedia.org/wiki/Programming_language
“A programming language is a formal language designed to communicate instructions to a machine, particularly a
- computer. Programming languages can be used to create
programs that control the behavior of a machine and/or to express algorithms precisely.” -- Wikipedia
Formal -> artifjcial
Final receiver -> machine
Deontic communication
Algorithms: defjnition and execution
3 HaPoC - 2013
Intro
Coding is a form of communication: m2c, m2m, c2c -> the cybernetic project
Write the code, read the code
Linguistic richness of programming languages -> ~1K
Turing-equivalence vs. expressivity -> Programming language churches, e.g. clojure, supercollider, ...
4 HaPoC - 2013
Intro
The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs.
- - Joseph Weizenbaum
5 HaPoC - 2013
Intro
We use semiotic tools, related to narratology, to analyze programming languages
Two other distinct semiotic views:
Zemanek H., Semiotics and programming languages, Communications of the ACM (9-3), 1966.
- > theroretical CS
Tanaka-Ishii K., 2010, Semiotics of Programming, Cambridge-New-York, Cambridge-University.
- > sign systems
6 HaPoC - 2013
Perspectives
Low-level vs. High-level languages Good practices Enunciation analysis of programming paradigms
7 HaPoC - 2013
Levels
Machine Code
Assembler
Control fmow -> structured programming
Low-levels High-levels Natural Languages
Machine code Assembler C++ Java Python Javascript Pseudo-code Flow-charts Italian, English No relations to Von Neumann Small relations to Von Neumann IF , WHILE Really related to Von Neumann STORE, LOAD, ADD
8 HaPoC - 2013
Good practices
Seibel P ., 2009, Coders at Work, New York, Apress
Readability -> the ideal human-reader
comments indentation meaningful name syntax highlight
9 HaPoC - 2013
Elements of enunciation
PERSONA: who is subject/object of enunciation? TIME: what is the time of enunciation? SPACE: what is the space of enunciation?
10 HaPoC - 2013
start = 8 howMany = 10 for i in range(howMany): k = i + start if float(k)/2 == round(k/2): print k, ": is even" else: print k, ": is odd"
ImperativeExample.py
# Prints on the screen 10 numbers starting from 8 # and determines whether they are even or odd
11 HaPoC - 2013
start = 8 howMany = 10 for i in range(howMany): k = i + start if float(k)/2 == round(k/2): print k, ": is even" else: print k, ": is odd"
ImperativeExample.py: PERSONA
The subject of the enunciation "I" is an abstract entity, the subject- programmer who get into a relationship with an asymmetric and complementary subject "YOU", an abstract agent of calculus which implements the given orders.
12 HaPoC - 2013
start = 8 howMany = 10 for i in range(howMany): k = i + start if float(k)/2 == round(k/2): print k, ": is even" else: print k, ": is odd"
ImperativeExample.py: TIME
Every statement prescribes an action to be realized at the time of its enunciation: the sequence of enunciates coincides with the advancement of time.
13 HaPoC - 2013
start = 8 howMany = 10 for i in range(howMany): k = i + start if float(k)/2 == round(k/2): print k, ": is even" else: print k, ": is odd"
ImperativeExample.py: SPACE
The memory is the reference space of the language: the names of variables establish a system of real mnemonic loci, in the double meaning
- f
memory addresses for the machine and "placeholders" for the human interpreter
14 HaPoC - 2013
start = 8 howMany = 10 for i in range(howMany): k = i + start if float(k)/2 == round(k/2): print k, ": is even" else: print k, ": is odd"
ImperativeExample.py: SPACE
The memory is the reference space of the language: the names of variables establish a system of real mnemonic loci, in the double meaning
- f
memory addresses for the machine and "placeholders" for the human interpreter
Life is too short for malloc
- - Neal Ford
15 HaPoC - 2013
Pascal is for building pyramids—imposing, breathtaking, static structures built by armies pushing heavy blocks into
- place. Lisp is for building organisms—imposing, breathtaking,
dynamic structures built by squads fjtting fmuctuating myriads
- f simpler organisms into place.
- - Alan Perlis
16 HaPoC - 2013
def isEven(num): if fmoat(num)/2 == round(num/2): return True else: return False def printEvenOrOdd(num): if isEven(num): print num, ": is even" else: print num, ": is odd" def evenOrOdd(howMany, start): map(printEvenOrOdd, range(start, start+howMany)) evenOrOdd(10, 8)
FunctionalExample.py
17 HaPoC - 2013
def isEven(num): if fmoat(num)/2 == round(num/2): return True else: return False def printEvenOrOdd(num): if isEven(num): print num, ": is even" else: print num, ": is odd" def evenOrOdd(howMany, start): map(printEvenOrOdd, range(start, start+howMany)) evenOrOdd(10, 8)
FunctionalExample.py: SPACE
18 HaPoC - 2013
def isEven(num): if fmoat(num)/2 == round(num/2): return True else: return False def printEvenOrOdd(num): if isEven(num): print num, ": is even" else: print num, ": is odd" def evenOrOdd(howMany, start): map(printEvenOrOdd, range(start, start+howMany)) evenOrOdd(10, 8)
FunctionalExample.py: PERSON
There is a request to the environment, no specifjc "YOU" is present here, to compute the output value of a function over a specifjc input value. Imaginary geography of functions -> topology
def isEven(num): if fmoat(num)/2 == round(num/2): return True else: return False def printEvenOrOdd(num): if isEven(num): print num, ": is even" else: print num, ": is odd" def evenOrOdd(howMany, start): map(printEvenOrOdd, range(start, start+howMany)) evenOrOdd(10, 8)
20 HaPoC - 2013
def isEven(num): if fmoat(num)/2 == round(num/2): return True else: return False def printEvenOrOdd(num): if isEven(num): print num, ": is even" else: print num, ": is odd" def evenOrOdd(howMany, start): map(printEvenOrOdd, range(start, start+howMany)) evenOrOdd(10, 8)
FunctionalExample.py: TIME
The function space also absorbs the time: the
- rder in which the graph
is explored does not afect the fjnal result of the computation.
21 HaPoC - 2013
class Number: def __init__(self, val): self.number = val def isEven(self): if fmoat(self.number)/2 == round(self.number/2): return True else: return False def getNumber(self): return self.number class EvenOrOddPrinter: def printEvenOrOdd(self, num): if num.isEven(): print num.getNumber(), ": is even" else: print num.getNumber(), ": is odd" def evenOrOdd(self, howMany, start): for i in range(howMany): k = i+start self.printEvenOrOdd(Number(k)) EvenOrOddPrinter().evenOrOdd(10, 8)
OOExample.py
22 HaPoC - 2013
class Number: def __init__(self, val): self.number = val def isEven(self): if fmoat(self.number)/2 == round(self.number/2): return True else: return False def getNumber(self): return self.number class EvenOrOddPrinter: def printEvenOrOdd(self, num): if num.isEven(): print num.getNumber(), ": is even" else: print num.getNumber(), ": is odd" def evenOrOdd(self, howMany, start): for i in range(howMany): k = i+start self.printEvenOrOdd(Number(k)) EvenOrOddPrinter().evenOrOdd(10, 8)
OOExample.py: SPACE
A taxonomy of classes that organizes the world into objects
- > fjelds, methods
This feature hides spatiality from the world.
23 HaPoC - 2013
class Number: def __init__(self, val): self.number = val def isEven(self): if fmoat(self.number)/2 == round(self.number/2): return True else: return False def getNumber(self): return self.number class EvenOrOddPrinter: def printEvenOrOdd(self, num): if num.isEven(): print num.getNumber(), ": is even" else: print num.getNumber(), ": is odd" def evenOrOdd(self, howMany, start): for i in range(howMany): k = i+start self.printEvenOrOdd(Number(k)) EvenOrOddPrinter().evenOrOdd(10, 8)
OOExample.py: PERSONA
name.method(args)
- >
subject! Do this in this way! The "YOU" of the enunciation is not the calculation agent, but a plurality of possible receivers, i.e. the
- bjects
24 HaPoC - 2013
class Number: def __init__(self, val): self.number = val def isEven(self): if fmoat(self.number)/2 == round(self.number/2): return True else: return False def getNumber(self): return self.number class EvenOrOddPrinter: def printEvenOrOdd(self, num): if num.isEven(): print num.getNumber(), ": is even" else: print num.getNumber(), ": is odd" def evenOrOdd(self, howMany, start): for i in range(howMany): k = i+start self.printEvenOrOdd(Number(k)) EvenOrOddPrinter().evenOrOdd(10, 8)
OOExample.py: TIME
Timeless description
- f classes (~functional
paradigm) and moreover a "call", i.e. a sequence of instantiations, assignments and methods calls (~imperative paradigm).
25 HaPoC - 2013
Conclusions
3 semiotic perspective
levels good practices theory of enunciation
Theory of enunciation can improve comprension of programming paradigms
- > Narratology, Gérard Genette
26 HaPoC - 2013