Giter VIP home page Giter VIP logo

www.ziglang.org's People

Contributors

alichraghi avatar andrewrk avatar atomk avatar booniepepper avatar bratishkaerik avatar c-bj avatar chrboesch avatar codehz avatar daurnimator avatar der-teufel-programming avatar edoardottt avatar jayschwa avatar jdeokkim avatar jdmichaud avatar jedisct1 avatar jfo avatar kristoff-it avatar kubkon avatar marler8997 avatar meppu avatar mikdusan avatar mlugg avatar mochalins avatar n4x2 avatar nektro avatar rudedogg avatar tau-dev avatar tiehuis avatar truemedian avatar yvt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

www.ziglang.org's Issues

I searched for standard library function documentation in the docs and didn't find it

I am totally new to zig and read your document on the language and found it helpful. It enabled me to make a start on learning the language. However I could not find any documentation on the functions in the zig standard library. I realise that I can read the code but when you have just read the language manual today, expecting one to read the code is a little bit much. Can somebody please work on providing some links to the main language reference manual to documentation on the entire standard library ? This would be enormously helpful and I think it would also help more people get interested in learning the language. I have just downloaded and installed version 0.3 of the zig language.

Call for Code Samples

There are two places in the current redesign of the website where we want to show snippets of code that give an idea to the user of how it's like to program in Zig.

One of those places is Learn/Code Examples, while the other is the front page where we have a somewhat strict limit in terms of lines and columns of code. Those limits can be slightly bent, but the general problem of finding a meaningful and succinct example remains.

Please share a few code examples that you think would be nice and for each also provide a couple of lines that describe what the code is showing (e.g. "A simple generic singly-linked list implementation").

If you want to submit a sample for the front page, please stay under 30 lines and 50 columns. Also please make it relevant to the arguments present on the frontpage about simplicity, comptime and performance+safety.

Also see #78 for more discussion on the website redesign.

Tiny logo

Inspired by https://github.com/edent/SuperTinyIcons, I made a hand-written SVG of the Zig logo that is ~600 bytes. This should make it suitable for embedding in the language reference documentation, etc. Using an SVG optimizer, pushes it down to ~500 bytes, but it's not easy to tweak in that form. For comparison, the current logo is ~3.8 KB.

While it's not a pixel-perfect recreation of the original logo, it is intended to look the same at a cursory glance. Changes:

  • Omitted text since it can be replaced with markup.
  • Slightly reduced the aspect ratio to 3:2.

If there is interest in using this logo, I will start a PR that incorporates it into the website and documentation.


Current logo (rasterized):
image

Tiny logo (rasterized):
image

SVG source: https://gist.github.com/jayschwa/1ef7b11ae2e82e78d3ac434140113a2d

Move index on pages to the side for easier navigation

Consider moving the "index" sections on your website to the side.

  • This prevents users from having to scroll down to get to some content, or back up again to look at the index.
  • It's 2019 and most users have a monitor with a width of more than 1024 pixels, so maybe make some more use of that horizontal screen real estate.
  • Other language docs like Rust also have their index/navigation moved to the side.

Sync existing translations with changes to learn/why-zig...

Of course, of all the pages of the website, the old article about Zig vs other language is the one that got to the front page of hacker news. And like one day after merging the first round of translations.

HN link: https://news.ycombinator.com/item?id=25797025

This made Andrew fix the page on the fly but now the existing tranlsations are out of sync. This is a diff of the changes:

7977181...25d9cd6

Pinging @codehz and @kassane. Sorry to ask again this early, but would you mind reflecting those changes in your translations?

Thanks!

I searched for formatted output to stdout in the docs and didn't find it

I'm trying to do some very simple formatted output to stdout.

The equivalent in C of what I'm trying to do is:

int n = 42;
printf("n = %d\n", n);

I know from the examples that I can do:

var n: i32 = 42;
std.debug.warn("n = {}\n", n);

but that writes to stderr, not to stdout. Or I can do (after some setup):

stdout_file.write("Hello, world!\n");

but that doesn't permit formatting.

I've been looking over the documentation (which says "Usually you don't want to write to stdout. You want to write to stderr.") and the runtime library sources. I could probably copy-and-paste the implementation of warn from the standard library and hack it to write to stdout rather than stderr, but that's not a satisfying solution.

