blob: 96531813db4e08943b13ddd29f7f1a50e744582a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
* Chapter 1
** 1.2.1
- Built in build tool is nice
- I have mixed feelings about the build tool taking in a build
script, rather than using a toml/json/etc config file.
** 1.2.2
- Really like ~test~ as a keyword rather than a module. [[file:hello_world/src/main.zig::test "simple test" {][example]]
** 1.2.3
- Using a bang to indicate a possible exception is interesting. Not
sure if I love it, will need to play with it, but it's certainly
terse. [[file:hello_world/src/main.zig::fn testOne(context: void, smith: *std.testing.Smith) !void {][example]]
- It is kinda neat that you can ~try~ without a follow up catch.
** 1.2.4
- Feels like a lot of commands to get a test. Gonna miss ~cargo run~.
** 1.3
- No thanks
#+begin_quote
I personally think that, the best way of reading Zig code is to read
the source code of the Zig Standard Library.
#+end_quote
- zig.news being down is weird, wonder what happened there?
** 1.4
- Don't like that ~var~ is mutable by default. Really do prefer
default immutability.
- Yeah I know I can ~const~, but it's the principle.
** 1.4.4
- "you *must* mutate" feels like such a weird rule.
** 1.4.6
- Gonna be hard to go back to manually defining the size of
arrays. ~[_]~ here I come.
** 1.7
- Labeled blocks are cool
** 1.8
- Woah, is that really what you have to do to write to ~stdout~?
#+begin_src zig
const std = @import("std");
pub fn main(init: std.process.Init) !void {
var stdout_buffer: [1024]u8 = undefined;
var stdout_writer = std.Io.File.stdout().writer(init.io, &stdout_buffer);
const stdout = &stdout_writer.interface;
const string_object = "This is an example of string literal in Zig";
try stdout.print("{d}\n", .{string_object.len});
try stdout.flush();
}
#+end_src
- Sentinel terminated arrays sound so academic. Given all the
criticisms of how hard and complicated Rust is, with Zig as a
frequent alternative, I am surprised to see how academic this feels.
- Have feelings about the choice to use the word "America" as the katakana example:
#+begin_quote
In the example below, we loop through the japanese characters “アメリカ”.
#+end_quote
- Feel like it's strange to put the string library functions into the
memory std lib... but I assume that's because they're not actually
string specific?
|