It's still missing linear/affine types, no? To me that's inexcusable given the current offering.
It's still missing linear/affine types, no? To me that's inexcusable given the current offering.
Zig certainly has some cool ideas - I definitely think that we should be making the phase distinction more flexible. I do wish however that its compile time function evaluation was built on a firmer foundation, ie. using dependent types.
Also depending on how you define "dependent types" - there are a few competing definitions - Zig has them.
Although there are differing ways to define dependent types, and they come in different varieties (dependent functions, dependent pairs/structs, very dependent types, dependent intersections, inductive types), they are all founded on a foundation of type theory. I guess if you want me to clarify, it is 'dependent types based on a well understood foundation from type theory'.
---
Edit: seems like Zig does have optional types! That is a good thing! https://ziglang.org/documentation/master/#Optionals
How is it ambiguous? Dependent type systems/algorithms can be weaker than desired, but there's no way you can say Zig has dependent types.
For example you can do:
const std = @import("std");
fn Int(comptime value: i32) type {
return struct {
pub fn value() i32 {
return value;
}
};
}
pub fn main() anyerror!void {
const int3 = Int(3);
const int4 = Int(4);
std.debug.warn("Types: {} {}\n", @typeName(int3), @typeName(int4));
std.debug.warn("Sum: {}\n", int3.value() + int4.value());
}
Output being: Types: Int(3) Int(4)
Sum: 7
Edit: The compiler does the right thing:[2] https://godbolt.org/z/eLWeU2
[1] https://ziglang.org/documentation/master/#Generic-Data-Struc...
I don't have a problem with GC so Nim/D are on the table. ATS is a pain in the ass but after the arrival of Rust it's pretty clear that linear/affine types can be user-friendly. There's no excuse any more.
http://smallcultfollowing.com/babysteps/blog/2018/11/01/afte...
http://smallcultfollowing.com/babysteps/blog/2018/11/10/afte...
So while Rust is much more productive than ATS or Cyclone, there is still room of improvement for that experience.
So D, Nim, C# (AOT compiled), Java (Embedded/Android Things/MicroEJ), Swift, Go are pretty much on the table as well.
Could you clarify the ambiguity you see, and how Zig has them?
It's "linear/affine types," not "linear affine types".
Also: Zig doesn't have linear or affine types. You seem to be quite confused about PL theory, which frankly does not make me any more confident in the language.
Or, the other one: lack of affine/linear types is "inexcusable", really?
As if these are so mainstream that any new language should have them? It's a new language, still in development, use it or not. Zig doesn't want to be a dumpster for trendy PL concepts. It has been designed to be a safer and friendlier C, not a simpler Haskell or Agda.
Current offering being of course Rust.
Rust isn't a "simpler Agda" either. It is a safer C/C++ – as in bare metal capable, no GC, natively compiled… and affine types is what makes the safety possible.
Calling Rust a "simpler Agda" is a bit insane. Rust simply has a sensible, current type system. Agda is full dependent types.
Exactly why the project is pointless. It doesn't offer enough beyond C for there to exist any incentive to switch. I would add that affine types are not simply a "trendy PL concept" given that Rust has used them to great effect.