Learning Guide for LuneScript Beginners
LuneScript is a powerful language, but beginners may feel overwhelmed by its unique notation and type system if they try to understand everything at once. This guide suggests how to learn efficiently and how to use the documentation.
Step 1: Environment Setup and Getting Used to Types
1-1. Installation and Hello World
First, set up your environment and see how simple code is converted to Lua. (Tutorial)
1-2. Introduction to Static Typing
The biggest difference from Lua is "types". Get into the habit of specifying types when declaring variables. You will understand the convenience of LuneScript by experiencing its powerful type inference. (Basic Syntax)
Step 2: Understanding LuneScript's "Safety Devices"
2-1. Nil Safety and Unwrap
The most common compilation errors are related to nil. Learn how to write safe code using
if! let and unwrap.
(Nilable Types)
2-2. Uninitialized Variable Detection
Appreciate the security of having the compiler prevent variables from being referenced while uninitialized through flow analysis. (Flow Analysis)
Step 3: Modern Features to Improve Productivity
3-1. Error Delegation (!)
This is one of LuneScript's headline features. Experience how much cleaner deep nested error handling becomes using this. (Error Handling)
3-2. Classes and OOP
Learn the convenience of defining and inheriting classes intuitively without worrying about Lua's metatables. (Classes)
Step 4: Challenging Practical Tasks
Try the practical sections at the end of the reference. In particular, the "Expression Parser" is excellent practice for integrating types, classes, ADTs, and pattern matching.
Documentation Lookup Tips
- Keywords List (Details): Look up the meaning of unfamiliar
symbols (e.g.,
let!,,,,,@@@). - Troubleshooting (Details): Use this as a collection of patterns for when you can't resolve a compilation error.
Learning Advice
Transcompile small snippets: The shortest route to understanding behavior is to write a few lines and see the resulting Lua.
Restrict existing Lua code with types: You can experience the safety provided by type constraints by rewriting existing Lua assets.
Don't use everything at once: Start by using it as "Lua with types". Advanced features can wait until you need them.