hello.zig -> fail :-(

i just copied the hello world example,
i got the error:

zig build-exe hello.zig
./hello.zig:4:14: error: container 'std.debug' has no member called 'print'
std.debug.print("Hello, world!\n", .{});
^

Website redesign feedback

I've been working for the last few weeks on a redesign of the website. I haven't changed the general graphical theme, but I've expanded the number of pages and restructured the front page drastically.

The work is being done in the hugo-redesign branch and unfortunately at the moment is a bit hard to get it working on your machine as it depends on the docgen tool. I'm working on a simplified version of it, but it's not ready yet. In the meantime you can preview the website here: http://ziglang.github.io/www.ziglang.org/

The main (but not sole) goal of this redesign is to make the site more accessible for the average developer who might not appreciate the in-depth overview of Zig that's currently present on the front page.

For this reason the in-depth overview has been moved inside the learning section, while the frontpage acts as a more general introduction to the Zig project as a whole, starting from the language itself, to the community and the Zig Software Foundation.

The main type of feedback I'm looking for at the moment is about the copy (i.e. the text), especially when it's small fixes that improve the wording or in general provide a more effective way of expressing what the text was trying to say in the first place. If you think something needs big changes, please provide adequate explanations and consider the impact on the surrounding text. For example, changing the "Performance and Safety" point with something else, will probably require to rethink the other two points as well.

Please try to keep the discussion focused on actionable points, if you want to have a general discussion and / or ask questions about what I'm trying to achieve with the website, please do so on Reddit: https://old.reddit.com/r/Zig/comments/jtjmq5/ziglangorg_redesign/

Struct example typo?

In the struct example:

fn setYBasedOnX(x: *f32, y: f32) void {
    const point = @fieldParentPtr(Point, "x", x);
    point.y = y;
}

is it supposed to be point.y = x;?

Add support for RSS

I've been looking for the RSS feed of zig updates for quite some time now and I cannot seem to find it. Subscribing to RSS for me is way more convenient than fetching the json file as it integrates better with aggregators. I therefore propose to:

  • add a file complying with the RSS protocol to the website
  • add changelog to said feed

Documentation is deprecated for options of compliler optimizations

Zig version: 0.6.0+53c63bdb7 on Linux 5.8.14-arch1-1

https://ziglang.org/documentation/master/#ReleaseFast

Looks like --release-fast --release-safe --release-small were options in the past, but now they are replaced with -O [mode] where [mode] is Debug | ReleaseFast | ReleaseSafe | ReleaseSmall. Although I haven't found since which version they were replaced (if they were).

$ zig test --help
  ...
  -O [mode]                 Choose what to optimize for
    Debug                   (default) Optimizations off, safety on
    ReleaseFast             Optimizations on, safety off
    ReleaseSafe             Optimizations on, safety on
    ReleaseSmall            Optimize for small binary, safety off
  ...

Example:
zig test main-testing.zig --release-fast returns error: unrecognized parameter: '--release-fast'
zig test main-testing.zig -O ReleaseFast seems to work as intended.

I searched for the standard library in the docs and didn't find it

There is currently nothing about the standard library in the docs. Even though this might be a moving target, it would be helpful to have at least a list of different modules and what functionality they cover + an overview of very common library functions (the available allocators, string functions, IO) just so you can get up and running writing a test program to feel the language out without reading through the library files. Bonus points for having the entire standard library docs automatically generated from the source code.

Caveat about Tier 1 and libc

It is a touted advantage of Zig that its stdlib "integrates with libc but does not depend on it." In the overview page on the section about the tier system, it is mentioned that:

Thus it is practical to write a pure Zig application with no dependency on libc.

However, this is only possible on Linux, because it is the only OS that provides a stable ABI guarantee such that Zig could implement syscalls without linking to libc. But macOS/x86_64 is listed as a Tier 1 target, even though Zig must link to libc to make syscalls on that platform, as is necessary for other BSDs as well.

I searched for generic function in the docs and didn't find it

There are a few clues to how it would be done, such as the declarations of built in functions. However, there isn't a good description of how this should be done like there is for generic data structures, and some of the semantics are unclear. In particular:

  • What is the var type, and what are its semantics? (it is in many declarations, but I can't find any documentation about it)
  • Does zig use duck typing? Or do I need to specify constraints somehow to use operators or members of a type
  • Are there any best practices for defining generic functions?
  • Can you define generic functions the same way you do with structs, by returning an anonymous function pointer?
  • Can you use a function (ex. @typeof) to compute the return type or parameter type of a function?

Caveat comment about Tier 1 support and libc

It is touted advantage of Zig that it "integrate with libc but does not depend on it." In the overview page on the section about the tier system, it is mentioned that:

Thus it is practical to write a pure Zig application with no dependency on libc.

However, this is only possible on Linux, because it is the only OS that provides a stable ABI guarantee such that Zig could implement syscalls without linking to libc. But macOS/x86_64 is listed as a Tier 1 target, even though Zig must link to libc to make syscalls on that platform.

Not mentioned in docs: `else => |x|` in switch

This feature seems to exist but it's not mentioned in the docs.

else supports a capture group which probably just returns the value that was in the switch(...). parentheses.

const std = @import("std");
pub fn main() void {
    var b: i32 = 5;
    switch (b) {
        else => |x| std.debug.warn("{}\n", .{x}), // prints 5
    }
}

Somes examples could be made clearer

I found that some examples were confusing. I'll explain why it's not clear and I'll suggest a solution at the end.

Error handling

https://github.com/ziglang/www.ziglang.org/blob/master/www/index.html#L725

This example is supposed to show that 'The switch keyword used on an error ensures that all
possible errors are handled
'. Yet the output is an error: ... not handled. For someone not familiar with Zig, this is only marginally different from error discarded that is shown above. And the errors are literally not handled in this example which contradicts the sentence above.
It is also surprising to see an example on the official website that is not compiling.

Compile-time code execution

https://github.com/ziglang/www.ziglang.org/blob/master/www/index.html#L975

Because the example use zig test that compiles and executes the program immediately, the fact that the assert is executed at compile time is not made clear enough. The reader is supposed to either :

  • make the difference between a compiler error and a stack trace (They look very similar.)
  • or notice that the usual text displayed by the test harness is not present.

Suggestion

In these 2 examples, a sentence explaining why these errors were expected and what it is showing could be added. As I said a compiler error is not what is expected when running official examples.
Maybe these are obvious for programmers used to low-level, compiled languages (which I am not) but I think the introduction to a language should aim to be as easily understandable as possible.

Fix responsiveness

The website does not scale properly on mobile devices. The HTML viewport meta tag should be used to set the viewport's width to the width of the device's screen and to set the correct initial zoom level when pages load:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Before adding the meta tag:

https://user-images.githubusercontent.com/33205782/77707044-4e878980-6fc4-11ea-94ae-dc2226f98bf3.jpg
https://user-images.githubusercontent.com/33205782/77707052-52b3a700-6fc4-11ea-9ea7-0ce77606d691.jpg

After adding the meta tag:

https://user-images.githubusercontent.com/33205782/77707031-4891a880-6fc4-11ea-9e23-f25cd0813446.jpg
https://user-images.githubusercontent.com/33205782/77707036-4b8c9900-6fc4-11ea-9bad-d1d6e07684da.jpg

However, with the current CSS, tables that are too broad are not clipped to fit into their padding box:

https://user-images.githubusercontent.com/33205782/77707042-4d565c80-6fc4-11ea-8d81-db73bde6917e.jpg

The following CSS code fixes this problem:

table {
    display: block;
    overflow: auto;
}

When a table overflows, it will be clipped to fit into its padding box and it will become scrollable:

https://user-images.githubusercontent.com/33205782/77707027-462f4e80-6fc4-11ea-951c-7acb9284ea14.jpg

hello world doesn't compile

The very first example does not compile, kind of. The problem is google takes you to the master doc while you have to use the one corresponding to the version installed (ziglang.org/documentation/0.5.0/ in my case).
I think that first semi-advanced Hello World with stdout manipulations should be removed completely - at this point the person reading it just wants to print "Hello, world!" in as little code as possible, and getting "error: type 'std.os.windows.GetStdHandleError!std.fs.file.File' does not support field access" on Hello World is not exactly reassuring

Make site more welcoming to newcomers

Currently, the website is rather unwelcoming to newcomers. When you land on the homepage, there are no code examples that could demonstrate Zig's capabilities, and beginner-friendly resources other than the official documentation are sparse and not directly linked on the website.

Nim's homepage and Go's homepage come to mind as examples that could be used to improve Zig's homepage.

Go as wrong example of languages with exceptions

As a Go user who is interested in Zig, I came across this sentence on the homepage:

C++, D, and Go have throw/catch exceptions, so foo() might throw an exception, and prevent bar() from being called.

Go does not have exceptions. Quote from their blog:

The language's design and conventions encourage you to explicitly check for errors where they occur (as distinct from the convention in other languages of throwing exceptions and sometimes catching them).

Thus, I would suggest to remove Go from the list of examples.
✌️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.