3 ms·
Zig lets you be very explicit about what you want. Zig's hello world takes 3 or 4 lines where other languages take 1. That is how much other languages make deci
by hiccuphippo 1mo ago
Zig lets you be very explicit about what you want. Zig's hello world takes 3 or 4 lines where other languages take 1. That is how much other languages make decisions for you. Some people care to make those decisions themselves.
- applfanboysbgon 1mo agoThis is the weirdest basis for comparing a language I've ever seen. Zig is one line as well, `std.debug.print("Hello, world!\n", .{});`, unless you're counting defining main and its brackets as 4 lines, in which case... Rust has that too, Java is 7 lines and C# is 8 lines to import System library and define the Program class as well if you're not using top-level statements / implicit usings. --- Edit for replies complaining I used debug.print: Okay, `try std.io.getStdOut().writer().print("Hello, world!\n", .{});`. Still one line, more explicit with chained methods, but that still just goes to show you how arbitrary this metric is -- Zig's standard library makes you be more explicit with one function, but it doesn't make you be as explicit with another one that works essentially the same way but writes to a different stream, ergo this has nothing to do with the language's inherent explicitness but rather comparing the implementation of a single random function.
- solatic 1mo agostd.debug.print is, as its name suggests, for debug output, not for program output. In Zig, you create a buffered writer for the stdout file handle, write hello world to the buffer, and then flush it. It exposes what's actually happening underneath.
- denismenace 1mo agoAs the name suggest `std.debug.print` is a short hand for debug printing. In a CLI app for example you should use IO.
- ErenayDev 1mo ago(reply to edit) small typo fix: instead of `std.io`, it should be `init.io`. `init` is first parameter in `main` function.
- zuzululu 1mo agoAs does C++ and other languages. What is so special about Zig that you cannot use LLMs with it? Please provide examples.
- caspper69 1mo agoThe breaking changes version to version. Zig tends to be quite liberal about moving forward, as should be expected at its version level. It simply outpaces the llms datasets.