Live data from Hacker News

Type resolution redesign, with language changes to taste

ziglang.org

211–220 of 284 posts

Re: Type resolution redesign, with language changes to taste

#211
post #166
post #146

Hi, author of this devlog here! Not to dismiss concerns about breaking language changes, but there seems to be a bit of a misconception here that this compiler change was highly breaking and will require significant effort from Zig users to update for. Perhaps I unintentionally gave that impression in the devlog or the PR writeup, apologies if so---but it's not the case! Although there were breaking changes in this p…

I am going to ask a question that is is definitely not the place for, but I am not involved with Zig in any way and am curious, so I hope you'll indulge me. I noticed the following comment was added to lib/std/multi_array_list.zig [0] with this change: /// This pointer is always aligned to the boundary `sizes.big_align`; this is not specified /// in the type to avoid `MultiArrayList(T)` depending on the alignment of…

I had to search for this, but managed to find the relevant mlugg@ comment[0] on the ZSF zulip:

> i had to change the bytes field from [*]align(@alignOf(T)) u8 to just [*]u8 (and cast the alignment back in the like one place that field is accessed). this wasn't necessary for MultiArrayList in and of itself, but it was necessary for embedding a MultiArrayList(T) inside of T without a dependency loop, like

    const T = struct {
        children: MultiArrayList(T),
    };
    // reproduced for completeness:
    fn MultiArrayList(comptime T: type) type {
        return struct {
            bytes: [*]align(@alignOf(T)) u8,
            // ...
        };
    }
[0]: https://zsf.zulipchat.com/#narrow/channel/454360-compiler/to...

Re: Type resolution redesign, with language changes to taste

#212

Earlier quoted context omitted.

I maintain a ~250K LoC Zig compiler code base [0]. We've been through several breaking Zig releases (although the code base was much smaller for most of that time; Writergate is the main one we've had to deal with since the code base crossed the 100K LoC mark). The language and stdlib changing hasn't been a major pain point in at least a year or two. There was some upgrade a couple of years ago that took us awhile to…

Are you aware that your Github README doesn't actually tell us anything about Roc is or why we might be interested? This might be on purpose given the first words are "Work in progress" and "not ready for release", but linking as above does lose some value.

Instead of being rude, consider checking Roc's website: https://roc-lang.org/

He wasn't pitching the language directly, but linking to the codebase as that was what was relevant to the comment he was replying to.

Re: Type resolution redesign, with language changes to taste

#213
post #110
post #72

Earlier quoted context omitted.

Two different philosophical approaches with Zig and Rust. - Zig: Let's have a simple language with as few footguns as possible and make good code easy to write. However we value explicitness and allow the developer to do anything they need to do. C interoperability is a primary feature that is always available. We have run time checks for as many areas of undetermined behaviour as we can. - Rust: let's make the compi…

> However we value explicitness and allow the developer to do anything they need to do* * except for having unused variables. Those are so dangerous the compiler will refuse the code every time.

don't know if it's still on the table, but Andrew has hinted that the unused variables error may in the future still produce an executable artefact but return an nonzero return code for the compiler. And truly fatal errors would STILL produce an executable artefact too, just one that prints "sorry this compilation had a fatal error" to stdout.

Re: Type resolution redesign, with language changes to taste

#214
post #175
post #148

Earlier quoted context omitted.

> Plenty of OOP architectures can be implemented 1:1 Plenty of OOP architecture can be implemented in C. That's an extremely flawed and fuzzy definition. But we've been through this before.

Yet people have to keep be reminded of it.

I think the issue is OOP patterns are one part missing features, one part trying to find common ground for Java, Modula, C++, SmallTalk, that it ends up too broad.

A much saner definition is looking at how languages evolved and how term is used. The way it's used is to describe an inheritance based language. Basically C++ and the descendants.

Re: Type resolution redesign, with language changes to taste

#215
post #210

What makes zig special as a language? I have the impression that it has quite a large fan base here on HN but don't really hear any talks about it anywhere else.

