| Comments

Highlights from Lonestar ElixirConf 2018

lonestar logo

This year’s winter in Berlin has been going on for far too long. Fortunately I managed to escape to Texas, USA for a few days to speak at and attend Lonstar ElixirConf 2018.

When I wasn’t eating BBQ and remembering what the sun looked like, I saw some great talks and met some amazing people. It was an excellent conference and a great showcase of the talented and vibrant Elixir community.

I’ve put together a short outline of the talks from the two days, along with my top five talks from the conference.

My Top Five

Day 1

Day 1 Keynote - (Chris McCord)

The conference kicked off with a keynote from Chris McCord. (There’s no video for this talk)

For the first part of the talk Chris spoke about the upcoming Phoenix 1.4 release. Much of this is covered in Chris’s recent blog post including a deep dive into how they worked on speeding up compilation time for the Phoenix development environment.

The rest of the talk was discussing how people should focus on using the strengths of Phoenix, Elixir & OTP. Many people build traditional stateless web applications using Elixir & Phoenix and are seeing great benefits of the language and framework, but they’re missing out on so much more.

Sometimes we learn a new language syntax but forget the new paradigms it brings. With Elixir comes OTP and with Phoenix we have Channels which enable stateFUL applications with built-in datastores.

Databases are great for consistency across our application, but just because we have them doesn’t mean we always have to use them. Think about when you need consistency and when you don’t and choose your tools accordingly.

Customize your car: An Adventure in Using Elixir and Nerves to Hack Your Vehicle’s Electronics Network - (Brien Wankel)

Brien spoke about how he’s been using Nerves (embedded elixir) to hack his Jeep. He’s been using a Raspberry Pi 3 to integrate with his car’s CAN bus, a message based multiplex protocol available on all cars since 2008 (and usually further back). The interface provides messages on lots of things your car is doing such as windows opening, lights turning on, accelerating etc.

He gave a brief overview of the hardware setup and the steps that were involved to get it up all up and running. There’s a lot of low-level hacking involved to get something working.

The overall project seemed really interesting but quite a bit of work - lots of things to figure out along the way and it would have been great to see some more practical outcomes of the project.

Elixir is for Startups - (Angel Jose)

Angel spoke about his experience working in startups and how Elixir has proved to be a great language. Things like Uptime, Scalability, Developer Productivity and some of the reasons they found Elixir a great fit for them.

Along those lines, I’ve recently been reading the new Adopting Elixir book is a great read for teams considering Elixir as a new platform.

Let’s Talk Process Dictionary - (Greg Vaughn)

Greg gave a deep dive into the process dictionary. It was an interesting into a part of Elixir that many developers know nothing about, yet it’s used by many libraries such as readline, logger and ecto.

The process dictionary seems pretty simple - it’s a key/value store on every process on the BEAM. However it’s not garbage collected and you can get yourself into a lot of trouble if you don’t really know what you’re doing.

Running Process.get() in an iex console will show you the process dictionary contents of your iex process.

There are arguments both for and against it’s use and Greg gives some practical examples of those.

In summary, while it can be quite a powerful way of sharing state, but you probably shouldn’t be using it.

Managing state in distributed Elixir - (Jerel Unruh)

Jerel gave an interesting talk on distributed computing with Elixir. Along the lines of Chris McCord’s talk, he spoke about how the architecture and setup of an Elixir application differ from a traditional web application.

They’re using some libraries to manage distributed state:

  • swarm - AP eventually consistent distributed process store. It handles node failures and redistribution of processes and even has callbacks to handle split-brain issues. It can also ensure that certain processes are only run on certain machines (e.g. cron jobs, database, etc.)
  • libcluster - Automatic cluster formation/healing for Elixir applications. It has a Kubernetes library which uses the Kubernetes API to query all endpoints for clusters to join
  • gen_state_machine - Wrapper around gen_statem, a state machine library. Nice way to mange state timers and process inside a GenServer. Has callbacks for entering/exiting states which enables persisting states between crashes so the state can be reloaded the process starts up again.

The talk had some great descriptions and examples. It made me think about how we’re using Elixir and how we’re missing out on some of the benefits that clustering provides.

Consistent, Distributed Elixir - (Chris Keathley)

