Commit 369ff4a9 authored by Alex Marandon's avatar Alex Marandon

Add context material

parent d4caa76b
......@@ -8,9 +8,299 @@
}
},
"source": [
"<center>\n",
"\n",
"# Elixir\n",
"\n",
"## Plus qu'un langage, une plateforme"
"\n",
"<img src=\"img/elixir.png\">\n",
"\n",
"\n",
"## Plus qu'un langage, une plateforme\n",
"\n",
"</center>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Concurrence et parallélisme"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### Concurrence\n",
"\n",
"Progressions dans le même intervalle de temps (CPU partagé)\n",
"\n",
"### Parallélisme\n",
"\n",
"Progressions réellement simultanées (plusieurs CPUs)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Pourquoi faire ?"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### Faire plusieurs choses en même temps\n",
"\n",
"- servir plusieurs utilisateurs en même temps (WebSockets)\n",
"- ne pas bloquer lors d'accès à des ressources externes (I/O)\n",
"- effectuer plusieurs calculs en même temps\n",
"\n",
"### Exploiter tous les coeurs de la machine\n",
"\n",
"La vitesse des processeurs n'augmente plus beaucoup mais le nombre de coeurs augmente."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Approches possibles\n",
"\n",
"### Processus système\n",
"\n",
"#### Exemples \n",
"\n",
"- système d'exploitation multitâche\n",
"- application web type Django ou Ruby on Rails"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"### Inconvénients\n",
"\n",
"- consommateur de ressources\n",
"- mécanismes de communication spécifiques (IPC)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Threads\n",
"\n",
"#### Exemples\n",
"\n",
"- IHM qui déclenche des calculs sans se blo\n",
"- serveur d'application web type Apache Tomcat"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"#### Inconvénients\n",
"\n",
"- mécanismes d'exclusion mutuelle nécessaires\n",
"- encore relativement consommateur de ressources"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Programmation asynchrone\n",
"\n",
"#### Exemples\n",
"\n",
"- Node.js\n",
"- Tornado, asyncio"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"#### Inconvénients\n",
"\n",
"- impact important sur le code (callbacks, async/await)\n",
"- pas de parallélisme possible\n",
"- pas d'isolation des erreurs"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"![](img/erlang.png)\n",
"\n",
"Source : [Erlang the Movie](https://www.youtube.com/watch?v=BXmOlCy0oBM) (lien YouTube)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Erlang/OTP\n",
"\n",
"- processus **légers** isolés\n",
"- code séquentiel pas impacté\n",
"- passage de messages natifs\n",
"- ~mutexes~, ~`synchronized`~\n",
"- ~race conditions~"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Mais encore !\n",
"\n",
"- tolérance aux erreurs\n",
"- programmation distribuée\n",
"- mise à jour de code à chaud\n",
"- bonne performance **ressentie**"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Et bien sûr\n",
"\n",
"Libre depuis 1998. Actuellement sous licence Apache 2.0"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Inconvénients\n",
"\n",
"- syntaxe *étrange*, eg. plusieurs séparateurs d'expression : `,` `;` et `.`\n",
"- support limité des namespaces et chaines de caractères\n",
"- outillage un peu à la traine (tests, build, doc, gestions de dépendances, etc.)\n",
"- ambience un peu old-school"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"![](img/joe.png)\n",
"\n",
"Joe Armstrong en 1990 dans [Erlang the Movie](https://www.youtube.com/watch?v=BXmOlCy0oBM) (lien YouTube)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](img/erlang-ecosystem.png)\n",
"\n",
"Source : [The Erlang Ecosystem - Robert Virding](https://vimeo.com/283416243) (lien Vimeo)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Elixir\n",
"\n",
"- Construit sur la machine virtuelle et le framework de Erlang\n",
"- Syntaxe plus familière inspirée par Ruby, Python, etc.\n",
"- Tout l'outillage moderne :\n",
" - gestion de dépendances avec intégration git\n",
" - tests\n",
" - documentation\n",
" - doctests\n",
" - formattage automatique\n",
" - générateur de projets"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"![](img/jose.png)\n",
"\n",
"José Valim en 2019 dans [The One Who Created Elixir](https://www.welcometothejungle.com/en/articles/btc-elixir-jose-valim)"
]
},
{
......@@ -21,6 +311,8 @@
}
},
"source": [
"## Le langage Elixir\n",
"\n",
"Quelques caractéristiques intéressantes :\n",
"\n",
"- programmation fonctionnelle\n",
......@@ -28,8 +320,7 @@
"- *pattern matching*\n",
"- fonctions multi-clauses\n",
"- *pattern matching* binaire\n",
"- appels de fonctions chainés avec l'opérateur `|>`\n",
"- métaprogrammation à base de macros"
"- appels de fonctions chainés avec l'opérateur `|>`"
]
},
{
......@@ -47,6 +338,50 @@
"- ~objets~, ~classes~"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares = Enum.map(1..10, fn x ->\n",
" x * x\n",
"end)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[4, 16, 36, 64, 100]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"even_squares = Enum.filter(squares, fn x ->\n",
" rem(x, 2) == 0\n",
"end)"
]
},
{
"cell_type": "markdown",
"metadata": {
......@@ -701,11 +1036,20 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Mais encore\n",
"\n",
"- protocoles (un peu comme des interfaces à la mode fonctionelle)\n",
"- métaprogrammation à base de macros\n",
"- les sigils eg. `~w(liste de mots)`\n",
"- vérification de types optionnelle"
]
}
],
"metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment