Things learned this week 1

in everythingelse

03·07·2009

Tags: , , ,

Symlinks, Message passing, Fronde immaginarie, la crisi in Europa e la moralità dei debiti

Things ‘learned’ this week:

programming

symlinks

Very quick learning, to create a symlink (Symbolic link)

ln -s path-of-file-to-be-linked link

a symbolic link seems to be a file whose content is the path to another file, if you destroy the original file the link is still there but points to nothing (it is a name for nothing, nice definition from myself). Compare this to an hardlink which is in fact another name for the same content – if you delete the original file the content is still available through the hardlink etc.

Data directed, conventional style and message passing

I’m ‘following’ the cs61a Berkeley course (see also Brian Harvey) on youtube (I have nothing to do). This week the main thing I’ve learned is, perhaps, this:

To read this forget what you already know about object oriented programming.

Suppose you have defined a data type ’square’ which is defined by its side. Now you write a function area that return the value of the area.


def square (s):
  return {'type' : 'square' , 'side' : s}

mysquare = square (2)

def area (s):
  return s['side'] * s['side']

area (mysquare)

>>4

Now, suppose you add another data type, a rectangle


def rectangle (w,h):
  return {'type' : 'rectangle' , 'width' : w , \
  'height' : h}

myrectangle = rectangle (2,3)

you would like to call area for your rectangle too. What you can do, for example, is to modify the area function to allow it to discriminate between squares and rectangles:


def area (f):

  if f['type'] == 'square':
    return f['side'] * f['side']

  elif f['type'] == 'rectangle':
    return f['width'] * f['height']

  else: raise Exception ('Unknown type')

If you have other functions like perimeter, etc., you can rewrite each of them in the same way. Brian Harvey names this approach: conventional style.
But you can deal with the same problem in different ways. To have a clear picture of the problem Harvey draws a table:

area perimeter etc.
square x*x 4*x etc.
rectangle h*w 2*(h+w) etc.

Conventional style is like reading the columns of the table. Each function (square , … ) needs to know how to deal with the different figures (the if statement in the function).
Suppose instead to deal with the table as a whole:


dd = {'square':\
  {'area': lambda x: x['side'] * x['side']} ,\
  'rectangle':\
  {'area': lambda x: x['width'] * x['height']}}

def operate (x, function):
  return dd[x['type']][function] (x)

Now I can simply write: operate (mysquare, ‘area’) or operate (myrectangle, ‘area’). If I really want I still can have the function area:


def area (x):
  return operate (x, 'area')

This is what Harvey calls data directed approach.

The third way you can read the table is by reading row by row, and now each data type have to discriminate between function calls (this is opposed to the previous conventional style where the function operate the distinction between data type).


def square (s):
  def ask (message):
    if message == 'area':
      return s*s
    elif message == 'perimeter':
      return s*4
    else:
      raise Exception ('message unknown')
  return ask

s = square (3)
s('area')
>> 9

s('perimeter')
>> 12

This approach is called message passing and, yes, is the core of what they call object oriented (and, yes, my example is stupid because in python you do have objects).

Società

Il nostro problema

Ho letto qui un intervento di Augusto Illuminati in cui si ipotizza una detronizzazione per berlusconi per sostituirlo con una specie di esecutivo di salvezza nazionale (nel caso ‘grave’) o con una paludona neodemocristiana (nel caso ‘meno grave’). Grave e meno grave è un giudizio sull’andamento della crisi e sulla virulenza del conflitto sociale che si determinerebbe.

Penso però che siano ipotesi abbastanza indimostrate, in particolare mi lascia qualche dubbio: a. che i conflitti sociali latenti siano in grado di esprimersi in modo tanto preoccupante da b. determinare la capacità all’interno della destra di mettere da parte berlusconi, con l’appoggio di un partito democratico che dovrebbe c. esprimere qualche capacità di iniziativa (ipotesi remota) oppure d. spaccarsi veramente.

Crisi

Sul manifesto del 4 luglio un articolo di J. Halevi si sofferma sulla direzione che sta prendendo la Germania in questa crisi. È stata introdotta in Germania una modifica alla costituzione per impedire che il deficit sfori il 0,35% del pil. Halevi, citando il Financial Times, riporta alcuni dei possibili esiti di questa decisione: la politica avrà le mani legate e sarà costretta essenzialmente a politiche di rigore anche quando queste possono peggiorare i momenti di recessione. Nella fase attuale, dice Wolfgang Munchau, questo potrebbe appunto peggiorare la situazione in Germania, deprimendo ancora di più l’economia in tutta Europa. Ma non solo questo: la Francia non sembra affatto intenzionata a seguire la stessa politica e, se i due paesi principali vanno ognuno per conto proprio le cose sembrano non mettersi bene.

Halevi ritiene che il senso di questa scelta sia la tendenza del capitale tedesco a una crescita basata sulle esportazioni, per cui un generale abbassamento dei salari è una cosa positiva (anche se deprime la domanda interna).

Se capisco quello che Halevi dice, si scatenerebbe in tutta Europa una gara ad abbassare i salari per essere competitivi sul piano delle esportazioni (un tempo si procedeva con svalutazione della moneta, adesso in area Euro non è più possibile).

Come ricorda Munchau, questo surplus tedesco che nel passato recente andava verso i famigerati mutui subprime e derivati americani, adesso dovrebbe trovare un altro sbocco, non potendo nemmeno finire in bond governativi tedeschi, finirebbe in bond francesi, per finanziare la spesa pubblica francese, e la germania finirebbe “intrappolata nel debito francese come la Cina è intrappolata in quello Usa”. La Germania si troverebbe a soffrire sia delle politiche depressive innescate dal rigore costituzionalizzato, sia un basso livello di ritorno sugli investimenti in bond francesi e finirebbero in poche parole per finanziare la politica economica francese.

Trovo abbastanza istruttiva questa osservazione nell’articolo di Munchau:

While the balanced budget law is economically illiterate, it is also universally popular. Average Germans do not primarily regard debt in terms of its economic meaning, but as a moral issue. Der Spiegel, the German news magazine, had an intriguing report last week on the country’s young generation. One of the protagonists in its story was a young woman who had borrowed a little money to set up her own company. The company turned out to be a success, and she had began to repay the loan. And yet she said she had not felt proud of having taken on debt.

This general level of debt-aversion is bizarre. Many ordinary Germans regard debt as morally objectionable, even if it is put to proper use. They see the financial crisis primarily as a moral crisis of Anglo-Saxon capitalism. The balanced budget constitutional law is therefore not about economics. It is a moral crusade, and it is the last thing, Germany, the eurozone and the world need right now.

Qui ci sono parecchie cose interessanti sul senso della lettura in chiave morale della crisi e sui perversi effetti della depoliticizzazione dell’economia.


COMMENTS

comments rss | trackback uri

Leave your feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>