SlideShare una empresa de Scribd logo
1 de 23
Creare un proprio linguaggio di programmazione
per il web e applicazioni desktop.
Gabriele Guizzardi

        guizzardi@brainandbytes.com – Brain & Bytes
        guizzardi@gmail.com - Guizzardi.net
La domanda
Ha senso realizzare un altro linguaggio di
  programmazione vista la grande disponibilità di
  linguaggi e dialetti di cui si dispone?
E' ancora possibile spendere decine di ore di
  lavoro per creare un linguaggio nuovo e su
  misura per se stessi?


                                                Nome speaker    2
                          Mail speaker – company or community
Il progetto
Scopo: realizzare un linguaggio di programmazione
Target: risolvere specifici problemi con specifici comandi
Tipo: linguaggio interpretato funzionale
Struttura: scanner, lexer, parser, token
Linguaggio utilizzato: C
Utilizzo: scripting
Nome: SKIMPY :-)


                                                          Nome speaker    3
                                    Mail speaker – company or community
Gli scopi
Creare un linguaggio formale
Utilizzo di istruzioni classiche di un linguaggio
Protocolli di comunicazione (seriale, parallelo, TCP,
  ecc.)
Utilizzo di tecnologie hardware quali modem GSM,
  lettori di token o badge
Gestione file di testo o strutturati (XML, CSV, ecc.)
Utilizzo batch (client/server) e web
                                                    Nome speaker    4
                              Mail speaker – company or community
Caratteristiche (pregi)
Dimensioni ridotte
Pochi cicli macchina per istruzione
Sintassi semplificata
Grammatica elementare
Portabilità


                                                Nome speaker    5
                          Mail speaker – company or community
Caratteristiche (difetti)
Istruzioni di base
Assenza di annidamento istruzioni
Assenza di annidamento file sorgenti
Sintassi essenziale



                                               Nome speaker    6
                         Mail speaker – company or community
La tecnologia web




                               Nome speaker    7
         Mail speaker – company or community
Linguaggio formale


insieme delle stringhe derivate da una grammatica
insieme delle stringhe fornite da una espressione
insieme delle stringhe accettate da un automa
controlli binari (true/false)
condizioni di controllo


                                                     Nome speaker    8
                               Mail speaker – company or community
Gli step realizzativi
sintassi del linguaggio in generale (formalismo)
sintassi di ogni singola istruzione

  <istruzione> ::= <comando> <parametro/i> | <variabile> <valore>
               <numero> ::= <cifra> | <numero> <cifra>
               <cifra> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

consiglio: diagrammi di flusso

                                                         Nome speaker    9
                                   Mail speaker – company or community
Le basi del linguaggio (analisi lessicale)

leggere il programma sorgente in elementi del lessico.
separare i relativi elementi del lessico (token).
eliminare sequenze inutili di caratteri come i commenti.
collezionare informazioni in array o tabelle (p.e. per le
   variabili).


                                                       Nome speaker    10
                                 Mail speaker – company or community
Le basi del linguaggio (analisi sintattica)
processo dei token del linguaggio

“IF a = 0” è formato da 4 token, cioè IF, a, = e 0

Data una grammatica non contestuale G e una stringa x di
  caratteri terminali, analizzare sintatticamente x significa
  determinare se x appartiene a L(G) e, in tale caso,
  costruire l’albero sintattico di x.

                                                       Nome speaker    11
                                 Mail speaker – company or community
L'interprete
lettura del file sorgente scartando ogni commento
ogni riga del file viene bufferizzata ed eseguita
controllo della sintassi del comando in modo che non sia
   eseguito un comando errato
controllo della sintassi del comando in modo che non sia
   eseguito un comando con un numero di parametri errati
discriminazione di un carattere da una variabile ($)


                                                     Nome speaker    12
                               Mail speaker – company or community
L'interprete
<variabile> | <variabile d’ambiente> | <costante> ::= $<lettera>

WRITE | <testo> | <testo> <var.> | <var.> | <var. d’ambiente>

                    WRITE “Ciao Mondo!”

                  LOAD <variabile> <valore>

                         LOAD a 100
                                                        Nome speaker    13
                                  Mail speaker – company or community
Esempio di codice
/programma di esempio
write
write "Demo Funzioni Matematiche"
line 20
write                          mul c $a $b
                               write $a " ^ " $b " = " $c
