Learn Julia interactively in your console/terminal, inspired by the swirl library for R!
Swirl.jl is an interactive learning platform that teaches you Julia programming right in your REPL (Read-Eval-Print Loop). Work through lessons at your own pace, get instant feedback on your answers, and build your Julia skills step by step.
📺 Watch a demo video to see Swirl in action!
After trying it out, feel free to give it a ⭐ on GitHub!
- 🎓 Interactive Learning: Type real
Juliacode and get immediate feedback - 📚 Structured Courses: Progress through well-designed lessons
- 💾 Auto-Save Progress: Your progress is automatically saved after each question
- 💡 Smart Hints: Get detailed, educational hints when you're stuck
- 🎯 Multiple Question Types: Messages, multiple choice, and code evaluation
- 🌟 Built-in Content: Comes with a short "Julia Basics" course
- 📦 Custom Courses: Install courses from
GitHub, URLs, or local directories - 🔄 Flexible Navigation: Easy menu navigation with back/exit commands
- 🎮 Progress Management: Reset and retake lessons anytime
- 🚀 Natural Interaction: Multi-step questions and natural code exploration
# From Julia REPL
using Pkg
Pkg.add(url="https://github.com/atantos/Swirl.jl")Or for local development:
using Pkg
Pkg.develop(path="/path/to/Swirl.jl")using Swirl
# Start learning!
swirl()That's it! The interface will guide you through:
- Selecting a course
- Choosing a lesson
- Working through interactive questions
# Start an interactive lesson
swirl()
# View all available courses
list_courses()
# Install a custom course
install_course("path/or/url")
# Uninstall a custom course
uninstall_course("Course Name")
# Delete all progress
delete_progress()While working through a lesson, you can use these commands:
| Command | Action |
|---|---|
hint or ? |
Get a detailed hint for the current question |
skip |
Skip the current question and move to the next |
back or menu |
Return to the lesson selection menu |
info |
Show all available commands |
exit or quit |
Exit Swirl (returns to Julia REPL, progress saved) |
At the Course Menu:
- Type a number to select a course
- Type
0to exitSwirl
At the Lesson Menu:
- Type a number to select a lesson
- Type
0to go back to course selection - Type
reset 1to reset lesson 1 - Type
reset allto reset all lessons in the course
julia> using Swirl
julia> swirl()
🌀 Welcome to Swirl for Julia!
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Type ) to enter Swirl mode. (Press backspace anytime to exit Swirl mode.)
Available courses
=================
1. Julia Basics
─────────────────────────────────────────────────────────────────────────────────────────────────────
⚙️ Commands
––––––––––
• -1 — Exit Swirl
💡 Select a course (enter number):
swirl> 1
📘 Lessons in Julia Basics
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
1. [✓] Basic Math and Bindings
2. [ ] Types and Functions
3. [ ] Vectors and Arrays ← in progress
─────────────────────────────────────────────────────────────────────────────────────────────────────
⚙️ Commands
––––––––––
• 0 — Back to course selection
• -1 — Exit Swirl
• reset <number> — Reset a specific lesson (e.g. reset 1)
• reset all — Reset all lessons in this course
💡 Type a lesson number or command:
swirl> 2
Types and Functions
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Learn about Julia's type system and how to use functions.
=========================================================
--- Question 3 of 6 ---
Strings in Julia are created with double quotes. Check what type "hello" is.
swirl> typeof("hello")
String
✓ Correct!
--- Question 4 of 6 ---
Julia has many built-in functions. The sqrt() function calculates square roots. Calculate the square
root of 16.
swirl> menu
💾 Saving progress and returning to lesson menu...
📘 Lessons in Julia Basics
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
1. [✓] Basic Math and Bindings
2. [ ] Types and Functions ← in progress
3. [ ] Vectors and Arrays
─────────────────────────────────────────────────────────────────────────────────────────────────────
⚙️ Commands
––––––––––
• 0 — Back to course selection
• -1 — Exit Swirl
• reset <number> — Reset a specific lesson (e.g. reset 1)
• reset all — Reset all lessons in this course
💡 Type a lesson number or command:
...Note: The example above shows REPL mode (with ReplMaker.jl installed). The prompt changes to
swirl>and you get syntax highlighting. Without ReplMaker, you'll use classic mode with the standardjulia>prompt.
Swirl.jl comes with the Julia Basics course, which includes:
- Arithmetic operations (+, -, *, /, ^)
- Biding creation and naming
- Updating bindings
- Understanding
Julia's type system - Using
typeof()for type checking - Built-in functions (sqrt, abs, etc.)
- Defining your own simple functions
- Creating arrays with
[] - Array indexing (1-based)
- Array functions (length, sum, push!, etc.)
- Using ranges with
:
Each lesson includes:
- Clear explanations
- Hands-on exercises
- Detailed hints
- Multiple choice questions
- Progress tracking
# Your course directory should contain a course.jl file
install_course("/path/to/my_course")# Install directly from a GitHub repository
install_course("https://github.com/atantos/course-repo")# Install from a .zip or .tar.gz archive
install_course("https://example.com/course.zip")Note: Installing from GitHub or URLs requires system commands to be available:
unzipfor .zip files (GitHub repos and .zip archives)tarfor .tar.gz filesThese are typically pre-installed on Linux/macOS. On Windows, you may need Git Bash, WSL, or manual extraction.
# 1. Create a course directory
mkdir ~/my_julia_course
# 2. Copy the template
cp templates/course/course.jl ~/my_julia_course/
# 3. Edit it with your content
# Edit ~/my_julia_course/course.jl# 4. Install it
using Swirl
install_course(expanduser("~/my_julia_course"))
# 5. Use it!
swirl()-
Use the template:
cp templates/course/course.jl ~/my_course/ -
Edit the course:
Course(
"My Awesome Beginners' Course",
"Description of what students will learn",
[
Lesson(
"Basic Math and Bindings",
md"# Basic Math and Bindings",
md"## Learn basic arithmetic operations and how to create bindings in Julia.",
[
CodeQ(
text=md"*Welcome to Swirl* for `Julia`! In this lesson, you'll learn the basics of `Julia` programming. We'll start with simple math operations and bindings. Let's begin! `Julia` can be used as a calculator. Try adding `5 + 3`.",
answer=8,
hint=md"Simply type the numbers and the plus sign: `5 + 3`
`Julia` will evaluate the expression and show you the result."
),
# ... more lessons
]
)-
Install and test:
install_course(expanduser("~/my_course")) swirl()
Display informational content without requiring an answer. Students simply press Enter to continue.
MessageQ("Welcome to this lesson!")
Ask students to write Julia code and check if the result matches the expected answer.
CodeQ(
"Calculate 2 + 2",
4, # Expected result
"Type: 2 + 2" # Hint (optional)
)Present students with multiple options to choose from. Students enter the number corresponding to their choice.
MultipleChoiceQ(
"What operator is used for exponentiation?",
["*", "**", "^", "pow"], # Choices array
3, # Index of correct answer (1-based)
"It's the ^ symbol" # Hint (optional)
)
# Without hint
MultipleChoiceQ(
"What is Julia?",
["A programming language", "A person", "A city"],
1
)Check for an exact string match (case-sensitive).
ExactQ(
"What keyword defines a function in Julia?",
"function",
"It's the word you type before the function name" # Hint (optional)
)
# Without hint
ExactQ("What keyword defines a function?", "function")Students can build on previous work since variable bindings persist between questions.
MultistepCodeQ(
text=md"**Good**! Bindings let you reuse values. Now create a binding `y` with the value `5`, then add `x` and `y` together.",
answer=15,
hint="",
steps=[
md"Create a binding `y` with value `5`.",
md"Add `x` and `y` together."
],
step_hints=[
md"Type: `y = 5`
Bindings let you refer to values for later use.",
md"Type: `x + y`
Remember: `x` is still `10` from the previous question!"
],
setup="x = 10"
)Swirl.jl/
├── src/ # Source code
│ ├── Swirl.jl # Main module
│ ├── types.jl # Core data structures
│ ├── parser.jl # Code evaluation
│ ├── runner.jl # Lesson execution
│ ├── progress.jl # Progress tracking
│ └── courses.jl # Course management (includes built-in Julia Basics)
│
├── templates/ # Templates for creating courses
│ ├── course/
│ └── lesson/
│
├── README.md # Documentation
│
└── test/
└── runtests.jl
Swirl.jl evaluates your Julia code in real-time using the Main module, so:
- ✅ Bindings you create persist between questions
- ✅ You can use any
Juliafeature - ✅ Your code runs in the same environment as your
REPL - ✅ Multi-step questions work naturally
~/.swirl_julia/
├── courses/ # Installed custom courses
│ ├── Course1/
│ └── Course2/
└── progress/ # Your saved progress
└── *.progress
Progress is automatically saved:
- After each correct answer
- When you exit a lesson
- When you navigate back to menus
Q: Where is my progress saved?
A: Progress is saved in ~/.swirl_julia/progress/ in your home directory. It's automatically saved after each question.
Q: Can I restart a completed lesson?
A: Yes! You can either:
- Select the lesson and choose "yes" when asked to restart
- Type
reset 1at the lesson menu to reset lesson 1
Q: Will typing 'exit' close my Julia session?
A: No! The exit command returns you to the Julia REPL. Your session continues and all bindings remain available.
Q: What if I make a mistake?
A: You get 3 attempts per question, and you can always type hint for detailed help!
Q: Can I share my custom course?
A: Yes! Push it to GitHub and others can install it with:
install_course("https://github.com/username/your-course")Q: How do I uninstall a course?
A: Use uninstall_course("Course Name"). Note: Built-in courses like Julia Basics cannot be uninstalled.
Q: Can I modify an installed course?
A: Yes! User-installed courses are stored as files in ~/.swirl_julia/courses/ and can be edited directly.
Contributions are welcome! Whether it's:
- 🐛 Bug reports
- 💡 Feature suggestions
- 📚 New course content
- 🔧 Code improvements
- 📖 Documentation enhancements
Please feel free to open an issue or submit a pull request.
- Create your course using the templates
- Test it thoroughly with
install_course()andswirl() - Push to
GitHub - Share the installation command!
- Interactive code evaluation
- Progress tracking and saving
- Multiple question types
- Smart hints system
- Custom course installation (local,
GitHub, URL) - Course management (install/uninstall)
- Lesson reset and retake
- Natural multi-step questions
- Improved navigation
- More built-in courses (intermediate/advanced topics)
- Multimedia content support
- Achievements and badges
- Community course repository
- Course version management
MIT License - see LICENSE file for details
Inspired by the excellent swirl package for R, which has helped countless people learn R programming.
Special thanks to the Julia community for creating and maintaining such an amazing language to teach!
using Pkg
Pkg.add(url="https://github.com/atantos/Swirl.jl")
using Swirl
swirl()Happy Learning! 🎉
Start your Julia journey today with swirl()!
# Learning
swirl() # Start learning
# Course Management
list_courses() # See all available courses
install_course("source") # Install course
uninstall_course("Course Name") # Remove course
# Progress Management
delete_progress() # Delete all progress
# During Lessons (type these in Swirl mode)
hint # Get help
skip # Skip question
menu # Return to menu
exit # Exit SwirlThat's all you need to get started! 🌀