Towards a Semiotic Framework for Programming Languages Andrea Valle - - PowerPoint PPT Presentation

towards a semiotic framework for programming languages
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

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

slide-3
SLIDE 3

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, ...

slide-4
SLIDE 4

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
slide-5
SLIDE 5

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
slide-6
SLIDE 6

6 HaPoC - 2013

Perspectives

 Low-level vs. High-level languages  Good practices  Enunciation analysis of programming paradigms

slide-7
SLIDE 7

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

slide-8
SLIDE 8

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

slide-9
SLIDE 9

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?

slide-10
SLIDE 10

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

slide-11
SLIDE 11

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.

slide-12
SLIDE 12

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.

slide-13
SLIDE 13

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

slide-14
SLIDE 14

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
slide-15
SLIDE 15

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
slide-16
SLIDE 16

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

slide-17
SLIDE 17

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

slide-18
SLIDE 18

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

slide-19
SLIDE 19

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)

slide-20
SLIDE 20

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.

slide-21
SLIDE 21

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

slide-22
SLIDE 22

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.

slide-23
SLIDE 23

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
slide-24
SLIDE 24

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).

slide-25
SLIDE 25

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
slide-26
SLIDE 26

26 HaPoC - 2013

Thanks for your time!