These are notes for a Zig-inspired strongly-typed GC language, taking some aspects from Python, and retaining some smiilar simplicity as promised by Go.
Zig brings so several great ideas to the table, but a variant of its apporoach for application-space would be very welcome, so it would provide a similar experience to Zig with many of its characteristics:
- error unions
- optionals
- defer
- block scopes
- structs
- struct methods with explicit
self
- strict typing
- mandatory discard-assignment
- import to const
- public/private scope
It adds on top of this:
- garbage collection
- native variable-length lists with
[]
notation and hash maps with{}
notation - three native primitive types (int (
i64
), float (f128
), bool) - three native composite types (string (
[]u8
), list (ArrayList
), map (map(string, <T>)
)) - native strings and string-interpolation
- supporting native types
- supporting UTF8 via UTF-8 wrapper type and methods
- Error payloads - errors can carry a message, not just exist as their own type
assert
keyword on booleans (no "truthy" evaluation on other types, incl optionals)- simple enumerations (
enum { a, b, c}
, potentially assignment of primitives) - interface types
It would explicitly leave out comptime as the concept doesn't map, and specifially would choose to not implement:
- pointers - they could be made to map (Go does this) but I am wary of having this alongside a GC
- any attempt at object orientation - I'm not convinced this is desirable, and adds language implementation complexity
- closures - they make tracing back during debugging a nightmare, and falsely complexify systems. They're also more complicated to implement. Struct interface types with methods can help instead.
To be clear I'm not expecting to implement this any time soon, if at all.... these are just musings in a stub note...
See Zis_example.zig
(should be .zis
but changed the extension to use formatting