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 && mazzei@di.unito.it
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 2 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, ... 3 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 4 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 5 HaPoC - 2013
Perspectives Low-level vs. High-level languages Good practices Enunciation analysis of programming paradigms 6 HaPoC - 2013
Levels Machine Code Assembler Control fmow -> structured programming Machine Assembler C++ Java Python Pseudo-code Italian, English code Javascript Flow-charts Low-levels High-levels Natural Languages Small relations to No relations to Really related to Von Neumann Von Neumann Von Neumann STORE, LOAD, ADD IF , WHILE 7 HaPoC - 2013
Good practices Seibel P ., 2009, Coders at Work, New York, Apress Readability -> the ideal human-reader comments indentation meaningful name syntax highlight 8 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? 9 HaPoC - 2013
ImperativeExample.py # Prints on the screen 10 numbers starting from 8 # and determines whether they are even or odd 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" 10 HaPoC - 2013
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. 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" 11 HaPoC - 2013
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. 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" 12 HaPoC - 2013
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 of memory addresses for the machine and "placeholders" for the human interpreter 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" 13 HaPoC - 2013
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 of memory addresses for the machine and "placeholders" for the human interpreter Life is too short for malloc start = 8 howMany = 10 -- Neal Ford for i in range(howMany): k = i + start if float(k)/2 == round(k/2): print k, ": is even" else: print k, ": is odd" 14 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 of simpler organisms into place. -- Alan Perlis 15 HaPoC - 2013
FunctionalExample.py 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) 16 HaPoC - 2013
FunctionalExample.py: SPACE 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) 17 HaPoC - 2013
FunctionalExample.py: PERSON def isEven(num): There is a request to the if fmoat(num)/2 == round(num/2): return True environment , no specifjc else: "YOU" is present here, to return False compute the output def printEvenOrOdd(num): value of a function over a if isEven(num): specifjc input value. print num, ": is even" else: Imaginary geography of print num, ": is odd" functions -> topology def evenOrOdd(howMany, start): map(printEvenOrOdd, range(start, start+howMany)) evenOrOdd(10, 8) 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: TIME def isEven(num): The function space also if fmoat(num)/2 == round(num/2): return True absorbs the time: the else: order in which the graph return False is explored does not def printEvenOrOdd(num): afect the fjnal result of if isEven(num): the computation. 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
OOExample.py 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) 21 HaPoC - 2013
OOExample.py: SPACE class Number: A taxonomy of classes def __init__(self, val): self.number = val that organizes the def isEven(self): if fmoat(self.number)/2 == round(self.number/2): world into objects return True else: -> fjelds, methods return False def getNumber(self): return self.number This feature hides class EvenOrOddPrinter: spatiality from the def printEvenOrOdd(self, num): if num.isEven(): world. 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) 22 HaPoC - 2013
OOExample.py: PERSONA class Number: name.method(args) def __init__(self, val): self.number = val -> def isEven(self): if fmoat(self.number)/2 == round(self.number/2): return True subject! else: return False Do this in this way! def getNumber(self): return self.number The "YOU" of the class EvenOrOddPrinter: enunciation is not the def printEvenOrOdd(self, num): if num.isEven(): calculation agent, but print num.getNumber(), ": is even" a plurality of possible else: print num.getNumber(), ": is odd" receivers, i.e. the def evenOrOdd(self, howMany, start): for i in range(howMany): objects k = i+start self.printEvenOrOdd(Number(k)) EvenOrOddPrinter().evenOrOdd(10, 8) 23 HaPoC - 2013
Recommend
More recommend