Valkyrie Tutorial
A multi-stage gradual typed language
Introduce
Valkyrie is a experimental multi-stage gradual typed language, hoping to combine the respective advantages of static typing and dynamic typing.
Integrate functional programming and object-oriented programming paradigms, and explore new effect-based paradigms.
The grammar mainly borrows from scala and swift, But many runtime concepts come from rust.
In fact, you can think of it as scala implemented in rust.
Features
- Algebraic Data Types
- Your favorite functional paradigm
- Null-safe, languages under the ADT model are strictly null-safe
- Algebraic subtyping
- Restricted traditional object-oriented paradigm
- Algebraic Effects (planned, semantically unclear)
- Gradual Structure Typing
- Intelligent automatic type inference (in progress)
- AST Macros (in progress)
- Multi-stage programming with package isolation (not yet implemented)
- Concurrent Garbage Collection (in plan, use rc for now)
- Lossless Rust FFI (in plan, waiting for crABI)
Tools & Community
Jupyter Runner: interactive execution environment
Idea Intellij: IDEA support
AST Visitor: AST definition and pretty print
Advice on Github: github.com/valkyrie-language
Tutorial
Learn basic syntax first
- Literals: learn basic literals like bool, string and integer
- Collections: learn common collections like list, map, set
- Calls and subscripts: learn how to call functions and get items
- Let Bind: learn how to define variables
- Define Function: learn how to define functions
- Module & Package: learn how to organize code
Then learn how to combine FP and OOP
- Structure and Class: learn polymorphism through subtyping
- Interface and Trait: learn polymorphism through type class
- Enumerate & Flags: Learn to code in a more readable way
- Disjoint Union and Variants: learn polymorphism through ADT
- Macro: learn meta programming through AST transformation
Then learn funky control flow
- If & Switch: learn how to jump by condition
- While Loop & For Loop: learn how to loop with condition and iterator
- Return, Break and Continue: learn how to return non-locally
- Try, Catch and Resume: learn how to return non-locally
Finally, a never-ending journey of advancement
- Pattern Match & Extractor
- Constructor and Builder
- Define Effect
Io
effect andLogging
effect- Generics, covariance, contravariance and invariance
- Type conversion, type reinterpretation and type transmutation
- Iterators and Generators
- Closures, callbacks and asynchronous programming
- Raw pointers and unsafe programming
- Value types and the stack allocation
- Macro and package isolation compile