load a 4                                                                or c $a $b
load b 6                       div c $a $b                              write $a " OR " $b " = " $c
                               write $a " / " $b " = " $c
add c $a $b                                                             xor c $a $b
write $a " + " $b " = " $c     mod c $a $b                              write $a " XOR " $b " = " $c
                               write $a " / " $b " resta " $c
sub c $a $b                                                             md5 x f test.txt
write $a " - " $b " = " $c     and c $a $b                              write "MD5 di prova.txt = " $x
                               write $a " AND " $b " = " $c
                                                                        md5 x s password
                                                                        write "MD5 di password = " $x
                                                                          Nome speaker                 14
                                                    Mail speaker – company or community
Risultato dell'esempio di codice




                                       Nome speaker    15
                 Mail speaker – company or community
Esempio di codice per il web
#!c:/SKIMPY/skimpy.exe
webheader
write "<b><i>Demo Funzioni Matematiche<br></i></b>"
line 20
write "<br>"                         mod c $a $b
load a 4                             write "Il resto di " $a " / " $b " è " $c "<br>"
load b 6                                and c $a $b
   add c $a $b                          write $a " AND " $b " = " $c "<br>"
   write $a " + " $b " = " $c "<br>" or c $a $b
   sub c $a $b                          write $a " OR " $b " = " $c "<br>"
   write $a " - " $b " = " $c "<br>"    xor c $a $b
   mul c $a $b                          write $a " XOR " $b " = " $c "<br>"
   write $a " ^ " $b " = " $c "<br>"
div c $a $b                              write "MD5 di prova.txt = "                 write "MD5 di password = "
write $a " / " $b " = " $c "<br>"        md5 x f test.txt                            md5 x s password
                                         write $x "<br>"                             write $x "<br>"

                                                                                 Nome speaker             16
                                                           Mail speaker – company or community
Risultato dell'esempio di codice




                                       Nome speaker    17
                 Mail speaker – company or community
Utilizzo su web host

GET          SKIMPY                                Prog.




                                       Nome speaker        18
                 Mail speaker – company or community
Utilizzo su web host




                                 Nome speaker    19
           Mail speaker – company or community
Utilizzo su web host




                                 Nome speaker    20
           Mail speaker – company or community
Il codice relativo
#!c:/SKIMPY/skimpy.exe
webheader

write "<FORM METHOD=GET ACTION='demoweb.smy'>"
write "valore 1: <INPUT NAME='valore1'><BR>"
write "valore 2: <INPUT NAME='valore2'><BR>"
write "<INPUT TYPE=SUBMIT></FORM>"
                                             goto esci
write $webgetenv "<br>"                      :accedi
write $webgetvalue1 "<br>"                   write "<p style='width:40%; color:#660099;
write $webgetvalue2 "<br>"                   text-align:left; background-color:#ffcc00;'
write "<br>"                                 >Password Corretta!<br>"
md5 x s $webgetvalue2                        extreturn
write "MD5 di " $webgetvalue2 " = " $x       :esci
                                             write "<br>Password Sbagliata!<br>"
if $x == "5f4dcc3b5aa765d61d8327deb882cf99"  extreturn
  goto accedi
                                                                    Nome speaker    21
                                              Mail speaker – company or community
Integrazione con altri linguaggi

write "<script type='text/javascript'>alert('Password Corretta!')</script>"



write "<p style='width:40%; color:#660099; text-align:left;
                   background-color:#ffcc00;' >Password Corretta!<br>"




                                                                  Nome speaker    22
                                            Mail speaker – company or community
Conclusioni
Quante ore uomo abbiamo impiegato?
Quanto tempo per scrivere la base del linguaggio?
Quanto tempo per scrivere nuove istruzioni?
Siamo “portabili” e “compatibili”?
Il ciclo di vita può essere compromesso a breve?
I costi sostenuti sono proporzionati al risultato?


                                                   Nome speaker    23
                             Mail speaker – company or community

Más contenido relacionado

Similar a Creare un proprio linguaggio di programmazione per il web e applicazioni desktop, by Gabriele Guizzardi

