An interactive tutorial website for learning Erlang by building a WebSocket chat server from scratch. This project teaches Erlang through hands-on coding, progressing from basic syntax to building a production-ready distributed chat system.
Through 35 progressive lessons, you'll build a complete WebSocket chat server while learning:
- Erlang fundamentals and functional programming
- OTP (Open Telecom Platform) patterns
- Concurrent and distributed systems
- Real-time communication with WebSockets
- Production deployment and operations
- Interactive Koans: Fill-in-the-blank exercises with immediate feedback
- Progressive Learning: Each lesson builds on the previous ones
- Real Project: Build an actual chat server, not just toy examples
- Modern UI: Dark/light mode, syntax highlighting, progress tracking
- Responsive Design: Works great on desktop and mobile
- Fast Search: Quick lesson search with keyboard shortcuts (Cmd/Ctrl+K)
- Node.js 22
- npm
# Clone the repository
git clone https://github.com/pennypack/learn-erlang.git
cd learn-erlang
# Install dependencies
npm install
# Start development server
npm run dev
# Open http://localhost:4321# Type check and build
npm run build
# Preview production build
npm run previewWe welcome contributions! Here's how you can help:
- Check existing issues first
- Use issue templates when available
- Include browser/OS information for UI issues
- Provide code examples for content issues
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run type checking:
npx astro check - Commit with clear messages:
git commit -m "Add: your feature" - Push to your fork:
git push origin feature/your-feature - Open a pull request
When contributing lessons or koans:
- Follow the existing lesson structure
- Keep examples practical and building toward the chat server
- Write clear, concise explanations
- Include 6-8 koans per lesson testing key concepts
- Test all code examples
- Follow the writing style in existing lessons
When creating or modifying koans:
- Single Blank Rule: Every koan MUST have exactly one
___blank - Clear Questions: Questions should be specific about what goes in the blank
- Simple Answers: Answers should be single values, expressions, or identifiers (not comma-separated lists)
- Test Coverage: All koan patterns MUST have corresponding tests in
js-erlang-interpreter/tests/ - Validation Types: Use appropriate validation hints:
value_check: For numeric or string valuespattern_check: For pattern matching scenarios- Default: Simple string comparison
Example koan structure:
{
id: "unique_koan_id",
question: "What value makes this base case work?",
code: "Factorial = fun\n (0) -> ___;\n (N) -> N * Factorial(N - 1)\nend.",
answer: "1",
validation: "value_check", // optional
hint: "Think about 0! = ?", // optional
explanation: "The factorial of 0 is defined as 1" // optional
}- Use TypeScript for new components
- Follow existing formatting (2 space indentation)
- Keep components small and focused
- Add comments for complex logic
- Create a new file in
src/content/lessons/ - Use the required frontmatter:
---
title: "Your Lesson Title"
description: "Brief description"
postNumber: 36
publishDate: 2025-01-17T00:00:00Z
tags: ["erlang", "your-topic"]
difficulty: "intermediate"
prerequisites: [1, 2, 3]
---- Write content following the established pattern
- Add interactive koans at the end
- Test the lesson thoroughly
src/
├── components/ # UI components
├── content/
│ ├── config.ts # Content schema
│ └── lessons/ # Tutorial lessons
├── layouts/ # Page layouts
├── pages/ # Routes
└── styles/ # Global styles
- Framework: Astro
- Styling: Tailwind CSS
- Language: TypeScript
- Syntax Highlighting: Expressive Code
- Interactive Koans: Custom Erlang interpreter
The interactive koans are powered by a custom JavaScript-based Erlang interpreter located in /js-erlang-interpreter. This interpreter:
- Supports basic Erlang syntax for educational exercises
- Handles pattern matching, lists, atoms, and function calls
- Provides immediate feedback for learning
- Runs entirely in the browser for a seamless experience
The interpreter is designed for teaching basic concepts and currently supports:
- Simple pattern matching
- List operations
- Basic arithmetic and comparisons
- Atoms and tuples
- Simple function definitions
The interpreter needs enhancement to support more advanced koans. Areas for improvement include:
- Map syntax and operations
- Process spawning and message passing
- More complex pattern matching scenarios
- Binary syntax
- Guards and list comprehensions
- Module system basics
Testing Requirements: When adding new koan patterns or interpreter features:
- All koan patterns MUST have corresponding test cases in
js-erlang-interpreter/tests/ - Test files should follow the naming convention:
lessonXX-koans.test.js - Each test should validate that the koan's expected answer produces the correct result
- Run tests with
npm testin thejs-erlang-interpreterdirectory - Ensure all tests pass before submitting a PR
If you're interested in extending the interpreter, see /js-erlang-interpreter/README.md for implementation details.
This project is licensed under the MIT License - see the LICENSE file for details.
- The Erlang/OTP team for creating an amazing platform
- The Astro team for their fantastic framework
- All contributors who help improve this tutorial
Built with ❤️ by Pennypack Software and the Erlang Community