-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hello world to samples page #397
base: main
Are you sure you want to change the base?
Conversation
For the other language pages, is it best to leave this off those pages until someone translates it? Or should I add it to the other pages without text? How does the translation process work with this repo? |
Previously, the index page displayed a "Hello World". Personally, I like the current example better. And for a 'Hello World', we might consider whether the debug version or a release version would be more appropriate: const std = @import("std");
const stdout = std.io.getStdOut();
pub fn main() !void {
try stdout.writeAll("Hello, World!\n");
} |
I see that you renamed all sample files to keep the order, if maintainers are ok with it I would remove that prefix since these files are not order-sensitive,. Having to keep the order of the filesin sync with the order in the page feels like an unnecessary complication. |
+1. Initially I just added hello world as number 6 and put it at the beginning so they were out of order, but I wasn't sure if the numbering was important. I'll remove the numbers, sounds good to me. |
I've updated the example to use stdout, but chose to use print, since it allows printing values in the text. |
You could do that, but why if you don't have a variable to print? try stdout.print("Hello World!\n", .{}); |
I think using the For e.g. in Go hello worlds you'll often see For e.g. in Rust hello worlds you'll often see |
I completely understand what you mean. While the old "Hello World" example is well-known, it often results in new visitors just taking a quick look and thinking, 'Wow, that looks complicated,' without really grasping the philosophy behind it. However, it’s crucial to understand Zig’s philosophy in order to appreciate the example fully — especially when it comes to the print case, where it’s essential to include even empty parameters. That's why I personally find the current example much better. It really showcases Zig's elegance and encourages curious visitors to explore a bit deeper. |
👍🏻. If folks are happy with the current example, can we merge this PR, or anything that should be tweaked, etc? |
What
Add a hello world example to the samples page.
Why
The learn samples showcase some advanced features and concerns like memory leaks, but as a someone who is new to Zig the first thing I need to see is hello world. i.e. The minimal application that runs and gives me some sense of where the entry point is and how to log so I can debug using some basic principles.
I think it would be helpful to new folks to add a hello world example to the samples page.
Close #117