Sviluppo web dall'antichità all'avanguardia e ritorno
Sviluppo web  dall'antichità all'avanguardia e ritornoSviluppo web  dall'antichità all'avanguardia e ritorno
Sviluppo web dall'antichità all'avanguardia e ritornolordarthas
 
Come sviluppo le applicazioni web
Come sviluppo le applicazioni webCome sviluppo le applicazioni web
Come sviluppo le applicazioni webAndrea Lazzarotto
 
Php mysql e cms
Php mysql e cmsPhp mysql e cms
Php mysql e cmsorestJump
 
MongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDBMongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDBStefano Dindo
 
Dominare il codice legacy
Dominare il codice legacyDominare il codice legacy
Dominare il codice legacyTommaso Torti
 
Seminario team working - 21-1-2015
Seminario team working - 21-1-2015Seminario team working - 21-1-2015
Seminario team working - 21-1-2015Alessandro Loffredo
 
Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti...
 Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti... Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti...
Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti...Fulvio Corno
 
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore RomeoHTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeomarcocasario
 
Server linux samba in un dominio
Server linux samba in un dominioServer linux samba in un dominio
Server linux samba in un dominioSaverio Menin
 
Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017
Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017
Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017Codemotion
 
Drupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e DrupalDrupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e DrupalDrupalDay
 
[BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA][BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA]Matteo Collica
 
Py a6 python-database
Py a6 python-databasePy a6 python-database
Py a6 python-databaseMajong DevJfu
 
Lezione5 - MIPS & SPIM Unicam
Lezione5 - MIPS & SPIM UnicamLezione5 - MIPS & SPIM Unicam
Lezione5 - MIPS & SPIM UnicamNicola Paoletti
 
Syntactical errors detection 2
Syntactical errors detection 2Syntactical errors detection 2
Syntactical errors detection 2LucaPostiglione2
 
Building Scala with Bazel - Scala Days
Building Scala with Bazel - Scala DaysBuilding Scala with Bazel - Scala Days
Building Scala with Bazel - Scala DaysNatan Silnitsky
 
Laboratorio Di Basi Di Dati 09 Il Linguaggio P H P
Laboratorio Di  Basi Di  Dati 09  Il Linguaggio  P H PLaboratorio Di  Basi Di  Dati 09  Il Linguaggio  P H P
Laboratorio Di Basi Di Dati 09 Il Linguaggio P H Pguestbe916c
 

Similar a Creare un proprio linguaggio di programmazione per il web e applicazioni desktop, by Gabriele Guizzardi (20)

Sviluppo web dall'antichità all'avanguardia e ritorno
Sviluppo web  dall'antichità all'avanguardia e ritornoSviluppo web  dall'antichità all'avanguardia e ritorno
Sviluppo web dall'antichità all'avanguardia e ritorno
 
Come sviluppo le applicazioni web
Come sviluppo le applicazioni webCome sviluppo le applicazioni web
Come sviluppo le applicazioni web
 
Php mysql3
Php mysql3Php mysql3
Php mysql3
 
Php mysql e cms
Php mysql e cmsPhp mysql e cms
Php mysql e cms
 
MongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDBMongoDB User Group Padova - Overviews iniziale su MongoDB
MongoDB User Group Padova - Overviews iniziale su MongoDB
 
Dominare il codice legacy
Dominare il codice legacyDominare il codice legacy
Dominare il codice legacy
 
Bash programming
Bash programmingBash programming
Bash programming
 
Bash intro
Bash introBash intro
Bash intro
 
Seminario team working - 21-1-2015
Seminario team working - 21-1-2015Seminario team working - 21-1-2015
Seminario team working - 21-1-2015
 
Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti...
 Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti... Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti...