Chris gave another talk on distributed computing, this time from a CAP perspective. It was a great overview of some of the problems distributed computing introduces and a very user-friendly introduction to the CAP Theorem.

He’s discussed the RAFT Consensus Algorithm and gave some examples from an elixir library he’s been working on.

Overall the presentation was a great introduction to the CAP theorem and consensus algorithms. Definitely worth a look if you’re interested in distributed computing.

Hack Session with Dave Thomas

The first day finished with a hack session with Dave Thomas. It was a great end to the day talking about code quality and refactoring in Elixir.

He started by talking about refactoring functions:

  • Take a look at a function, does the function name have a conjunction in the name (and/or/etc.)?
  • Is the function doing more than one thing?
  • If so, break it up into two functions
  • Are the new functions doing more than one thing? Repeat…
  • A common side-effect is getting rid of local variables which can often be a code smell.

Repeat the same process for your modules. One example he gave was GenServers, how we bundle our API and callbacks into one module, he wrote a good article about how we shouldn’t really be doing this.

Everyone was encouraged to start hacking, taking these ideas and apply them to some code we’ve written.

Day 2

Day 2 Keynote - (Aaron Patterson)

Coming from a ruby background I was excited to hear what Aaron Patterson had to say about Elixir and I certainly wasn’t disappointed. Aaron gave a really funny, really interesting presentation of some of the constructs of Elixir by implementing a new distributed language he called ‘Tenderlang’.

The language starts out with just functions. He proceeds to implements things like assignments, modules, native types all with nothing but functions. It was fun deep dive into the power of functions.

Why Elixir Matters: A Genealogy of Functional Programming - (Osa Gaius))

Osa presented an interesting look into the history and family tree of functional programming. He addressed this from the perspective of asking why should a new developer consider Elixir or functional programming.

In a really nicely delivered presentation, Osa gave a great overview of why Elixir and Erlang matter today.

User-centered API Versioning - (Niall Burkley)

In this presentation I gave an overview of how we’re managing versions on some of our Elixir API’s at Meltwater. We’re using a different approach to handling change to our API, aiming to keep our API users happy by keeping their API calls and responses consistent even after we roll out changes.

For every breaking change in our API, we create a new API version. But rather than each version being a new set of API calls, the version is a transformation layer that converts the request/response to the latest version.

In the presentation I outlined how this versioning strategy works, and how it can be implemented in a Plug-based web framework.

Intermediate SQL with Ecto - (Dennis Beatty)

Dennis Beatty gave a nice presentation on some handy hacks for doing some non-standard queries in Ecto.

With some nice examples using Elixir and PostgreSQL he showed how to do things like using a non-standard primary key, doing bulk inserts with insert_all to bulk-insert records and use Postgres on_conflict functionality to deal with duplicates.

Building on Sand: Firm Foundations from Legacy Databases - (Ben Cates)

Ben spoke about how they’re building a new application alongside their legacy one, using the same database.

He covered three main parts of their legacy database integration:

  • Bad names: renaming tables and columns in Ecto
  • Bad types: using Ecto Custom Types, to wrap things like floats into decimals, unix timestamps into DateTimes
  • Bad structure: eliminating unnecessary columns and tables, using Structs to model some duplicated table data like addresses

It was a nice overview of how to integrate with a legacy database but still keep your naming and coding conventions in your Elixir application.

The Next Phase of Elixir Deployment Tools - (Paul Schoenfelder)

Paul has been working with Dockyard to improve deployment tools for Elixir. He spoke about distillery, one of the tools he has written to make releases easier.

In general he is working on closing the gap between how mix runs applications in development and releases runs applications in productions. In particular, application configuration has been a big problem.

There is a good summary of the talk in his recent blog post.

Closing Keynote - (Tim Mecklem)

Tim gave a really inspiring talk about how he used Nerves to help build an open source Closed-Loop Artificial Pancreas system for his wife who has Type 1 diabetes.

During his talk he did a live demo, hooking up to a Continuous Glucose Monitor he was wearing to show his blood sugar levels in real time.

What really made the talk compelling was not the technical side of things, but the moral and ethical dilemmas he faced along the way. He also made me think about how we should try to write software to make the world a better place. Well worth a watch.