😼 You looked at the source!

Dimitris Zorbas

Code spells, smells and sourcery

Elixir.LDN 2017

I returned from vacations in beautiful Greece (Amorgos island 🏝), to attend Elixir.LDN-2017 in London.

General Feeling

The venue was at a very convenient location and was well suited for the conference. I could see many familiar faces and felt like a supercharged edition of the London Elixir meetup.

If you’re interested in attending the Elixir London meetups you probably want to join #london of the elixir-lang slack (get an invite) and the meetup.com group.

The Talks

Keynote - José Valim - Elixir 1.5 Update and Q&A

Video

The talk was mostly about Elixir 1.5 features and demystifying the way Elixir files are loaded, parsed and compiled to BEAM files.

There was a lot of focus on the importance of the introduction of the Dbgi Chunk in OTP 20 (see this PR and mailing list discussion).

An example of how it is used can be seen in the code below (found in elixir@1.5.1 lib/iex/lib/iex/pry.ex):

defp fetch_elixir_debug_info_with_fa_check(module, fa) do
  case :code.which(module) do
    beam when is_list(beam) ->
      case :beam_lib.chunks(beam, [:debug_info]) do
        {:ok, {_, [debug_info: {:debug_info_v1, backend, {:elixir_v1, map, _} = elixir}]}} ->
          case List.keyfind(map.definitions, fa, 0) do
            {_, _, _, _} -> {:ok, beam, backend, elixir}
            nil -> {:error, :unknown_function_arity}
          end
        {:ok, {_, [debug_info: {:debug_info_v1, _, _}]}} ->
          {:error, :non_elixir_module}
        {:error, :beam_lib, {:unknown_chunk, _, _}} ->
          {:error, :otp_20_is_required} # TODO: Remove this when we require OTP 20+
        {:error, :beam_lib, {:missing_chunk, _, _}} ->
          {:error, :missing_debug_info}
        _ ->
          {:error, :outdated_debug_info}
      end
    _ ->
      {:error, :no_beam_file}
  end
end

This feature enables quicker debugging (see: stackoverflow-question and related PR) for IEx, Plug, ExUnit and opens a wide spectrum of possibilities, even adding a full type system in Elixir as José hinted during the Q&A session.

Exception.blame

José also talked about the new Exception.blame/3 function which is capable of attaching debug information to certain exceptions.

Currently this is used to augment FunctionClauseErrors with a summary of all clauses and which parts of clause match and which ones didn’t.

The feature is showcased best by the video below:

ElixirScript@0.30.0

José mentioned the release of ElixirScript version 0.30.0 which now supports compiling Elixir code to JavaScript on the fly. Read the release notes here.

Evadne Wu - How to Sell Elixir

Slides Video

The talk was about suggesting the use of Elixir for a system of Faria Education Group where Evadne works , what it took to convince the management and their story developing it.

Some of the quotes I noted from this talk are:

  • When choosing technologies, you’re managing risk
  • Good technology can’t save you from bad specification
  • JVM is a good ecosystem to get things done

Peter Saxton - Working with HTTP/2 in Elixir

Slides Video

Peter has built an HTTP/2 only server entirely in Elixir. The server is called Ace.

Some of the quotes I noted from this talk are:

  • Handling binary protocols in Elixir is easy
  • Prefer coding library apps where possible
  • Don’t use config.exs for your library apps

Deconstructing HTTP/2 frames from a binary stream:

def parse_from_buffer(
  <<
    length::24,
    type::8,
    flags::bits-size(8),
    _R::1,
    stream_id::31,
    payload::binary-size(length),
    rest::binary
  >>, max_length: max_length)
  when length <= max_length
do
  {:ok, {{type, flags, stream_id, payload}, rest}}
end

Louis Pilfold - Getting Pretty Serious

Video


louis pilfold
Louis "getting pretty serious"

Louis is the author of exfmt and talked about the differences between linters and formatters and the difficulties of implementing a formatter.

He said that he based his algorithm on Philip Wadler’s algorithm for pretty printing (see: paper) and Inspect.Algebra, which is in turn based on the “Strictly Pretty” paper by Christian Linding.

There was also a GSoC project for the implementation of a code formatter for Elixir (see: here).

Quotes from the talk:

  • Compilers are easy, people are hard
  • Adhering to a consistent code style saves you money

I could see that Louis was using the :Neoformat command from inside (Neo)Vim to demonstrate exfmt and luckily there are instructions for integration with Vim here 🙌.

Georgina McFadyen - Elixir Umbrella - Microservices or Majestic Monolith?

Video

This was an informative talk about creating, developing and releasing umbrella applications. It seemed to me like a condensed version of the “Microservices under the Umbrella” workshop which I attended at Elixironf.EU 2017.

She said that you can choose to deploy you application with Distillery building a release per sub-app, one release including all sub-apps or you can group sub-apps and release separately.

An interesting question during the Q&A session was if you can nest umbrella apps where Georgina responded that it’s probably not possible but she hasn’t tried it.

In case you didn’t know you can scaffold a new umbrella application using:

mix new some_project --umbrella

Nikolay Tsvetinov - How We Created The University Course - Functional Programming With Elixir

Nikolay presented his story teaching Elixir in a functional programming course at the university of Sofia.

Slides Video

Gary Rennie - HTTP/2 Plug to Phoenix, Cowboy too

Video

Plug is HTTP/1.1 only and developed mostly with the Cowboy Erlang server in mind. Then next major version of Cowboy (2) is soon to be released, but it has taken a few years. You can read the migration guide here.

Gary did a demo of using Cowboy directly from Elixir and later one of an HTTP/2 chat service with Phoenix and Chatterbox.

Péter Gömöri - Profiling and Tracing for all with Xprof

Video

This talk was about the Xprof tool which is a single-function profiler aimed for production safety, ideal for immediate visual feedback and ad-hoc debugging.

It uses “match_spec” flavored filtering to provide an expressive way to filter function calls by their usage.

xprof

Q&A Session

Q: Is it safe for production usage?

A: It is meant to be turned on for investigations, not to be constantly on, just to be safe. It only keeps 1 minute worth of data.

Andrea Leopardi - Stepping into a New Era: Injecting Elixir in an Existing System

Slides Video

Quotes from the talk:

  • Services are good, use the best tool for the job
  • Using Elixir in Football Addicts was a huge success (perf went ☝, Resources / Server usage went 👇)

Brooklyn Zelenka - Witchcraft: Monads for the Working Alchemist

Slides Video

She talked about the Blub Paradox, coming from a more powerful language (Haskell), she felt the need to make Elixir look more like it.

She authored the following libraries to achieve that:

Lighthing Talks

I can only remember a talk about elchemy (Elm -> Elixir) by Krzysztof Wende.

Highlights

After Party


elixirldn after-party
The venue of the after-party

Lot’s of amazing conversations which I’m probably still digesting.

Upcoming Conferences