First-Class Types, Syntactically (2024)
a day ago
- #compile-time
- #type-systems
- #programming-languages
- Zig treats types as first-class values, requiring compile-time code execution (comptime).
- Comptime has drawbacks: debugging and profiling are harder, and compilation becomes less predictable.
- Odin demonstrates an alternative approach to first-class types without comptime, using unified syntax for types and values.
- Macros in C can simulate generic functions but mix type and value parameters.
- Odin's syntax allows type parameters to be passed like values, improving readability and flexibility.
- Unifying type and value syntax enables operators to have different meanings based on context (e.g., casting with call syntax).
- Go's casting syntax is praised for its simplicity and clarity.