返回课程
AI019 专业级

Elixir 编程

一份全面的 Elixir 函数式与并发编程指南。涵盖从面向对象思维到函数式思维的转变、模式匹配、不可变性、基于演员模型的并发处理,以及使用 OTP 构建健壮的分布式系统。

4.8
30.0h
981 名学生
10 lessons
0 点赞
人工智能
开始学习

课程概述

📚 内容概要

一本全面介绍使用 Elixir 进行函数式与并发编程的指南。内容涵盖从面向对象思维转向函数式思维、模式匹配、不可变性、基于角色模型的并发机制,以及利用 OTP 构建健壮的分布式系统。

通过函数式编程的美妙,掌握构建弹性并发系统的艺术。

作者: 戴夫·托马斯(Dave Thomas)

致谢: 何塞·瓦利姆(José Valim)、科里·海恩斯(Corey Haines)、布鲁斯·泰特(Bruce Tate)、杰西卡·克尔(Jessica Kerr)、安德鲁·艾登(Anthony Eden)、查德·福勒(Chad Fowler)、金·沙里尔(Kim Shrier)、坎达斯·坎宁安(Candace Cunningham)及波托马克索引(Potomac Indexing)。

🎯 学习目标

  1. 对比 Elixir 的数据转换模型与传统的基于状态的编程方式。
  2. 配置交互式 Elixir shell(IEx),并通过脚本和编译执行 Elixir 代码。
  3. 使用匹配操作符(=)、钉操作符(^)和通配符(_)进行数据解构与验证。
  4. 解释不可变性在性能与内存管理方面的理论与实际影响。
  5. 识别并使用 Elixir 内置类型,包括值类型、系统类型和集合类型。
  6. 应用变量作用域规则与 with 表达式来管理复杂的数据转换。
  7. 使用标准语法和捕获语法(&)创建并调用匿名函数。
  8. 在模块中使用模式匹配与递归实现命名函数,以处理复杂逻辑。
  9. 使用保护条件和默认参数控制函数执行流程。
  10. 解构与构建列表: 利用头/尾模式匹配遍历和构建递归列表结构。

课程

Lesson

This lesson introduces Elixir as a functional language focused on data transformation, emphasizing the importance of immutability and the use of the pipe operator for clean, predictable code. Students will also learn how Elixir’s actor-based concurrency model uses isolated processes and message passing to ensure thread safety and system scalability.

This lesson introduces the functional paradigm of Elixir, focusing on the core concept of data immutability and the use of pattern matching over variable mutation. Students will learn how to perform data transformations to create new values rather than modifying existing ones, ensuring predictable and thread-safe code.

This lesson explores foundational functional programming in Elixir, focusing on anonymous and named functions, module encapsulation, and the use of the pipe operator for data transformation. Students will also learn to leverage pattern matching and the `with` expression to handle complex, multi-step logic safely and effectively.

AI019: Recursive Lists and Data Structures (Lesson 4) explores the recursive nature of linked lists in Elixir, focusing on head-tail decomposition and the implementation of custom recursive functions. Students will learn to identify base cases, utilize the cons operator, and apply recursive patterns to perform efficient list operations.

This lesson explores the differences between greedy processing with the Enum module and lazy processing with the Stream module in Elixir. Students will learn to implement the Enumerable protocol and apply these concepts to perform memory-efficient data transformations and advanced string processing.

This lesson explores advanced Elixir control flow, focusing on pattern matching with case expressions, guard clauses, and the use of the with construct for error handling. Students will also learn to manage project structures using Mix and improve code quality through professional tooling like Credo and Dialyzer.

This lesson explores how to maintain persistent state in Elixir using recursive functions and Tail-Call Optimization (TCO) to keep processes alive. Students will learn to manage process lifecycles, handle message passing, and implement deterministic communication patterns in concurrent systems.

This lesson explores the fundamentals of the Open Telecom Platform (OTP) in Elixir, focusing on how behaviors, supervision trees, and I/O messaging enable the creation of fault-tolerant, distributed applications. Students will learn to implement GenServers and leverage the Error Kernel philosophy to build robust systems that effectively manage process lifecycles and inter-node communication.

This lesson explores advanced OTP architectures and the Five-Question Framework to achieve high-reliability state management in Elixir. Students will learn to design robust supervision trees and distributed systems by systematically defining environment constraints, focal points, and fault-tolerance strategies.

This lesson explores Elixir’s metaprogramming capabilities, focusing on how the language's homoiconic nature allows source code to be treated as data via the Abstract Syntax Tree (AST). Students will learn to design extensible software using protocols and macros while evaluating how static analysis tools like Dialyzer provide type safety without sacrificing dynamic flexibility.