#Elixir
127 notas · última:
Wiping the tech debt out with immutable code
The post argues that technical debt keeps growing and proposes immutable code as a way to reset it by rewriting isolated components instead of incrementally patching them.
A Brief Guide to OTP in Elixir
The article introduces OTP as Elixir’s process-based toolkit, then shows basic processes, receive loops, GenServer callbacks, and a Supervisor for restarting a treasury process.
Things Elixir's Phoenix Framework Does Right
The article argues that Phoenix sits near the middle between flexible and strict frameworks, stands out in persistent communication, benefits from BEAM-based concurrency, and handles failures and clusters with built-in supervision.
Using Mnesia in an Elixir Application
The post explains what Mnesia is, how it fits soft real-time and fault-tolerant use cases, when to prefer it over PostgreSQL or Redis, and shows an Elixir banking app built with Amnesia.
Why did we choose Elixir for the backend development of MoodleNet?
The post says MoodleNet chose Elixir and Phoenix for backend development because of performance, scalability, concurrency, reliability, simplicity, flexibility, correctness, and developer productivity.
Communicating between LiveViews on the same page
The post compares ways for multiple LiveViews on one page to communicate: via parent and child PIDs, sibling routing through a shared ancestor, or PubSub scoped by root PID or page ID.
Dependency Injection in Elixir
The post compares two ways to apply dependency injection in Elixir: through application config with Application.get_env/3, or by passing collaborators as function parameters, with trade-offs in visibility and flexibility.
You might not need the Calendar or Timex libraries
Elixir’s standard library now covers most date, time, and timezone needs. Third-party libraries still matter for missing features, but many projects can avoid them.
Linear Regression with Elixir, Phoenix and LiveView. Part I
The post builds a simple linear regression model in Elixir, stores training points, and updates weights with gradient descent over multiple epochs to improve predictions.
Elixir Phoenix App deployed into a Load Balanced DigitalOcean setup
The post walks through deploying a Phoenix app on DigitalOcean with Postgres, HAProxy, and two Phoenix nodes, stressing Erlang clustering, release-based deployment, and the limits of PaaS for this setup.
Tracing and observing your remote node
The post explains how to trace and observe a remote Elixir node through EPMD, SSH port forwarding, node naming, cookies, and tools like Erlyberly and Observer.
Building a Game with Phoenix Channels
Tutorial that builds a simple browser game with Phoenix Channels, using an Agent for shared state, channel events for movement, collision detection, Gravatar avatars, and score tracking.
What's coming in Elixir 1.3
The post surveys Elixir 1.3 changes, including stricter scoping, richer `with` support, calendar types, new Mix tasks, and deprecations that will raise warnings.
Writing extensible Elixir with Behaviours
The post explains Elixir Behaviours as explicit public contracts for interchangeable modules, then shows how Swoosh uses them to support multiple email adapters and flexible configuration.
Supervising multiple GenServer processes
The post refactors a single board monitor into one GenServer per board, supervised by a module-based Supervisor, so a failure in one board does not wipe the state of the others.
Debugging techniques in Elixir
The post compares simple printing with two Elixir debugging options: IEx.pry/0 for inspecting a running process and :debugger for breakpoints, variable inspection, and step-by-step navigation.
Elixir obsoletes Ruby, Erlang and Clojure in one go
The author argues that Elixir combines Ruby-like developer experience, Erlang-style concurrency, and useful Clojure features, making Ruby, Erlang, and Clojure obsolete for most use cases.
Designing with OTP Applications in Elixir
The post breaks Domain Scraper into separate OTP applications, argues for independent restart boundaries, and shows an umbrella setup that wires Twitter fetching and the unshortening pool together through streams.
Custom Infix Functions in Elixir
The post shows that Elixir does not let you create new infix operators in regular code. The parser already knows a fixed set of operators, and only those can be implemented.
How to contribute to Elixir
The page explains how to build, test, and verify Elixir changes locally, from running make compile and make test to targeting single packages, using a custom build in an app, and cleaning bad builds.
Parallel Elixir Run
The post shows how to distribute letter-frequency work across several Elixir processes with Task.async and Task.await, then merge the partial results. It reports faster runtimes with multiple workers than with one.
Fragments in Ecto
The post shows how to query date ranges in Ecto by using `fragment/1` with Postgres `OVERLAPS`, plus `type/2` to tell Ecto the date types it cannot infer.
Folding Window Functions Into Ecto
The post shows how to rank trips by category with PostgreSQL window functions, then reproduce the query in Ecto 2.0 using raw SQL and tests, comparing it with a naive in-memory approach.
Remote IEx access via :ssh
The post shows how to start the SSH application first, then launch the daemon with IEx as the shell so a remote Elixir node opens an interactive IEx prompt over SSH.
Writing Acceptance tests in Phoenix
The post shows how to write acceptance tests in Phoenix with Hound, from setup and an IntegrationCase to form interactions, while noting the runtime cost of these tests.
Writing Documentation – Elixir v1.3.0-dev
Elixir treats documentation as a first-class citizen and explains how to write it with Markdown, module attributes, doctests, privacy rules, and the difference between docs and comments.
Phoenix, to the basics and beyond.
The post outlines a short set of Phoenix topics beyond the default generators: editor setup, model definitions, custom primary keys and validators, and a Repository-based approach with macros.
What I learned migrating a Rails app to Elixir/Phoenix
The migration favors small functions, explicit composition, and Phoenix idioms over Rails patterns. It also shows where the ecosystem is thinner and where custom integrations or rewrites are needed.
Phoenix: The difference between web and lib
Phoenix has two code locations, `web` and `lib`. The key difference is that `web` is hot reloaded on each request, while `lib` is suited to state that lives beyond a request lifecycle.
Comparing Elixir and Erlang variables
The article compares Elixir rebinding and Erlang pattern matching, showing how both can cause hidden bugs when variables are added, removed, or reused in changing code.
Test-Driven APIs with Phoenix and Elixir
The tutorial uses TDD to build a Phoenix API for listing movies, adding dependencies, routes, a controller, a view, and a model while showing how each test failure guides the next change.
The Obligatory “Flame War” Phoenix vs Node.js
The post compares Node.js and Phoenix with simple Siege benchmarks, showing Node doing fine on I/O-bound requests but collapsing when each request blocks for one second, while Phoenix keeps handling the load.
When to choose Elixir over Ruby for 2016 projects?
The article says Rails still fits internal apps, prototypes, smaller user bases, cacheable sites, and systems that can be split up. Elixir is better for high traffic, async, distributed, real-time, always-on, and large systems.
Elixir Christmas Tree Puzzle
A coding puzzle asks for an Elixir program that prints a centered Christmas tree made of zeros, with a star on top and a trunk at the bottom, and ranks solutions by character count.
Building an API Facade with Elixir
The post describes building a lightweight API serializer facade in Elixir and Phoenix, using pattern matching, guard clauses, and macros to keep serialization format-agnostic and DRY.
Ex Pusher Lite - Part 1: Phoenix Channels and Rails apps
The post shows a Rails chat built with Pusher, then starts replacing Pusher with a Phoenix server that receives POSTs from Rails and broadcasts them over WebSockets.
Sharing Functions Between Phoenix Controllers
The post explains how Phoenix controllers share imports through web/web.ex, how use MyApp.Web, :controller expands __using__/3, and how adding an import there makes helper functions available to all controllers.
What makes Elixir so attractive for some developers?
The post collects other developers’ reasons for liking Elixir, especially performance, concurrency, fault tolerance, metaprogramming, tooling, and Phoenix for real-time and distributed systems.
Blinking LEDs and Spinning Servos with Elixir
The author describes building an Elixir-based Raspberry Pi setup for an automated cat feeder, starting with an LED blink test, then a servo, then a proximity sensor, using Adafruit parts and library help.
Mocks and explicit contracts
The post argues that mocks are useful, but only when they replace a real dependency through an explicit contract. That keeps tests isolated, makes boundaries visible, and avoids coupling to implementation details.
