Atomic Habits: a personal summary
Here is my summary of Atomic Habits based on each chapter, and I hope this information can give you an idea of what the book is about, so you can read it yourself and get all of the benefits.
Last week I attended Elixir Conf 2019 in Aurora, Colorado. It was my fourth Elixir Conf and by far the one that I engaged more with other people that I've never talked before, the hallway track was great and I could meet again some conference buddies from other editions. Another highlight was the conference hotel, a brand-new resort close to Denver, who knows me well understands how I like anything Colorado so I am glad the next edition will be in the same location.
The conference format was similar to previous years, it was three tracks, two days, with two extra days for an optional training, that I didn’t attend this time. The conference had 4 keynotes, José Valim (Elixir creator), Chris McCord (Phoenix creator) and Justin Schneck (Nerves co-creator), Dockyard team introducing Lumen, and great talks.
All the talks and keynotes are available in the Elixir Conf YouTube channel. Each keynote was focused in some areas, Elixir language and future, LiveView, Nerves and the brand-new Lumen, a project from Dockyard that uses Elixir in the client (browser).
As I always like to take notes when attending conferences and these are my highlights for Elixir Conf 2019. Please be advised that those notes are written like reminders for things I considered relevant during the talks and they are not a summary of them by any means. As the conference had many tracks, of course I couldn't attend all the talks, so feel free to comment with your favorite talk and notes:
Before anything, thank you very much José for the incredible language, it is a pleasure working full-time with Elixir and share the same community with great people, and I extend that to all Elixir core team as well.
The main goal is enhance the ability to put applications in production easier, and to ensure what is running in production can be inspected.
The two main pieces are releases and telemetry.
Releases
Distillery
;shellcheck
to test shell scripts;Telemetry
The library is composed by many pieces and helps snapshot what is going on inside running applications through metrics from the BEAM and custom ones.
telemetry
, telemetry_poller
, telemetry_metrics
, and telemetry_reports
;The next release, 1.10, will come with a different set up for its CI, now using Cirrus CI. It will also contain compiler tracing and ExUnit
pattern diffing.
Now that the language enhancements are getting to a very stable point, and the community projects are being built and showcasing the power of the language, the efforts will be more directed to lower level (HiPE, Lumen and Hastega) and code analysis.
At Lonestar Elixir Conf 2019, Chris McCord presented the still-private project LiveView, which enables rich, real-time user experiences with server-rendered HTML. Right after the conference, the project was made available to the public and since then, a collection of projects is showcasing how interesting and powerful LiveView is. That also includes a Phoenix Phrenzy, a contest for LiveView projects.
In this keynote, he presents a few interesting points of LiveView and also what is coming next and the reasons behind.
live_redirect
, live_link
and handle_params
for pagination URL changes;phx-debounce
;In his keynote, Justin Schneck, again, gave a really nice demo to show the improvements Nerves is getting.
Read-only filesystem, immutable;
Whitelist approach (build up) with minimal output;
Lumen is a new project from Dockyard that uses Elixir in the client. It uses WebAssembly and Rust as well in the compiler.
The compiler has some unique constratins such as code size, load time and concurrency model.
Why not BEAM?
New Compiler
Frontend
Accepts source in Erlang and Core Erlang, including mix task.
Middle tier
AST lowered to EIR.
Backend
Lowers from EIR to LLVM IR, generate object files.
Future goals
Push more data to LLVM, bootstrapping, MLIR, and embedded targets.
Memory management
BEAM and Rust, with property-based testing.
Memory model
Process heap and pre-process garbage collection.
Processes
Very similar with what we have in Elixir. Code stack, mailbox, pid,
memory, links, and so on.
Schedulers
One per thread, main thread and webworkers.
WebAssembly main thread
Calls are blocking, scheduler needs to run timers.
Interacting with web
JS calling Lumen, and Lumen calling JS.
In this talk Alex showed some LiveView internals, how it works and how it works so well.
From template with sigils to AST
%Phoenix.LiveView.Rendered{}
with static, dynamic and fingerprint;%Phoenix.LiveView.Comprehension{}
to optmize data sent to the client;Mounting the DOM
live
and live_render
macros;<div>
that receives the template can be configured to be any HTML tag;Phoenix.LiveView.Socket
;"lv:*"
;%Phoenix.Socket.Message{}
;Morphdom.js
to re-render the changes in the DOM;WebRTC (Web Real-Time Communication) is a free, open-source project that provides web browsers and mobile applications with real-time communication (RTC) via simple application programming interfaces (APIs). It allows audio and video communication to work inside web pages by allowing direct peer-to-peer communication, eliminating the need to install plugins or download native apps.
Janus is a general purpose WebRTC server that has an Elixir client available.
Phoenix as middleman between client and Janus.
PagerDuty has a feature that records all incident user logs and they use CQRS pattern to design that piece of functionality.
They use composite keys for tracing that can be order-able. Other benefits of the approach is having separation for monitoring and scaling.
Handling date and time is a challenge in any language, in this talk we see the details behind Calendar
in Elixir that had an upgrade in the version 1.9.
Differences between UTC, TAI and the concept of layers of wall time.
~D
, ~T
, ~N
, ~U
;NaiveDateTime
vs DateTime
date/time comparison;TimeZoneDatabase
behaviour, as example tzdata
;Z
;Mint is a reasonable new low-level HTTP client that aims to provide a small and functional core that others can build on top.
The initial need was caused by a potential removal of httpc
from Erlang standard library. Mint is a processless client, that defines a wrapper as data structure for the connection, on top of gen_tcp
. Mint knows how to handle raw bits and also HTTP
protocol.
Streaming by default
Responses will arrive async (status, headers, body and so on).
Security
httpc
is not safe by default;hackney
is safe by default but can be overridden if you work with `ssl_options`;mint
is safe by default;castore
;Proxying
Mint has proxying support for request and tunnel proxy types.
HTTP2
GenServer, GenStage, GenStatem with connection data. Also, it can be used as one process with many connections.
gRPC
;In her talk, Miriam showed us things to consider to improve performance, also alerted us that any tuning in the VM should be done only when needed, for very specific cases. Besides that, performance measuring should be done for a long time, and not using IEx.
One of the things she mentioned is that memory copy, something that happens a lot in the BEAM brings CPU overhead.
Other suggestion is to keep OTP version updated as possible as new releases are always improving performance.
In this talk, Chris presents some insight why Design by Contract should be considered and how his new library Norm can help projects in the data specification and generation aspect.
Even not personally interested in MySQL as prefer and use only Postgres, I was willing to know more about internals of Ecto and how Ecto uses its adapters to connect and interact with databases.
:gen_tcp
for database connection;binpp
;OK_Packet
with defrecord
;DBConnection
behaviour: maintain a connection pool, does not overload the database, reconnect, support to common database features, and it needs to be fast;DBConnection
based on the pool configuration;Ecto.Adapter
, Ecto.Adapter.Queryable
, Ecto.Adapter.Schema
, Ecto.Adapter.Storage
, and Ecto.Adapter.Transaction
;1
and 0
;Kubernetes has great benefits, even being a not so easy implementation. Some of the benefits are improved resource efficiency and reduced cost, and operational scalability. In this talk Phil described his process to implement Kubernetes at Hippware.
In this talk David compares the characteristics of ElasticSearch that is well-known as a great solution for search and cached data, with Elixir/Erlang out-of-box solutions such as ETS and Persistent Term, listing the pros and cons of each option.
match/2
, match_object/1
and fun2ms/1
;fun2ms/1
;Whether you call it UI testing, end-to-end testing, end-to-user testing, or acceptance testing, it is often an intensely manual and time-consuming process. An Elixir library, Hound, can carry some of the load through browser automation.
Hound takes screenshots of tests and stores in the test folder.
StreamData
generator using bind/2
helper;While handy, there are some gotchas when elements are not ready or if the application is heavily dependent in Javascript events/side effects;