What Elixir Does
- Functional — immutable data, pattern matching, pipe operator
- Actor model — lightweight processes (millions per node)
- OTP — supervision trees, GenServer, Agent, Task
- Fault tolerance — let it crash philosophy, supervised restarts
- Distribution — connect nodes across machines
- Hot code reload — swap code without downtime
- Phoenix — high-performance web framework
- LiveView — server-rendered real-time UI without JS
- Ecto — database abstraction with changesets and query DSL
- Mix — build tool, tasks, compiler, tests
- ExUnit — built-in test framework
Architecture
Elixir code compiles to Erlang bytecode and runs on BEAM VM. Each process is isolated (own heap), messages are passed by copy, and the scheduler is preemptive across processes. Supervisors restart failed children per a declared strategy. Cluster formation via Erlang Distribution Protocol.
Self-Hosting
Language toolchain.
Key Features
- BEAM VM (Erlang runtime)
- Millions of lightweight processes
- Actor model messaging
- OTP supervision trees
- Hot code upgrade
- Distributed clustering
- Pattern matching
- Pipe operator for data flow
- Phoenix web framework
- LiveView for real-time UIs
- Mix build tool
Comparison
| Language | Runtime | Concurrency | Fault Tolerance |
|---|---|---|---|
| Elixir | BEAM | Actor model | Supervision |
| Erlang | BEAM | Actor model | Supervision |
| Go | Native | Goroutines | Manual |
| Scala (Akka) | JVM | Actor model | Supervision |
| Rust | Native | Async + threads | Result types |
| Java | JVM | Threads + Loom | Exceptions |
常见问题 FAQ
Q: Elixir vs Erlang? A: 同一 VM (BEAM),语法不同。Elixir 语法更现代 (Ruby-ish),macros 更强,Mix 工具更友好。Erlang 语法更贴近 Prolog,对老玩家习惯。新项目推荐 Elixir。
Q: LiveView 是什么? A: Phoenix 的特色功能——服务端渲染 UI,通过 WebSocket 推送 diff 到浏览器。零 JS 代码做实时 UI,和 React 级体验接近但无前后端分离。
Q: 适合什么场景? A: 实时应用、聊天、游戏服务器、IoT 后端、高并发 API、需要 fault tolerance 的系统。WhatsApp、Discord、Pinterest 都在用。
来源与致谢 Sources
- Docs: https://elixir-lang.org/docs.html
- GitHub: https://github.com/elixir-lang/elixir
- License: Apache 2.0