Overview
The--hot flag enables hot reload mode, which automatically watches your project files for changes and restarts your application when modifications are detected. This significantly improves the development workflow by eliminating manual restarts.
Syntax
Path to the main Wren script file to execute with hot reloading enabled.
How It Works
When hot reload is enabled:- Initial Run: Starts your Talon application normally
- File Watching: Monitors the current directory and all subdirectories for file changes
- Change Detection: Uses platform-specific file watchers (inotify on Linux, FSEvents on macOS, ReadDirectoryChangesW on Windows)
- Debouncing: Waits 25ms after the last change before triggering a reload (prevents multiple rapid reloads)
- Graceful Restart: Stops the current VM, then starts a new one with the updated code
- WebSocket Notification: Broadcasts reload events to any connected clients (useful for WASM builds)
File Watching
The hot reload system watches:- The current working directory (
.) - All immediate subdirectories
- All
.wrenfiles in these locations
Examples
Basic Hot Reload
Start your game with hot reloading:.wren file in your project. The application will automatically restart with your changes.
Development Workflow
main.wren or any imported module:
Working with Multiple Files
The hot reload watches all files in your project:main.wrengame.wrenutils.wren- Any other
.wrenfiles in the directory
Debouncing
The hot reload system includes intelligent debouncing with a 25ms cascade window. This means:- Multiple rapid file changes (like saving multiple files) are batched together
- Only one reload occurs after changes stabilize
- Prevents excessive restarts during bulk edits
WebSocket Integration
Hot reload includes a WebSocket server that:- Notifies connected clients about reload events
- Sends
{"command": "reload_all"}messages on file changes - Useful for browser-based WASM builds that can listen for reload events
Platform Support
Hot reload is supported on:- Linux: Uses inotify for efficient file watching
- macOS: Uses FSEvents API
- Windows: Uses ReadDirectoryChangesW API
Limitations
Current Status
Not Watched
- Files in deeply nested subdirectories (beyond one level)
- Files outside the current working directory
- Binary assets (textures, sounds) - these require a manual restart
Use Cases
Rapid Prototyping
Perfect for quickly iterating on game mechanics:Game Development
Ideal for game development workflow:- Adjust player physics
- Tweak enemy AI
- Modify level layouts
- Change visual effects
Learning and Experimentation
Great for learning Talon and Raylib:Performance Considerations
- Startup Time: Each reload includes full VM initialization
- State Loss: Application state is not preserved across reloads
- File I/O: Minimal overhead from file watching on modern systems
Comparison with Normal Run
| Feature | talon <file> | talon --hot <file> |
|---|---|---|
| Initial startup | Same | Same |
| File watching | No | Yes |
| Auto-reload | No | Yes |
| Manual restart needed | Yes | No |
| WebSocket server | No | Yes |
| Best for | Production, testing | Development |
Related Commands
talon run- Run without hot reloadtalon init-exe- Generate production buildstalon init-wasm- Generate WASM builds with hot reload support
Tips
Maximize Efficiency
- Keep Entry Point Small: Put most logic in separate modules to minimize reload time
- Use Modular Design: Well-structured code benefits more from hot reload
- Save All Files: Some editors save files with delays - ensure files are saved before expecting reload
Debugging
If hot reload isn’t working:- Check file permissions
- Verify the file is in the watched directory
- Look for error messages in the console
- Ensure file changes are actually being saved