hacker emblemHai tempo que tiña oído falar da beleza da obra de Shakespeare, pero nunca lera nada dela. Un atopa unha linguaxe de programación fermosa como python e esquécese de seguir buscando algo mellor, sen se parar a pensar que ó mellor aínda se pode construír código cunha maior eleganza.

Pois ben, onte, de casualidade, atopei a que agora é a miña linguaxe de preferenza: Shakespeare. A súa beleza, a súa estética, o seu estilo é inigualable comparado co resto de linguaxes que levo visto ata o de agora. Será difícil que un día atope unha linguaxe que me pareza claramente mellor, que me sorprenda e agrade tanto.

Características

Ó principio da obra defínese un título.

Na obra deben intervir alomenos un actor. Os actores son os que gardan os valores (enteiros) durante a actuación. Os actores poden gardar máis dun valor empregando a súa memoria (unha pila, stack).

A obra divídise en actos e os actos en escenas. A obra debe ter alomenos un acto e un acto alomenos unha escena.

Nas escenas defínense os actores que entran e saen, pero en todo momento ten que haber un ou dous actores. Ó final da obra deben saír todos.

Os actores poden coller/dicir os seus valores en forma de enteiro ou de caracter ASCII asociado a ese valor. Para que un actor diga o seu valor enteiro o outro actor debe dicir: “Open your heart”, mentres que se se quere o código ASCII deberá dicir: “Speak your mind”. De igual xeito, para que un actor colla un valor o outro actor deberá dicir: “Open your mind” ou “Listen to your heart”.

Para darlle valor a un actor o outro actor ten que dicir: “You are as X as VALOR”. Onde X é un adxectivo e VALOR un enteiro.

Os enteiros constrúense operando (suma, resta, producto, etc) sobre potencias de dous construídas da seguinte maneira: ADXECTIVO1 ADXECTIVO2 ADXECTIVO3 … NOME. Se o nome ten cualidades positivas (rosa) vale 1, se ten cualidades negativas (porco) vale -1. Por cada adxectivo que preceda ó nome multiplícase por dous o valor.

Para máis información consultar a documentación de Shakespeare.

Obra en Shakespeare

Nada mellor que un exempro para se quedar atontado coa súa presenza. A seguinte obra calcula a área dun triángulo: primeiro pide a lonxitude da base e altura e logo devolve a área.

The Infamous Triangle Area Program.

Romeo, a intelligent man with bad intentions.
Juliet, a young and beautiful woman.
Ophelia, a old and beautiful woman.

Act I: About how they get the dimensions.

Scene I: Get the height.

[Enter Romeo and Juliet]

Romeo:
You are as pretty as twice the sum of a amazing noble angel and a
small red sweet peaceful lovely rose. Speak your mind!

You are as beautiful as the sum of yourself and a brave cute fair
happy honest pony. You are as beautiful as the difference between
yourself and the sum of a lovely angel and a pony. Speak your mind!

You are as cute as the sum of yourself and a sweet pretty flower.
Speak your mind!

You are as delicious as the difference between yourself and a brave
hero. Speak your mind!

You are as gentle as the sum of yourself and a King. Speak your mind!

You are as lovely as the sum of yourself and the sum of a peaceful
gentle Lord and a good honest noble King. Speak your mind!

You are as smooth as the quotient between yourself and a fair King.
You are as sweet as the sum of yourself and the sum of a happy rich
Lord and a King. Speak your mind!

Listen to your heart.

[Exit Juliet]

Scene II: Get the base.

[Enter Ophelia]

Romeo:
You are as amazing as the sum of twice a amazing charming cunning
embroidered reddest King and a fair hero. Speak your mind!

You are as fair as the sum of yourself and a cute fine handsome lovely
pretty King. You are as fair as the difference between yourself and a
Lord. Speak your mind!

You are as good as the sum of yourself and a good fair noble fine rose.
You are as good as the sum of yourself and a good flower. Speak your
mind!

You are as honest as the difference between yourself and a lovely
loving cute pretty angel. You are as honest as the sum of yourself and
a fair angel. Speak your mind!

You are as noble as the difference between yourself and a fair fine
gentle good honest King. You are as noble as the difference between
yourself and a rich happy Lord. You are as noble as the difference
between yourself and a good pony. Speak your mind!

Listen to your heart.

[Exeunt Romeo and Ophelia]

Act II: About how they calculate the result.

Scene I: To calculate the result.

[Enter Romeo and Juliet]

Juliet:
You are as pretty as the quotient between myself and a sweet summer’s day.

[Exit Juliet]

[Enter Ophelia]

Ophelia:
You are as pretty as the product of yourself and myself.

Scene II: Show the result.

Ophelia:
Open your heart.

[Exeunt Romeo and Ophelia]

A forma máis sinxela para ve-la obra é baixarse o código fonte de Shakespeare e copia-la obra no subdirectorio examples/ e executar make.


2 Responses to “Shakespeare, unha linguaxe de programación”

  1. 1 TeRMi

    Habrá algo si con Benedetti ou con Rafael Dieste?

    P.D: na miña modesta opinión máis fermosos que shespir. 😀

  2. 2 xoseotero

    En SourceForge non atopei nada 😀


Categories

Calendario

Xullo 2006
M T W T F S S
« Xuñ   Ago »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
3K2 theme by Hakan Aydin