3 ms·
[Off-topic] Another programming language website with no code examples front/center on the homepage? When you click "Download & Documentation" there's a link u
by dmix 8y ago
[Off-topic] Another programming language website with no code examples front/center on the homepage?
When you click "Download & Documentation" there's a link under the headline "master" to the long-form documentation which has some examples: https://ziglang.org/documentation/master/ https://ziglang.org/documentation/master/
Edit: also found a blog post with a nice introduction: https://andrewkelley.me/post/intro-to-zig.html https://andrewkelley.me/post/intro-to-zig.html and an examples directory: https://github.com/ziglang/zig/tree/master/example https://github.com/ziglang/zig/tree/master/example
Interesting to see how the language has evolved away from using "%" in the original Hello world:
const std = @import("std");
pub fn main(args: [][]u8) -> %void {
// Print "Hello World!", and believe that no errors will happen
std.io.stdout.printf("Hello World!\n") %% unreachable{};
// Short version:
%%std.io.stdout.printf("Hi!\n");
}
Compared to the newer version :
const std = @import("std");
pub fn main() !void {
// If this program is run without stdout attached, exit with an error.
const stdout_file = try std.io.getStdOut();
// If this program encounters pipe failure when printing to stdout, exit
// with an error.
try stdout_file.write("Hello, world!\n");
}
- daurnimator 8y agoLooks like someone just filed the lack of samples as an issue: https://github.com/ziglang/zig/issues/2218 https://github.com/ziglang/zig/issues/2218
- manaskarekar 8y agoMy favorite website for an example of this functionality is: https://dlang.org/ https://dlang.org/. Succinct examples on a clean page, no fluff.
- Thaxll 8y agoYes, the homepage for Go is similar https://golang.org/ https://golang.org/