Scripting - Esecuzione condizionale - Costrutti iterativi - Variabili (quoti...
 
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore RomeoHTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
HTML5 Italy: Mai più CSS, fogli di stile moderni con LESS - Salvatore Romeo
 
Server linux samba in un dominio
Server linux samba in un dominioServer linux samba in un dominio
Server linux samba in un dominio
 
Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017
Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017
Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017
 
Drupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e DrupalDrupal Day 2011 - Node.js e Drupal
Drupal Day 2011 - Node.js e Drupal
 
[BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA][BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA]
 
Py a6 python-database
Py a6 python-databasePy a6 python-database
Py a6 python-database
 
Lezione5 - MIPS & SPIM Unicam
Lezione5 - MIPS & SPIM UnicamLezione5 - MIPS & SPIM Unicam
Lezione5 - MIPS & SPIM Unicam
 
Syntactical errors detection 2
Syntactical errors detection 2Syntactical errors detection 2
Syntactical errors detection 2
 
Building Scala with Bazel - Scala Days
Building Scala with Bazel - Scala DaysBuilding Scala with Bazel - Scala Days
Building Scala with Bazel - Scala Days
 
Laboratorio Di Basi Di Dati 09 Il Linguaggio P H P
Laboratorio Di  Basi Di  Dati 09  Il Linguaggio  P H PLaboratorio Di  Basi Di  Dati 09  Il Linguaggio  P H P
Laboratorio Di Basi Di Dati 09 Il Linguaggio P H P
 

Más de Codemotion

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyCodemotion
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaCodemotion
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserCodemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 - Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Codemotion
 

Más de Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Creare un proprio linguaggio di programmazione per il web e applicazioni desktop, by Gabriele Guizzardi

  • 1. Creare un proprio linguaggio di programmazione per il web e applicazioni desktop. Gabriele Guizzardi guizzardi@brainandbytes.com – Brain & Bytes guizzardi@gmail.com - Guizzardi.net
  • 2. La domanda Ha senso realizzare un altro linguaggio di programmazione vista la grande disponibilità di linguaggi e dialetti di cui si dispone? E' ancora possibile spendere decine di ore di lavoro per creare un linguaggio nuovo e su misura per se stessi? Nome speaker 2 Mail speaker – company or community
  • 3. Il progetto Scopo: realizzare un linguaggio di programmazione Target: risolvere specifici problemi con specifici comandi Tipo: linguaggio interpretato funzionale Struttura: scanner, lexer, parser, token Linguaggio utilizzato: C Utilizzo: scripting Nome: SKIMPY :-) Nome speaker 3 Mail speaker – company or community
  • 4. Gli scopi Creare un linguaggio formale Utilizzo di istruzioni classiche di un linguaggio Protocolli di comunicazione (seriale, parallelo, TCP, ecc.) Utilizzo di tecnologie hardware quali modem GSM, lettori di token o badge Gestione file di testo o strutturati (XML, CSV, ecc.) Utilizzo batch (client/server) e web Nome speaker 4 Mail speaker – company or community
  • 5. Caratteristiche (pregi) Dimensioni ridotte Pochi cicli macchina per istruzione Sintassi semplificata Grammatica elementare Portabilità Nome speaker 5 Mail speaker – company or community
  • 6. Caratteristiche (difetti) Istruzioni di base Assenza di annidamento istruzioni Assenza di annidamento file sorgenti Sintassi essenziale Nome speaker 6 Mail speaker – company or community
  • 7. La tecnologia web Nome speaker 7 Mail speaker – company or community
  • 8. Linguaggio formale insieme delle stringhe derivate da una grammatica insieme delle stringhe fornite da una espressione insieme delle stringhe accettate da un automa controlli binari (true/false) condizioni di controllo Nome speaker 8 Mail speaker – company or community
  • 9. Gli step realizzativi sintassi del linguaggio in generale (formalismo) sintassi di ogni singola istruzione <istruzione> ::= <comando> <parametro/i> | <variabile> <valore> <numero> ::= <cifra> | <numero> <cifra> <cifra> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 consiglio: diagrammi di flusso Nome speaker 9 Mail speaker – company or community
  • 10. Le basi del linguaggio (analisi lessicale) leggere il programma sorgente in elementi del lessico. separare i relativi elementi del lessico (token). eliminare sequenze inutili di caratteri come i commenti. collezionare informazioni in array o tabelle (p.e. per le variabili). Nome speaker 10 Mail speaker – company or community
  • 11. Le basi del linguaggio (analisi sintattica) processo dei token del linguaggio “IF a = 0” è formato da 4 token, cioè IF, a, = e 0 Data una grammatica non contestuale G e una stringa x di caratteri terminali, analizzare sintatticamente x significa determinare se x appartiene a L(G) e, in tale caso, costruire l’albero sintattico di x. Nome speaker 11 Mail speaker – company or community
  • 12. L'interprete lettura del file sorgente scartando ogni commento ogni riga del file viene bufferizzata ed eseguita controllo della sintassi del comando in modo che non sia eseguito un comando errato controllo della sintassi del comando in modo che non sia eseguito un comando con un numero di parametri errati discriminazione di un carattere da una variabile ($) Nome speaker 12 Mail speaker – company or community
  • 13. L'interprete <variabile> | <variabile d’ambiente> | <costante> ::= $<lettera> WRITE | <testo> | <testo> <var.> | <var.> | <var. d’ambiente> WRITE “Ciao Mondo!” LOAD <variabile> <valore> LOAD a 100 Nome speaker 13 Mail speaker – company or community
  • 14. Esempio di codice /programma di esempio write write "Demo Funzioni Matematiche" line 20 write mul c $a $b write $a " ^ " $b " = " $c load a 4 or c $a $b load b 6 div c $a $b write $a " OR " $b " = " $c write $a " / " $b " = " $c add c $a $b xor c $a $b write $a " + " $b " = " $c mod c $a $b write $a " XOR " $b " = " $c write $a " / " $b " resta " $c sub c $a $b md5 x f test.txt write $a " - " $b " = " $c and c $a $b write "MD5 di prova.txt = " $x write $a " AND " $b " = " $c md5 x s password write "MD5 di password = " $x Nome speaker 14 Mail speaker – company or community
  • 15. Risultato dell'esempio di codice Nome speaker 15 Mail speaker – company or community
  • 16. Esempio di codice per il web #!c:/SKIMPY/skimpy.exe webheader write "<b><i>Demo Funzioni Matematiche<br></i></b>" line 20 write "<br>" mod c $a $b load a 4 write "Il resto di " $a " / " $b " è " $c "<br>" load b 6 and c $a $b add c $a $b write $a " AND " $b " = " $c "<br>" write $a " + " $b " = " $c "<br>" or c $a $b sub c $a $b write $a " OR " $b " = " $c "<br>" write $a " - " $b " = " $c "<br>" xor c $a $b mul c $a $b write $a " XOR " $b " = " $c "<br>" write $a " ^ " $b " = " $c "<br>" div c $a $b write "MD5 di prova.txt = " write "MD5 di password = " write $a " / " $b " = " $c "<br>" md5 x f test.txt md5 x s password write $x "<br>" write $x "<br>" Nome speaker 16 Mail speaker – company or community
  • 17. Risultato dell'esempio di codice Nome speaker 17 Mail speaker – company or community
  • 18. Utilizzo su web host GET SKIMPY Prog. Nome speaker 18 Mail speaker – company or community
  • 19. Utilizzo su web host Nome speaker 19 Mail speaker – company or community
  • 20. Utilizzo su web host Nome speaker 20 Mail speaker – company or community
  • 21. Il codice relativo #!c:/SKIMPY/skimpy.exe webheader write "<FORM METHOD=GET ACTION='demoweb.smy'>" write "valore 1: <INPUT NAME='valore1'><BR>" write "valore 2: <INPUT NAME='valore2'><BR>" write "<INPUT TYPE=SUBMIT></FORM>" goto esci write $webgetenv "<br>" :accedi write $webgetvalue1 "<br>" write "<p style='width:40%; color:#660099; write $webgetvalue2 "<br>" text-align:left; background-color:#ffcc00;' write "<br>" >Password Corretta!<br>" md5 x s $webgetvalue2 extreturn write "MD5 di " $webgetvalue2 " = " $x :esci write "<br>Password Sbagliata!<br>" if $x == "5f4dcc3b5aa765d61d8327deb882cf99" extreturn goto accedi Nome speaker 21 Mail speaker – company or community
  • 22. Integrazione con altri linguaggi write "<script type='text/javascript'>alert('Password Corretta!')</script>" write "<p style='width:40%; color:#660099; text-align:left; background-color:#ffcc00;' >Password Corretta!<br>" Nome speaker 22 Mail speaker – company or community
  • 23. Conclusioni Quante ore uomo abbiamo impiegato? Quanto tempo per scrivere la base del linguaggio? Quanto tempo per scrivere nuove istruzioni? Siamo “portabili” e “compatibili”? Il ciclo di vita può essere compromesso a breve? I costi sostenuti sono proporzionati al risultato? Nome speaker 23 Mail speaker – company or community