diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-05-10 17:20:10 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-05-10 17:20:10 +0200 |
commit | 7910e2910daa33af41cef729dcf2408a106473de (patch) | |
tree | b531d45766cafb9846cfc5ad8e0d6e121da38cb5 | |
parent | 54ba43b15f6875e1d65ebed772c5dd678bb4752c (diff) |
Add html version
-rw-r--r-- | erlang.html | 415 |
1 files changed, 415 insertions, 0 deletions
diff --git a/erlang.html b/erlang.html new file mode 100644 index 0000000..d363274 --- /dev/null +++ b/erlang.html @@ -0,0 +1,415 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <meta name="generator" content="pandoc"> + <meta name="author" content="Guido Günther"> + <meta name="dcterms.date" content="2016-05-09"> + <title>Wissenswertes über Erlang</title> + <meta name="apple-mobile-web-app-capable" content="yes"> + <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> + <link rel="stylesheet" href="reveal.js/css/reveal.css"/> + <style type="text/css">code{white-space: pre;}</style> + <link rel="stylesheet" href="reveal.js/css/theme/black.css" id="theme"> + <!-- Printing and PDF exports --> + <script> + var link = document.createElement( 'link' ); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css'; + document.getElementsByTagName( 'head' )[0].appendChild( link ); + </script> + <!--[if lt IE 9]> + <script src="reveal.js/lib/js/html5shiv.js"></script> + <![endif]--> +</head> +<body> + <div class="reveal"> + <div class="slides"> + +<section> + <h1 class="title">Wissenswertes über Erlang</h1> + <h2 class="author">Guido Günther</h2> + <h3 class="date">2016-05-09</h3> +</section> + +<section id="who-am-i" class="slide level1"> +<h1>Who am I</h1> +<ul> +<li>Free Software Hacker (Freelancing Software Developer)</li> +<li>Debian Developer since 2000</li> +<li>Contributed to libvirt-*, X11, Linux Kernel, GNOME, Calypso, …</li> +<li>FSFE Fellow and GNOME Foundation member</li> +<li>Rather new to Erlang</li> +</ul> +</section> +<section id="erl-what" class="slide level1"> +<h1>Erl-what?</h1> +<ul> +<li>Developed at Ericsson in 1986</li> +<li>Open sourced 1998</li> +<li>Ericsson Language or Agner Krarup Erlang?</li> +<li><p>For telephone systems</p></li> +<li>Functional, concurrent programming language</li> +<li>Garbage collected runtime system</li> +<li><p>Erlang/OTP</p></li> +</ul> +</section> +<section id="erlang-features" class="slide level1"> +<h1>Erlang, Features</h1> +<ul> +<li>Fault tolerant</li> +<li>Hot code replacements</li> +<li>Distributed</li> +<li>highly available - 12 years of uptime - nine 9s (30 ms / a)</li> +</ul> +</section> +<section id="projects" class="slide level1"> +<h1>Projects</h1> +<ul> +<li>ejabberd, Riak, CouchDB, RabbitMQ</li> +<li>WhatsApp, GitHub, Facebook, …</li> +</ul> +</section> +<section id="you-lack-style---no-state" class="slide level1"> +<h1>You lack style - no, state!</h1> +</section> +<section class="slide level1"> + +<h2 id="functional-language">Functional language</h2> +<p>f(x) = y</p> +</section> +<section class="slide level1"> + +<p>i = i + 3</p> +</section> +<section class="slide level1"> + +<p><del>i = i + 3</del></p> +</section> +<section class="slide level1"> + +<p>for (int i=0; i < 3; i++) do_something(i);</p> +</section> +<section class="slide level1"> + +<p><del>for (int i=0; i < 3; i++) do_something(i);</del></p> +</section> +<section class="slide level1"> + +<pre><code>1> A=3. +3 +2> A=4. +** exception error: no match of right hand side value 4</code></pre> +</section> +<section class="slide level1"> + +<h2 id="no-means-no">No means No</h2> +<ul> +<li>No imperative programming</li> +<li>No global variables and state</li> +<li>No pointers</li> +<li>No variable reassignments</li> +</ul> +</section> +<section class="slide level1"> + +<ul> +<li>Yes, Higher Order Functions</li> +<li>Yes, Pattern Matching</li> +<li>Yes, Code Reloads</li> +<li>Yes, Lots of independent Processes</li> +</ul> +</section> +<section class="slide level1"> + +<h2 id="recursion-to-the-rescue">Recursion to the Rescue</h2> +<pre><code>loop(X) -> loop(X, 0). + +loop(X=0, Sum) -> Sum; +loop(X, Sum) -> loop(X-1, Sum+X).</code></pre> +</section> +<section class="slide level1"> + +<h2 id="recursion-in-detail">Recursion in Detail</h2> +<pre><code>loop(3) -> loop(3, 0) +loop(3,0) -> loop(3-1, 0+3) +loop(2,3) -> loop(2-1, 3+2) +loop(1,5) -> loop(1-1, 5+1) +loop(0,6) -> 6 + +3 + 2 + 1 = 6</code></pre> +</section> +<section class="slide level1"> + +<h2 id="head-to-wall-tail">Head to <del>Wall</del> Tail</h2> +<pre><code>A = [this, is, a, list]. +[H|T] = A.</code></pre> +</section> +<section class="slide level1"> + +<pre><code>rev(L) -> rev(L, []). + +rev([], N) -> N; +rev([H|T], N) -> rev(T, [H] ++ N).</code></pre> +</section> +<section class="slide level1"> + +<pre><code>rev([a,b,c,d]) -> rev([a,b,c,d], []) + +rev([a|[b,c,d]], []) -> rev([b,c,d], [a] ++ []) + +rev([b|[c,d]], [a]) -> rev([c,d], [b] ++ [a]) + +rev([c|[d]], [b,a]) -> rev([d], [c] ++ [b,a]) + +rev([d|[], [c,b,a]) -> rev([], [d] ++ [c,b,a]) + +rev([], [d,c,b,a]) -> [d,c,b,a]</code></pre> +</section> +<section class="slide level1"> + +<h2 id="more-pattern-matching">More pattern matching</h2> +<pre><code>A = {this, is, a, tuple}. +{_, _, _, B} = A.</code></pre> +</section> +<section class="slide level1"> + +<pre><code>> B. +tuple +> _. +* 1: variable '_' is unbound</code></pre> +</section> +<section class="slide level1"> + +<h3 id="fun-with-funs">Fun with Funs</h3> +<pre><code>F = fun (X) -> X*X end. +> F(3). +> F(ok).</code></pre> +</section> +<section class="slide level1"> + +<pre><code>> F(3). +9 +> F(ok). +** exception error: an error occurred when evaluating an arithmetic expression + in operator */2 + called as ok * ok</code></pre> +</section> +<section class="slide level1"> + +<h2 id="success-typing">Success, Typing!</h2> +<p>Dialyzer</p> +<pre><code>-spec foobar(atom()) -> [atom()]. +foobar(App) -> …</code></pre> +</section> +<section id="processes-which-processes" class="slide level1"> +<h1>Processes, which Processes</h1> +</section> +<section class="slide level1"> + +<h2 id="spawning-a-process">Spawning a process</h2> +<pre><code>F = fun(X) -> io:format("~p~n", [X]) end. +times(X, Args, C) -> ... + +spawn(l, times, [F, "I'm a process", 3]).</code></pre> +</section> +<section class="slide level1"> + +<pre><code>spawn(l, times, [F, "I'm a process", 3]), +spawn(l, times, [F, "I'm a process too", 3]).</code></pre> +</section> +<section class="slide level1"> + +<h2 id="concurrency-for-free">Concurrency for free!</h2> +<pre><code>"I'm a process" +"I'm a process too" +"I'm a process" +"I'm a process too" +<0.53.0> +"I'm a process" +"I'm a process too"</code></pre> +</section> +<section class="slide level1"> + +<h2 id="shared-nothing">Share(d) nothing</h2> +<pre><code>start_pong(Pid) -> … +pong(Pid) -> … + +> P = l:start_pong(self()). +> P ! { ping, "foo" }. +> P ! giveup.</code></pre> +</section> +<section class="slide level1"> + +<pre><code>> R = fun () -> receive M -> M end end.</code></pre> +</section> +<section class="slide level1"> + +<pre><code>> R(). +{pong,"hallo1"} +> R(). +{pong,"hallo2"}</code></pre> +</section> +<section class="slide level1"> + +<h2 id="let-it-crash">Let it crash</h2> +<pre><code>2> P ! {ping, 3}. +{ping,3} +3> +=ERROR REPORT==== 8-May-2016::15:13:30 === +Error in process <0.34.0> with exit value: +{badarg,[{io,format,[<0.25.0>,"pong: Received ping '~s'~n",[3]],[]}, + {l,pong,1,[{file,"l.erl"},{line,57}]}]}</code></pre> +</section> +<section class="slide level1"> + +<pre><code>2> P ! whatever +Unknwown message asfasdf, giving up</code></pre> +</section> +<section class="slide level1"> + +<h2 id="linking-processes">Linking processes</h2> +<pre><code>> process_flag(trap_exit, true). +> P = l:start_pong2(self()). +3> P ! sadfsadf. +Unknwown message sadfsadf, giving upsadfsadf +4> receive X -> X end. +{'EXIT',<0.35.0>,reason}</code></pre> +</section> +<section class="slide level1"> + +<h2 id="distributed-nodes">Distributed nodes</h2> +<pre><code>$ erl -sname ping +$ erl -sname pong + +register(spawn(...))</code></pre> +</section> +<section class="slide level1"> + +<p>On pong</p> +<pre><code>> P = l:start_pong3().</code></pre> +<p>On ping</p> +<pre><code>> {pong, pong@bogon} ! {ping, "hello", self()}. +> {pong, pong@bogon} ! {ping, "hello", self()}. +> receive X -> X end. +{pong,"hello"}</code></pre> +</section> +<section class="slide level1"> + +<pre><code>erlang:node(). +erlang:nodes().</code></pre> +</section> +<section class="slide level1"> + +<h2 id="hot-code-replacements">Hot code replacements</h2> +<pre><code>version() -> … +c(l).</code></pre> +</section> +<section id="otp" class="slide level1"> +<h1>OTP</h1> +<p>Open Telecommunication Platform</p> +</section> +<section class="slide level1"> + +<h2 id="batteries-inclued">Batteries inclued</h2> +<ul> +<li>EUnit</li> +<li>Mnesia</li> +<li>HTTP/SNMP/…</li> +<li>…</li> +</ul> +</section> +<section class="slide level1"> + +<h2 id="behaviours">Behaviours</h2> +<ul> +<li>gen_{server,fsm,event}</li> +<li>supervisor</li> +<li>application</li> +</ul> +</section> +<section id="debugging" class="slide level1"> +<h1>Debugging</h1> +</section> +<section class="slide level1"> + +<h2 id="tracing-processes-messges">Tracing Processes, Messges, …</h2> +<pre><code>erl -sname observer -hidden -run observer</code></pre> +</section> +<section class="slide level1"> + +<h2 id="tracing-functions">Tracing functions</h2> +<pre><code>dbg:start(). +dbg:tracer(). +% trace messages (m) +dbg:p(pong, m). </code></pre> +</section> +<section id="the-greater-erlang-universe" class="slide level1"> +<h1>The greater Erlang Universe</h1> +<ul> +<li>REST: <a href="https://github.com/webmachine/webmachine">Webmachine</a></li> +<li>JSON: <a href="https://github.com/davisp/jiffy">jiffy</a></li> +<li>YAML: <a href="https://github.com/processone/p1_yaml">p1_yaml</a></li> +<li>Build, run, test: <a href="https://github.com/erlang/rebar3">Rebar3</a></li> +<li>… your favorite erlang app goes here …</li> +</ul> +</section> +<section id="extending-erlang" class="slide level1"> +<h1>Extending Erlang</h1> +</section> +<section class="slide level1"> + +<h2 id="nifs---gesundheit">NIFs - Gesundheit!</h2> +<p>Native Implemented Functions</p> +</section> +<section class="slide level1"> + +<h2 id="c-nodes">C-Nodes</h2> +</section> +<section id="see-also" class="slide level1"> +<h1>See also</h1> +<ul> +<li><a href="http://elixir-lang.org/">Elixir</a></li> +<li><a href="http://lfe.io/">LFE(Lisp flavored Erlang)</a></li> +<li><a href="http://erlangonxen.org/">Erlang on Xen</a></li> +</ul> +</section> +<section id="further-reading" class="slide level1"> +<h1>Further Reading</h1> +<ul> +<li><a href="http://learnyousomeerlang.com/">Learn you some erlang</a> - buy the book!</li> +<li>On Debian <a href="">/usr/share/doc/erlang-doc</a></li> +<li>Everywhere else: https://www.erlang.org/docs</li> +</ul> +</section> +<section id="questions" class="slide level1"> +<h1>Questions?</h1> +</section> + </div> + </div> + + <script src="reveal.js/lib/js/head.min.js"></script> + <script src="reveal.js/js/reveal.js"></script> + + <script> + + // Full list of configuration options available at: + // https://github.com/hakimel/reveal.js#configuration + Reveal.initialize({ + // Vertical centering of slides + center: true, + // Transition style + transition: 'fade', // none/fade/slide/convex/concave/zoom + + // Optional reveal.js plugins + dependencies: [ + { src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, + { src: 'reveal.js/plugin/zoom-js/zoom.js', async: true }, + { src: 'reveal.js/plugin/notes/notes.js', async: true } + ] + }); + </script> + </body> +</html> |