We’re Fly.io. We run apps for our users on hardware we host around the world. Fly.io happens to be a great place to run Phoenix applications. Check out how to get started!
As an Elixir/Phoenix developer going on 10 years it is very easy to take for granted everything that Elixir and Phoenix can do for us. So I wanted to take a step back and list all of the stuff that we get for free when we choose Elixir and Phoenix.
My goal with this post is dump an list of information and links and let you choose your own path. If you are unfamiliar with any of these topics or Elixir and Phoenix please click any of these links and take a peak, I think you might be surprised at the quality and depth of what you find!
The inspiration for this post was a Saša Jurić re-tweet where he shared the following slide from his GOTO Conference Talk.
This image enumerates some of the technical requirements that the Erlang Virtual Machine can replace in your tech stack. Not to say that these other projects can’t do these things well, they can and do in our own stack here at Fly.io. The point is that in those ecosystems you have to solve these problems in the first place, when reviewing this article José Valim said it best:
removing the problem altogether instead of solving the problem
The BEAM
This above list doesn’t even cover the built in support for incredible bits like:
- Actor Process Model, meaning due to concurrency you have a Process and it sends messages to other processes. No Shared memory. Fully managed by the BEAM’s built in scheduler. Millions of processes are no issue. Fearless concurrency!
- Distribution: meaning two servers can communicate seamlessly and automatically. It just works and is incredible.
- RPC: Calling a function or process remotely is as easy as calling a local one, no need to concern ourselves with connections or serialization or deserialization. This is one of the many reasons Fly is so committed to using Elixir and Phoenix, the wireguard based network and globally hosting makes using this trivial and desirable.
- Parallel Garbage Collection, meaning the VM is Soft Real Time, minimal pausing!
- Emphasis on low resource usage in general
- Built in UDP/TCP/SSL server support.
- Built in Key Value Store ETS.
- Tooling for tracing and observing your code.
- 37 Years of constant development and production use.
The beauty of this list is that if Elixir and Phoenix team have done our Job right you don’t need to think about any of this at all. It just works for you and lets you stand on the shoulders of this giant.
Elixir
If we go higher level the Elixir programming language provides us even more as developers:
- A full dependency management and build tool with mix and Hex.
- With modern tooling built in:
- Testing
- Documentation
- Formatting
- Language with a clean, documented and fully exampled Standard Library. Its remarkable how little cruft there is in this Language. Go into any other language to find random functions or modules that are marked do not use, or without examples or documentation. Not the case for Elixir.
- Modern Documentation:
- Built in Cheatsheets
- Built in Custom Markdown
- Links to source
- Search
- Support for Mermaid, Math.js, Vega-Lite and more!
- Modern language features like:
- Protocols enabling high level collections and functions like Enum, Streams, and Access
- Stream, enabling lazy and performant data processing
- Full featured Date/Time/DateTime/Calendar modules.
- Task for trivial parallel processing.
- Agent for trivial shared state management.
- Config for environment specific configuration
- Registry for local, decentralized and scalable key-value process storage.
This is just a subset of what Elixir the Language provides. It doesn’t include the deep catalog of libraries within package registry Hex enabling so much more.
Some examples from Hex:
- Machine Learning with Bumblebee with HuggingFace integration and it works with batching and distribution globally.
- Math/Science comparable to NumPy using Scholar.
- Complex distributed big data processing using GenStage or Broadway
- Embedded and IoT Programming using Nerves.
- Stream-Data for property and generative based testing.
- Sobelow for security and static Analysis.
- Oban for a Worker/Job Queue implementation.
- Req for high level HTTP Clients.
- Plug for HTTP Servers.
- Bandit for pure Elixir HTTP1/2 Server!
- LiveBook for Juypter like workbooks with Elixir!
- Membrane for video stream processing.
- Decimal for arbitrary precision decimal arithmetic.
- Jason for highly performant JSON Encoding/Decoding.
- Image for image manipulation.
- CLDR for maybe the most complete Internationalization and Locale libraries outside of maybe the Web Browser. Numbers, List, Units, Date\Time\DateTimes, Collation, Territories, and more.
- Rustler and Zigler for truly simple Rust and Zig FFI support, for when you need to drop down and bash bits.
There is very little that the Elixir Ecosystem hasn’t tackled!
Phoenix and LiveView
The fun doesn’t stop there because Phoenix simply builds on all of his incredible tooling to provide us with:
- A fully featured HTTP library with
- Advanced Routing
- Plug-able steps
- Built in HTML and JSON handling
- With HTTPS with sane security defaults
- Secure Cookie Sessions
- Secure Tokens
- Controller Actions for MVC Style apps.
- Built in Internationalization Tooling
- Websockets with
- Multiplexing via Channels
- JavaScript library that handles backoff and common error modes
- Serialization
- Sessions
- Scalable to millions of clients.
- PubSubFully Distributed
- With optimizations for “hot paths”
- Presence Monitoring and tracking who is in a channel
- Fully Distributed
- Built using CRDT’s
- JavaScript support
- Development Tooling:
- Live Code Reloading
- Helpful and actionable Errors
- Built in End to End Testing. (No Chromedriver needed)
- JavaScript
- Bundling/Minification/Integrity/Cache Busting
- Using esbuild that is installed for you
- NPM support
- Custom JS is trivial
- Bundling/Minification/Integrity/Cache Busting
- CSS via Tailwind
- Bundling/Minification/Integrity/Cache Busting
- Using tailwind that is installed for you
- Custom CSS is trivial
- Bundling/Minification/Integrity/Cache Busting
- LiveView
- Simple, server rendered Live HTML and CSS, in pure Elixir.
- HTML and Html Attribute Compile Time Verification
- Highly Optimized for the modern web
- Debug tooling for Dev
- JS Interop is Trivial
- Latency Simulation
- Single BEAM Process per connection
- Trivial File Uploads to disk or the cloud.
- Databases with Ecto
- Postgres/MySQL/Sqlite/and more
- Full Query DSL with Raw SQL escape hatch
- Migrations Up/Down/Schema dump
- Full Schema and Change Validation
- Transaction Support
- Multi-step Queries/Transactions
- Full Authorization/Authentication generator
- Register, Login, Forgot Password, Email Verification and Sessions
- LiveView or Server HTML
- Email Rendering and Sending
- Built in Metrics Tracking
- Single Line to add a full Metrics Dashboard
- Dockerfile generator
Just going through this list there is everything you’d need to start a company or build a website to solve nearly any problem. Coupled with the BEAM’s ability to scale from the smallest server to a globally distributed network with millions of customers on every continent! I may sound a little breathless but I am out of a breath just collating all of these links.
Wrap up
Stepping back it’s incredible that a small team is able to accomplish so much. Every one of Phoenix’s incredible features is built on the shoulders of the fantastic Elixir project underneath. Further backed by 37 years of constant development by the Erlang project.
If you haven’t looked into Phoenix or Elixir I urge you to explore any one of the above links that catch your eye. Installing and setting up Elixir has never been easier with LiveBook or Natively!