Remix.run Logo
scuff3d 2 days ago

I agree, and I try to ignore that stuff, but there are a few things that I think are a little more fundamental then that.

This one is fairly minor, but the overly granular namespacing drives me nuts. I shouldn't have to go four or five layers deep to get fairly common functionality. The pattern of returning structs from within structs from within structs just gets old. Maybe that has to do with the way the language handles generics, I don't know.

The attitude to interfaces is also grating. I get that Kelly and the Zig team want to discourage there use, but with the changes to Io it feels a bit like they want to have their cake and eat it to. Before it was mainly just allocators, but now readers, writers, and it sounds like async are all going to be handled through interfaces. But yet the community writ large is still expected to not really use them. Seems like they should have sorted their attitude and approach to interfaces before making these most recent changes.

0-R-1-0-N 2 days ago | parent | next [-]

Reader and writers were interfaces before 0.15.1. What’s new is that they are buffered. I don’t think that zig discourages interfaces, just that the language doesn’t hide anything. An interface in all system languages is a struct with a vtable just like in zig but that they have an easy way of creating one. If you need one in zig you can go that approach or use a tagged union just that zig is open about what an interface is.

bbatha a day ago | parent | next [-]

> f you need one in zig you can go that approach or use a tagged union just that zig is open about what an interface is.

Perl objects worked like this and the ecosystem is a mess as a result. There's a built in `bless` to add a vtable. There's some cool stuff you can do with that like blessing arrays to do array of structs vs struct of arrays and making it look like a regular object in user code. The problem is there are like 4 popular object libraries that provide base stuff like inheritance, meta objects, getters/setters etc and they're not all compatible and they have subtle tradeoffs that get magnified when you have to pull multiple in to get serious work done.

scuff3d 2 days ago | parent | prev [-]

Yes I know. I see the same statement every single time this conversation comes.

Let me ask this: hypothetically if they wanted to, would it be possible for Zig to add a language feature called Interface which provided to the user "...an easy way of creating one".

0-R-1-0-N a day ago | parent [-]

Creating an interface is fairly easy once you know how. I would say that it is as easy as in rust for a beginner. You get used to it and I don’t believe it needs a special keyword.

scuff3d a day ago | parent [-]

That's not what I asked.

lenkite 2 days ago | parent | prev [-]

Zig will be forced to introduce interfaces or traits or whatever they want to call it just like Go was forced dragged, kicking and screaming to introduce generics.

Nobody is going to want to live without proper interfaces or an equivalent in 202x instead of DIY hacks. Its a fundamental, building-block of software development. You will have a gazillion complaining in Zig forums after its 1.0 release.

nasretdinov 2 days ago | parent [-]

The analogy with Go is quite interesting, because in the end, after Go got its generics, the actual usage of this feature is quite minimal compared to what I expected :)

lenkite 2 days ago | parent [-]

That's an interesting assertion but does not hold to reality. Nearly every single modern Go library leverages Generics in some manner AFAIK. It is a feature primarily meant for library authors anyways. Go generics are still limited - nowhere as powerful as Rust/C++ or even Java's generics. Primarily because they added it too late and ran into considerable trouble, instead of upfront thinking about the design.

Interfaces however are far more fundamental. Any app with components and modularization would declare intent through interfaces. Not having interfaces/traits as a language feature is like living without a hand or leg. Sure you can limp and hop, but it will get rather tiresome.