class: center, middle # The BEAM community and efene Mariano Guerra [@warianoguerra](https://twitter.com/warianoguerra) [efene.org](http://efene.org) [@EfeneLang](https://twitter.com/EfeneLang) [instadeq.com](https://instadeq.com) [@instadeq](https://twitter.com/instadeq.com) Erlang User Conference Stockholm 2017 --- class: center # Disclaimer There's light at the end of the tunnel ??? It's kind of a critical talk, ut I think this kind of discussions are healthy --- class: center # Erlang had it 25 years ago --- class: center # Fast Forward 25 years ![Evolution](imgs/lada-evolution.jpg) /ht @videlalvaro ??? The language has been evolving quite nicely during the recent years, but the rest not much so. --- class: center What does Erlang have in 2017 that others will copy in 25 years? ??? Where are we leading, what are others going to be copying in 25 years? Erlang started with a need and it solved it, it achieved the vision, what is the new need? what are we solving? --- class: center, middle # The Times They Are A-changin' ![Car Choices](imgs/citroen-toyota-peugeot.jpg) ??? We live in a time of choice overload, we live in an era of algol-like languages The language market has evolved, 20 years ago vim/emacs (that is: vim) and a Makefile was enough, now people expect a lot more. Citroën C1, Peugeot 107, Toyota Aygo --- class: center ![Car Choices](imgs/vw-skoda-seat-1.jpg) ??? too many alternatives, no time to analyze in detail (pick a lib based on github stats) We need to make the BEAM a plaform with choices for all needs but maximizing the amount of interoperability and shared effort. What's the minimal change in the BEAM to bring protocol support/interop to all languages? VW Up, Skoda City Go, Seat Mii The SEAT Mii and Škoda Citigo are rebadged versions of the Up, with slightly different front and rear fascias, and are manufactured in the same factory. --- class: center # Give me Convenience or Give me Death ![Dead Kennedies](imgs/give-me-convenience.jpg) ??? As usual, punk rock has all the answers People need really good reasons to transition to a new technology/stack Why Akka exists in the JVM and dotNet if erlang exists and works? Why orleans was implemented in dotNet and not erlang? --- class: center ![McCarthy Lisp 1967 IBM 7090](imgs/McCarthyLisp1967.jpg) ??? Here is John McCarthy running Lisp on a 1967 computer, I'm sure he didn't use it for the speed. --- class: center But the Smalltalk was very slow—so slow that I used to take a coffee break while it was garbage collecting -- Joe Armstrong --- (15:11:12) DHH: before fastthread we had ~400 restarts/day (15:11:22) DHH: now we have perhaps 10 ??? This is how much people are willing to tolerate a bad platform if it gives them convenience and small MTtMR: First RoR demo was how to get a blog up and running in 15 minutes RoR was not thread safe for years (one of the reason Elixir exists today) --- class: center We can tolerate many things if the tool makes us more **productive** --- class: center McCarthy wasn't using Fortran Joe wasn't using C DHH wasn't using **Erlang** ??? He said he won't migrate to Elixir because he feels productive in Rails --- class: center Productivity is not only the language semantics or the VM implementation. It's the whole *experience* -- That's what I call **community** in this talk ??? All the things around the language For example, I'm using markdown today, even if I like restructured text more, the only rst tool is in python, requires installation and a build step, remark.js is just a script tag away --- class: center The effort on **community** is inversely proportional to the power of the tool -- Mariano's Law --- class: center # We call it a REPL ![Intellij Java IDE](imgs/java-intellij.png) --- # The Pragmatics **C** -> Algol **C++/Java** -> Simula/Smalltalk **Python** -> ABC **Ruby** -> Smalltalk **Javascript** -> Self/Scheme ??? Recognize their weaknesses Improve experience through tools, libraries, docs, practices, linters etc --- # If we build it they will come C -> **Algol** C++/Java -> **Simula/Smalltalk** Python -> **ABC** Ruby -> **Smalltalk** Javascript -> **Self/Scheme** ??? Since they are pure they don't need to do all those extra things --- class: center "We were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp." Guy Steele --- class: center IRC vs Slack Web/Blogs/RSS vs Medium/Facebook Mastodon vs Twitter Postgres vs MySQL Riak vs Mongo BSD vs Linux Gmail/Google/WhatsApp etc --- class: center, middle # We are selling Erlang the wrong way ![Selling Erlang](imgs/mario-water-1.png) ??? https://www.useronboard.com/features-vs-benefits/ We are selling the flower (what erlang can do) people want the powers (what erlang allows them to achieve) --- background-image: url(imgs/marshmallow.jpg) class: middle, center, reverse-text # MTtMR / Hackaton Test ??? Marshmallow experiment (1/3 waited for the 2nd marshmallow) Instant gratification Prioritize short term over long term benefits Prioritize "developer happiness" over stability, performance etc. Mean time to meaningful result How Loading Time Affects Your Bottom Line https://blog.kissmetrics.com/loading-time/ "How time to tangible result affects your bottom line" Would you use Erlang for a hackaton? --- class: middle, center # "Here's what our product can do" and # "Here's what you can do with our product" sound similar, # but they are completely different approaches. -- Jason Fried --- class: center Beware of the Powerful Language tar-pit in which everything is possible but nothing of interest is easy. --- class: center # The Language of the System ??? BEAM should be the platform for IoT, for modern web technologies, the language of the system, of distributed systems, of protocols, microservices without the pain we need to provide the tools, libs, docs, guides, help it's like TDD/Tests, you know you should be using it, but... reasons --- class: center # Innovator's dilemma ??? maintream languages are more pragmatic, they adopt features of other languages if they make sense, at some point they will be a "good enough" alternative to Erlang's strengths and then we may be left with a niche platform. --- background-image: url(imgs/Survivorship-bias.png) class: center, reverse-text # I don't see a problem ??? The damaged portions of returning planes show locations where they can take a hit and still return home safely; those hit in other places do not survive We are the survivors, since we survived the "Erlang learning cliff" we don't see a problem. We should be asking the ones that tried and failed to see how to improve. Every new service written in Go should be a reminder that we aren't doing enough. --- # Why would I care? Bus Factor exercise: * ferd * t_sloughter * lhoguin * bytemeorg * ostinelli * elbrujohalcon * heinz_gies * gar1t * jlouis What if we had twice of those? 5x? 10x? ??? at least for egotistical reasons, to get more libs, more docs, more posts, more tools, frameworks, jobs, conferences --- background-image: url(imgs/erlang-site.png) ??? Low hanging fruit --- background-image: url(imgs/erlang-quickstart.png) ??? How long do you stay on a site if you don't find what you are looking for. is this the best first encounter with an erlang beginner? --- background-image: url(imgs/haskell-site.png) --- class: center # Haskell's motto: Avoid success at all costs Check Elm, OCaml, Racket sites too ??? The rules have changed --- # Enough Complaining * Erlang docs style improvement * Blogged How-To * Merged \o/ * Erlang client side index for search * Erlang docs to restructured text/sphinx * Generic platform: from docs to X * beamdocs --- background-image: url(imgs/erlang-docs.png) --- background-image: url(imgs/erlang-docs-rst.png) --- class: center # and efene :) --- class: center # efene is an attitude towards community, docs, tooling, UX # ... and also an alternative syntax for Erlang --- ```javascript { "string": "sure", "integer": 42, "float": 3.14, "bool": true, "null": nil, "list": [1, ["nested!"]], "trailing ,": true, } ``` ??? You know JSON, you know almost all data syntax in efene --- ```python { what: `an atom`, 'wait!': 'binary string', cons: 1 :: 2 :: [], tuples: { empty: (), one_item: (1,), two: (1, 2), } } ``` ??? You know some js/python and you know the rest of the data syntax --- ```javascript #b {Version:4, IHL:4, TypeOfService:8, TotalLength:16, Identification:16, FlagX:1, FlagD:1, FlagM:1, FragmentOffset:13, TTL:8, Protocol:8, HeaderCheckSum:16, SourceAddress:32, DestinationAddress:32, Rest: binary} = Packet ``` ??? Tagged values for other data types, same syntax, easier to remember, read, simpler language --- ```python 1 + -2 - 3 * 4 / 5 % 6 // 7 ``` ??? Python/JS syntax for operators --- ```python 1 | ~2 ^ 3 & 4 >> 5 << 6 ``` --- ```python true and false or not true ``` ??? andd orr xor --- ```python 1 < 2 and 2 <= 3 and 3 == 3 4 > 3 and 4 >= 4 and 4 != 3 1 is 1 and 2 isnt 3 ``` --- ```python match foo(): case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python receive case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python fn top_level_function case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` ??? Note: tuple not unrolled for functions --- ```python fn top_level_function @public case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python fn case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python fn NamedLambdaFun case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python lists.map(List) <- case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python mlist.map(List) <<- case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- class: try-catch ```python try foo() catch case error, E1: E1 case exit, E2: E2 case EType, E3 when is_tuple(E3): E3 case EType, E4: E4 else: (error, no_match) end ``` --- ```python lists.seq(1, 10) ->> lists.filter(IsOdd) -> MyFun(param) ``` --- ```python for X in lists.seq(1, 10): X + 1 end ``` ??? Familiar syntax for list comprehensions, easier to write lists.map/lists.foreach taking advantage of a BEAM optimization for list comprehensions --- ```python for X in lists.seq(1, 10); when X % 2 is 0: X + 1 end ``` --- ```python for X in lists.seq(1, 10); Y in lists.seq(10, 20): (X, Y) end ``` --- ```javascript when A < 10: io.format("A < 10") else A < 20: io.format("A < 20 and >= 10") else: io.format("A >= 20") end ``` ??? One of main problems with erlang is that has an if expression that doesn't behave like ifs in other languages. it's not an if it's a guard, that's why in efene it looks like a guard --- ```javascript @record(acc) -> (user, pass, email) Acc = #r.acc {user: 'bob', pass: '*'} #r.acc {user: Uname, email: Em} = Acc Uname = #r.acc.user Acc Acc2 = #r.acc Acc#{email: 'bob@m.com'} UnameIdx = #r.acc user ``` ??? full record support with tagged values --- ```javascript @type(result(E, V)) -> (error, E) or (ok, V) @type(division_error()) -> result(division_by_zero, number()) fn divide_two @public @spec(number(), number()) -> division_error() case _A, 0: (error, division_by_zero) case A, B: (ok, A / B) end ``` ??? Dialyzer suport --- # Support * Rebar3 * Xref * Dyalizer * All Erlang warnings --- # Support * Compile to bytecode * Transpile 1:1 to Erlang * Erlang hrl includes * Erlang macros support * No install, 2 lines in rebar.config + Start with one file + Bail out at any time * Include fn overrides --- # A Boring Language * Probably last release + No new syntax * No stdlib + But one way of doing things * No wrappers * No efene ports * No efene only tools * Slack: a channel on Erlang slack ??? No new syntax unless erlang gets new syntax Blessed stack This is not an attack on Elixir, just a different niche Non fn specific Qs redirected to #general --- # An Exiting Language * Let's get things done * Focus on docs, onboarding, templates, error msgs, community, examples, tools * Standard stack, focus on polish and integration + Rebar3, Relx, Cuttlefish, Cowboy, Lager, Exometer, Recon, Syn, Shotgun, Katana, worker_pool, Common Test * Lang Interop: Rust (cnode, NIF), Clojure (JVM), JS (Web), Wasm (perf) * Sys Interop: docker/rkt/k8s, Heroku/Google/AWS/Azure, Windows --- # Status * 1.0 Beta 1 today! * Stable for a long time * Been using it for tools * Also for [instadeq.com](https://instadeq.com) --- # Help! * Try efene, read the docs + Open issues + Talk about your experience * Syntax Highlighter * Improve Pretty Printer * Improve REPL * VS Code Support + BEAM Language Server * Templates * Let's build great BEAM tooling with efene --- background-image: url(imgs/new-lada.jpg) class: middle, center # Thanks! --- class: middle, center Mariano Guerra [@warianoguerra](https://twitter.com/warianoguerra) [efene.org](http://efene.org) [@EfeneLang](https://twitter.com/EfeneLang) [instadeq.com](https://instadeq.com) [@instadeq](https://twitter.com/instadeq.com) --- # What you can also do * Can we get the cool Elixir features in the BEAM? * Mentoring * Blog more * Erlang module of the week * Clojure-docs style documentation * Follow Erlang on Reddit, SO, HN, Twitter, #learning@Slack and provide help --- # What you can also do * Guides for common tasks + REST API + Talk to Postgres + Handle files + CLI + Make HTTP requests/talk to APIs + Binary pattern matching * Annual survey * Improve string module * More