logoalt Hacker News

brabellast Monday at 6:53 AM1 replyview on HN

Yes, but how is that equivalent?

Zig:

    const std = @import("std");
    pub fn main() !void {
      // std is like a namespace here
      std.debug.print("Hello, World!\n", .{});
    }
D:

    import std.stdio;
    void main()
    {
      // no namespace here, "writeln" and everything else in "std.stdio" is imported
      writeln("Hello, World!");
    }
The closest to Zig in D would be:

    import io = std.stdio;
    void main()
    {
      io.writeln("Hello, World!");
    }

Replies

WalterBrightlast Monday at 7:24 AM

You can write in D:

    std.stdio.writeln("Hello, world!");