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

Boost your productivity with the Erlang Languag...

Boost your productivity with the Erlang Language Server

# Roberto Aloi - CODE BEAM STO V - 11 SEP 2020

Implementing features such as auto-complete or go-to-definition for a programming language is not trivial. Traditionally, this work had to be repeated for each development tool and it required a mix of expertise in both the targeted programming language and the programming language internally used by the development tool of choice.

A brilliant intuition, the "Language Server Protocol" (LSP), changes the rules of the game. A real blessing for the Erlang community.

Roberto Aloi

July 01, 2021
Tweet

More Decks by Roberto Aloi

Other Decks in Technology

Transcript

  1. Kred. - Name from Kreditor - Monolithic Erlang System -

    Distributed system - Monorepo - 250 Erlang applications - 1.5 million lines of code - The main reason I started Erlang LS
  2. The Productive Years. 2015 - Satisfied with my Erlang IDE

    - Erlang-mode - Syntax Highlighting - Code Indentation - EDTS - Code Navigation - Find Callers - No fancy stuff
  3. ?

  4. Emacs Lisp Erlang 2. Send a HTTP request asking for

    callers 1. Find the current MFA using a regex yaws_sup:child_specs/0 3. Run xref to find the callers 4. Send back the response via HTTP 5. Render the list of callers in the UI
  5. What if we would formalize the HTTP API such as

    the EDTS server could be leveraged by other clients (text editors)?
  6. Language Server Protocol. - Invented by Microsoft - JSON-RPC Based

    - Two transports: TCP and STDIO - Client / Server (but not really) - Server lifecycle controlled by client - Negotiation about capabilities - Extensible (DAP)
  7. Development Tool Language Server User Opens Document NOTIFICATION: didOpen {Document}

    User Edits Document NOTIFICATION: didChange {DocumentURI, Change[]} Trigger Compilation... NOTIFICATION: publishDiagnostics {Diagnostic[]} REQUEST: definition {DocumentURI, Location} RESPONSE: {Location} User Requests “Go To Defintion” Compilation Completed
  8. { "jsonrpc": "2.0", "id" : 1, "method": "textDocument/definition", "params": {

    "textDocument": { "uri": "file:///Users/robert.aloi/git/yaws/src/yaws_api.erl" }, "position": { "line": 2662, "character": 25 } } } { "jsonrpc": "2.0", "id": 1, "result": { "uri": "file:///Users/robert.aloi/git/yaws/src/yaws_sup.erl", "range": { "start": { "line": 45, "character": 0 }, "end": { "line": 45, "character": 11 } } } } Request Response
  9. Indexing. - Different from EDTS approach - Happens in the

    background - Persisted - Hashing to avoid re-indexing - Shallow vs Deep - Exclusion list for OTP apps - Use standard libraries - The els_dodger module - Fault-tolerant parsing
  10. - Natural evolution from ETS - Store Erlang terms -

    Comes with OTP The Mnesia Database. The Good parts
  11. - Disc Copies Limits - Memory footprint - Wait for

    Tables - No Distribution: overkill - Looking for alternatives The Mnesia Database. The Bad parts
  12. Speaker - https://unsplash.com/photos/EKfkHf2ftkwEk by Med Badr Chemmaoui Network - https://unsplash.com/photos/OKOOGO578eo

    by Anastasia Dulgier Monolith - https://pixabay.com/photos/nature-landscape-mountain-monolith-893912 by makunin Goals - https://unsplash.com/photos/LNzuOK1GxRU by Markus Winkler IDE - https://unsplash.com/photos/-FHIdRVGets by Ferenc Almasi Laptop - https://unsplash.com/photos/G0gtwbjF0_0 by Patrick Tomasso Productive - https://unsplash.com/photos/KE0nC8-58MQ by Carl Heyerdahl Cry - https://unsplash.com/photos/T5lmpSYxnSU by Tom Pumford Discovery - https://unsplash.com/photos/rzCi3mD-6ho by Isaac Davis Theatre - https://unsplash.com/photos/WW1jsInXgwM by Rob Laughter Phones - https://pixabay.com/photos/phones-wired-old-unused-telephone-1708692 by Benjamin Balazs (edited) Idea - https://unsplash.com/photos/9upRLljfKP8 by Frank Vessia Pens - https://unsplash.com/photos/zCJrolkwRyE by Mark Rabe Coding - https://unsplash.com/photos/ZgZsKFnSbEA by Reza Namdari Lego - https://unsplash.com/photos/HpMihL323k0 by Glen Carrie Dive - https://www.pexels.com/photo/diver-under-the-sea-887826 by Tirachard Kumtanom Library - https://unsplash.com/photos/AG2Ct_DqCh0 by chuttersnap Library 2 - https://unsplash.com/photos/PkbZahEG2Ng by Tobias Fischer Concert - https://unsplash.com/photos/m1WZS5ye404 by Vishnu R Nair Band - https://www.pexels.com/photo/woman-playing-guitar-while-singing-beside-man-playing-... by Brett Sayles Pencil - https://unsplash.com/photos/bj3l739cwc8 by Kelly Sikkema Photo Credits