I can share mine. I am not sure if this connects with you because maybe you are more experienced. I'm DevOps writing boring Python microservices for €. I have no CS background and never did systems programming. However, writing Python always bothered me because there are so many layers between you and what's happening on the metal. For me, Django is the peak example of this, to me it feels almost like doing no code.…

I'm sure it's not what you meant, but the argument "it makes me slower at my job and deliver less stable solutions, but I feel cool doing it" is not exactly a compelling endorsement.

Re: Type resolution redesign, with language changes to taste

#216
post #212

Earlier quoted context omitted.

Are you aware that your Github README doesn't actually tell us anything about Roc is or why we might be interested? This might be on purpose given the first words are "Work in progress" and "not ready for release", but linking as above does lose some value.

Instead of being rude, consider checking Roc's website: https://roc-lang.org/ He wasn't pitching the language directly, but linking to the codebase as that was what was relevant to the comment he was replying to.

If I missed with tone, that's on me. I was going for "helpful constructive feedback".

Re: Type resolution redesign, with language changes to taste

#217
post #62

Earlier quoted context omitted.

Zig is a modern C, Rust is a modern C++/OCaml So if you enjoy C++, Rust is for you. If you enjoy C and wish it was more verbose and more modern, try Zig.

Seriously asking, where Go sits in this categorization?

Go is a language which sits perfectly where using garbage collection is no problem with ya.

Re: Type resolution redesign, with language changes to taste

#218
post #73

Earlier quoted context omitted.

I can think a few reasons: - Cranelift applies less optimizations in exchange for faster compilation times, because it was developed to compile WASM (wasmtime), but turns out that is good enough for Rust debug builds. - Cranelift does not support the wide range of platforms (AFAIK just X86_64 and some ARM targets)

So it isn't just a matter of "they would use Rust instead". There is a whole ecosystem of contributions across the globe and the lingua franca used by those contributors.

> There is a whole ecosystem of contributions across the globe and the lingua franca used by those contributors.

which is slowly changing with wider rust adaptation.

Re: Type resolution redesign, with language changes to taste

#219
post #214
post #175

Earlier quoted context omitted.

Yet people have to keep be reminded of it.

I think the issue is OOP patterns are one part missing features, one part trying to find common ground for Java, Modula, C++, SmallTalk, that it ends up too broad. A much saner definition is looking at how languages evolved and how term is used. The way it's used is to describe an inheritance based language. Basically C++ and the descendants.

> one part trying to find common ground for Java, Modula, C++

The primary common ground is that their functions have encapsulation, which is what separates it from functions without encapsulation (i.e. imperative programming). This already has a name: Functional programming.

The issue is that functional, immutable programming language proponents don't like to admit that immutability is not on the same plane as imperative/functional/object-oriented programming. Of course, imperative, functional, and object-oriented language can all be either mutable or immutable, but that seems to evade some.

> SmallTalk

Smalltalk is different. It doesn't use function calling. It uses message passing. This is what object-oriented was originally intended to reference — it not being functional or imperative. In other words, "object-oriented" was coined for Smalltalk, and Smalltalk alone, because of its unique approach — something that really only Objective-C and Ruby have since adopted in a similar way. If you go back and read the original "object-oriented" definition, you'll soon notice it is basically just a Smalltalk laundry list.

> how term is used.

Language evolves, certainly. It is fine for "object-oriented" to mean something else today. The only trouble is that it's not clear to many what to call what was originally known as "object-oriented", etc. That's how we end up in this "no its this", "no its that" nonsense. So, the only question is: What can we agree to call these things that seemly have no name?

Re: Type resolution redesign, with language changes to taste

#220
post #157

Earlier quoted context omitted.

If I comment out sections of code while debugging or iterating I don't want a compile error for some unused variable or argument. Warning. fine, but this happens to me so frequently that the idea of unused variables being an error is insane to me.

It is insane and you are completely right. This has been a part of programming for over 50 years. Unfortunately you aren't going to get anywhere with zig zealots, they just get mad when confronted with things like this that have no justification, but they don't want to admit it's a mistake.

But even the solutions would be so trivial - have a separate 'prod' compiler flag. With that, make these errors, without make these warnings.

Problem solved, everyone happy.

Post reply on HN