Overview
March 31, 2026 ยท View on GitHub
This tutorial will teach you to the basic language concepts of Virgil III, starting from basic concepts and progressing to more complex features. It assumes a passing familiarity with at least one programming language that favors curly-braced syntax.
If you're already fairly skilled at another programming language, see Coming From which gives a basic flavor of Virgil in relation to other languages.
This tutorial is organized into a series of articles covered independent aspects of the language, from the basics to advanced concepts. That way, you can jump right into a topic.
Basic usability
- Get started with your first program, the classic Hello World.
- See how to develop for WebAssembly with Virgil.
Language concepts
- How to use variables and definitions.
- Add some structure to our code instead by using components.
- Primitive types are numbers, booleans, strings, characters.
- Numbers include both fixed-size integers and floating-point numbers.
- Methods make up most of the logic of programs.
- Local Variables are how we store data in methods.
- Arithmetic on numbers in Virgil is a lot more general than other programming languages.
- Fixed-sized Integers allow intuitive systems programming and save memory.
- Arrays are key for storing large amounts of data.
- Ranges are a generalization of arrays.
- Strings are key for dealing with files, text, etc.
- Tuples allow using multiple values where one value is expected.
- Tuples and Methods go together particularly well in Virgil.
- Logic is done with familiar control constructs.
- Algebraic data types allow building structured data, including open and extensible variants.
- Enums allow expressing fixed sets of values and even tables.
- Enum sets allow expressing a set of values from a given enum type.
- Virgil has switches and pattern matching.
- Ternary Expressions expressions have a slightly different syntax in Virgil.
- Logical operations can be used to combine boolean expressions.
- First-class functions and partial application support a somewhat functional programming style.
- Functions are first-class values in Virgil.
- Partial Application allows programming with higher-order functions.
- Methods from objects or classes can be used for functional programming.
- Methods can have type parameters and be generic in their type.
- Classes are part of Virgil's support for object-oriented programming.
- Classes can inherit members from superclasses.
- Classes have a nice syntax for immutable fields (called class parameters).
- Classes, too, can have type parameters and thus be generic.
- Class methods can return their receiver object, this.
- Casts allow us to convert one type of data to another, and query the type of data or objects.
- Layouts allow expressing exact data representations for interfacing with external software and hardware.
- Pointers are used in platform-specific parts of the runtime.
- Linking to external code
- Type parameters don't have variance in Virgil; only subtyping on functions.
- Function expressions bring even more functional constructs and allow succint code.
- Simple bodies allow for even shorter method declarations.
- Putting it all together, synthesis.
More advanced topics
- Know enough of the language? Learn how to use some libraries.
- Virgil doesn't yet have exceptions.
- What kind of programming style should I use?
- Some techniques that are used to make Virgil fast.