Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building the Ruby × Elixir Conf App

Building the Ruby × Elixir Conf App

Reject Conf 2018

Pokai Chang

April 14, 2018
Tweet

More Decks by Pokai Chang

Other Decks in Technology

Transcript

  1. 皰玡㳓 @zetavg ‣ Բ狝夺䌌Ꭺ಑褾 Developer ‣ Ruby, JavaScript, Elixir, ReasonML,

    C ‣ ࡅ稭碝ᄤ獖槹ጱದ蔩 蚤桽螂犋݄ ‣ 磧蜱ࣁሻӞ犚 Functional 承᥺ ‣ 瓵మฎአ硳ሲ牏ߝ搡膏硳胼ٍّጱොୗ樄咳敟誢
  2. Conference apps ‣ Schedule, personal schedule, map, events, announcements ‣

    Facebook F8 ‣ Google I/O ‣ Apple WWDC ‣ Web Summit ‣ Build-in chat for attendees
  3. What to use? ‣ App: ReasonML ‣ Backend: Elixir ‣

    API: GraphQL ...why so many new things?
  4. Others teaches you some CS ways to think: data structures,

    theory of computation, type theory, formal methods ̿߶牧ܻ㬵౯䛑扗蝡䰬௏ᘍ㺔氂牏蝡愊మဩ磪綠笙牧憽஑݈蝱ྍԧ̀
  5. Functional “I don’t want to hide data. I want to

    transform it.” (Quoted from “Programming Elixir” by Dave Thomas)
  6. Concurrent “Most programmers treat threads and processes as a necessary

    evil; Elixir developers feel they are an important simplification.” (Quoted from “Programming Elixir” by Dave Thomas)
  7. Expectable Conventions length [1, 2, 3] # "length" tuple_size {:ok,

    "hello"} # "size" ̴ https://elixir-lang.org/getting-started/basic-types.html#lists-or-tuples
  8. More about Elixir (౯ᛔ૩ጱ殼ଧ) 1. elixirschool.com物獈槹ݻጱ承ဩ硽䋊 2. elixir-lang.org物ਥො guides 䌃஑盄অ

    3. 獢碍ୗ翥纷: ℂ Elixir & Phoenix 獈槹牐 羬ڜ物य़വ牧Ӿ෈牧অ捝ฃ睞 4. Programming Elixir物౯ፓ獮ݝ磪፡蝡Ӟ๜ (ׯ) ୌ捍䷱䌃螂 Functional ጱ๏݋獨ݝ捝 1 ~ 2牧ݢ犥捝ک 3 ౲ 4ҁ౲ℂ 3牏4 樄ত 捝҂ٚ㵕ಋ牧犋簁䨝ᤩ২֦̿蝡䰬䌃疰 OO 眖ࠡ牐̀ҁ藮
  9. Benefits form OCaml ‣ Battle-tested language created in 1996 ‣

    Functional and immutable by default ‣ Solid type system: structural, inferred and sound ‣ Flow is written in OCaml! ‣ Ecosystem & tooling ‣ ocaml-language-server
  10. Why ReasonML ‣ Type safety ‣ Fast compile time ‣

    Generates fast code ‣ The language of React ‣ When Reason's creator created React, the prototype was written in Standard ML1 ‣ ReasonReact: All your ReactJS knowledge, codified ‣ Fun 1 OCaml is also a member of the ML programming language family.
  11. Varient Type ‣ ݢ犥ቘ薹౮胼癲独ጱ enum ‣ አ type 㬵狶 pattern

    matching ‣ 犖胼አ㬵玟獤㻌֖2 e.g.: Pt(2.)牏Px(12.) 2 Mars Climate Orbiter, costed hundreds of millions of US dollars, crashed because of a pound-force-seconds and newton-seconds type mismatch in 1999.
  12. Type System ‣ Prevent mistakes such as typo, null, wrong

    argument... ‣ Prevent unexpected behavior changes when adding new features ‣ Document!
  13. Type system: Structural v.s. Nominal (* These functions takes a

    list of <something> and returns a <something>. *) let first: 'a list -> 'a = fun (item::_) -> item let second: 'a list -> 'a = fun (_::item::_) -> item (* * The type of function that takes a list of string and returns a string. * Note that this type signature is different from the two functions above. *) type listOfStringSelector = string list -> string (* A function that applies a listOfStringSelector to a list of string. *) let selectListOfStringBy: listOfStringSelector -> string list -> string = fun f -> fun l -> f l
  14. Type system: Structural v.s. Nominal let second: 'a list ->

    'a = fun (_::item::_) -> item type listOfStringSelector = string list -> string let selectListOfStringBy: listOfStringSelector -> string list -> string = fun f -> fun l -> f l (* * The structure of * "function that takes a list of <something> and returns a <something>" * is comaticatible with * "function that takes a list of string and returns a string ", * so the code compiles! *) let b = ["a"; "b"; "c"; "d"] |> selectListOfStringBy second
  15. Type system: Inferred We can remove all the type annotations.

    OCaml will infer them correctly. (* * OCaml will know that the type of these functions are "'a list -> 'a", * as the argument is patteren-matched as a list and will return an * item from the list. *) let first = fun (item::_) -> item let second = fun (_::item::_) -> item
  16. More about ReasonML ‣ 2ality Ӥጱ "What is ReasonML?" 羬ڜ෈

    ‣ Reason ‣ ReasonReact ‣ BuckleScript
  17. GraphQL ‣ Graph data query language ‣ Schema first development

    ‣ Easily parallels frontend & backend develop ‣ Easier communication for developers ‣ No need of extra document