• onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    7
    arrow-down
    1
    ·
    5 hours ago

    Of course compiling something without checks is safe. If that’s your standard, we should write the kernel in JS, Python, Ruby, LUA or any other dynamically typed language since there’s no compilation time.

    Progress means I don’t have to read blog posts in order to compile the kernel. Progress means I have a sane toolchain that lets me run, test, debug, manage dependencies, and even distribute my code and artefacts (documentation, compile output, …) easily. Progress means catching many more bugs at compile-time instead of runtime.

    Anti Commercial-AI license

    • You’re throwing the baby out with the bath water with the reductio ad absurdum argument. Rust may very well be less secure than Ada - if so, then does that make it not good enough?

      I say it’s not worth trading some improvement in safety for vastly longer compile times and a more cognitively complex - harder - language, which increases the barrier of entry for contributors. If the trade were more safety than C, even if not as good as Rust, but improved compile times and a reasonable comprehensibility for non-experts in the language, that’s a reasonable trade.

      I have never written a line of code in Zig, but I can read it and derive a pretty good idea of what the syntax means without a lot of effort. The same cannot be said for Rust.

      I guess it doesn’t matter, because apparently software developers will all be replaced by AI pretty soon.

      • onlinepersona@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 hours ago

        I have never written a line of code in Zig, but I can read it and derive a pretty good idea of what the syntax means without a lot of effort. The same cannot be said for Rust.

        That’s you dawg. You probably have a different background, because I can follow zig code, but have no idea what a bunch of stuff means.

        See samples

        pub fn enqueue(this: *This, value: Child) !void {
                    const node = try this.gpa.create(Node);
                    node.* = .{ .data = value, .next = null };
                    if (this.end) |end| end.next = node //
                    else this.start = node;
                    this.end = node;
                }
        

        pub fn enqueue(this: *This, value: Child) !void { , !void? It’s important to return void? Watch out void is being returned? Does that mean that you can write !Child ? And what would that even mean?

        const node = try this.gpa.create(Node); what does try mean there? There’s no catch, no except. Does that mean it just kills the stack and throws the exception until it reaches a catch/except? If not, why put a try there? Is that an indication that it it can throw?

        node.* = .{ .data = value, .next = null }; excuse me what? Replace the contents of the node object with a new dict/map that has the keys .data and .next?

        if (this.end) |end| end.next = node // what’s the lambda for? And what’s the // for ? A forgotten comment or an operator? If it’s to escape newline, why isn’t it a backslash like in other languages?

        start: ?*Node. Question pointer? A nullable pointer? But aren’t all pointers nullable? Or does zig make a distinction between zero pointers and nullable pointers?

        pub fn dequeue(this: *This) ?Child {
                    const start = this.start orelse return null;
                    defer this.gpa.destroy(start);
        

        this.start orelse return null is this a check for null or a check for 0 or both?

        However when I read rust the first time, I had quite a good idea of what was going on. Pattern matching and move were new, but traits were quite understandable coming from Java with interfaces. So yeah, mileage varies wildly and just because you can read Zig, doesn’t mean the next person can.


        Regardless, it’s not like either of us have any pull in the kernel (and probably never will). I fear for the day we let AI start writing kernel code…

        Anti Commercial-AI license

      • N.E.P.T.R@lemmy.blahaj.zone
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 hours ago

        Zig is designed as a successor to C, no? So i assume it does syntax and things quite similarly. Rust is not a C-like language, so i dont think this a fair comparison at all.

        But in the end, learning syntax isnt the hard part of a new language (even if it is annoying sometimes).