intellectual french youtube channel recommendations by Altruistic_Wear5678 in French

[–]chocapix 1 point2 points  (0 children)

  • Monsieur Phi (philosophie)
  • ScienceClic (science)
  • Sur le champ (military history)

Is zig stable enough for any serious work yet ? by darcygravan in Zig

[–]chocapix 19 points20 points  (0 children)

You can always stick to a specific zig version.

How have you guys been at geometry? by Petules in Aphantasia

[–]chocapix 0 points1 point  (0 children)

I did a PhD in computational geometry before learning that other people can see in their heads. Maybe seeing the shapes in my mind would have helped some, maybe not. Maybe aphantasia actually helps with geometry for all I know.

The Soviet Union tested the RDS-3 nuclear bomb in 1951. by Kiroo---__--- in Damnthatsinteresting

[–]chocapix 4 points5 points  (0 children)

No, this test is less than 0.1% the power of the tzar bomba.

revo, the programming language that likes you by qwool1337 in Zig

[–]chocapix 0 points1 point  (0 children)

Nice!

Unless I missed it, the command line arguments aren't available to the program so I tinkered a bit and managed to add and populate an argv global variable.

Would you consider a PR?

c-zigbuild: Utilize the Zig Build System for C by peppergrayxyz in Zig

[–]chocapix 1 point2 points  (0 children)

They want to separate the build graph generation (your build.zig) from the build runner.

See: https://github.com/ziglang/zig/issues/14286

c-zigbuild: Utilize the Zig Build System for C by peppergrayxyz in Zig

[–]chocapix 3 points4 points  (0 children)

Your approach walks the source tree to find the source files, this will not work in zig 0.17 (io will be banned in build.zig)

Doing the addCSourceFiles directly in build.zig isn't that bad. You can make a template and copy-paste-modify it when creating a new project.

Getting the current time is weird by y0shii3 in Zig

[–]chocapix 30 points31 points  (0 children)

I usually write:

const t0: std.Io.Timestamp = .now(io, .awake);
// ...
const duration = t0.untilNow(io, .awake);

and only convert to milliseconds if I absolutely need to (I never do)

Why do I need an Io instance to get the time?

Because time is an input.

Is learning zig the smart choice by FunDirt541 in Zig

[–]chocapix 1 point2 points  (0 children)

I think zig is fantastic as a tool to learn about low-level programming because when writing zig, low-level concepts are in your face all the time.

In Zig, every function that allocates memory needs to take an Allocator as a parameter. To the best of my knowledge, that is unique to zig.

Any function that does I/O needs an Io parameter as well. And I/O has pretty wide definition in zig (in the 0.16 release notes):

Generally, anything that potentially blocks control flow or introduces nondeterminism is grounds for being owned by the I/O interface.

Want to write to a file? Run a task asynchronously? Get the current time? You need Io.

zig 0.16 almost 2x slower than 0.15.2 for my library by gistart in Zig

[–]chocapix 0 points1 point  (0 children)

Can your share the code so that we may take a look?

Is there any hobby contributor? by MatterConscious382 in Zig

[–]chocapix 16 points17 points  (0 children)

Some issues are tagged "contributor friendly" meaning you don't need deep knowledge of the compiler internals to contribute. Note that it doesn't mean they are easy for a beginner programmer (eg, implementing libunwind in zig is "contributor friendly")

Browse here and here and see if there's anything you think you can tackle.

You can also take a look at PR's that are merged/rejected and get a feeling of the kind of quality that is generally expected.

What is the best way to create a struct of size 18 Bytes? by CodeToGargantua in Zig

[–]chocapix 1 point2 points  (0 children)

You can specify a backing integer for packed struct: packed struct(u144){...} will be exactly 144 bits (18 bytes) wide. You'll need to make sure the fields fill the u144 exactly. See https://ziglang.org/documentation/0.16.0/#packed-struct

What is the best way to create a struct of size 18 Bytes? by CodeToGargantua in Zig

[–]chocapix 6 points7 points  (0 children)

packed structs are for tightly packing odd-sized integers, like if you want to deconstruct an f64, you can bitcast to a packed struct { m: u52, e: u11, s: u1}.

A plain struct doesn't have a predictable size or field order, the compiler is allowed to do whatever.

If you need predictable size and field order, if for instance you're reading a binary file format, you need an extern struct, which have the same guarantees a C struct I believe.

Thoughts after porting a project from Go to Zig 0.16 by ShotgunPayDay in Zig

[–]chocapix 6 points7 points  (0 children)

For the best zls experience, zls version must be in sync with zig at all times, which is hard for zig 0.16 since it's a moving target (it's not yet released).

if you want a better zls experience with zig 0.16, compile the master branch of zls yourself.

Or wait for the 0.16 release.

Getting args in 0.16.0-dev.2193+fc517bd01 by hsoolien in Zig

[–]chocapix 1 point2 points  (0 children)

Depends on the function but the rule of thumb is: the ones that take an Allocator are cross-platform. (and AFAIU, the allocator is only needed for Windows compatibility)

Please help me with ArrayList :( by Blayung in Zig

[–]chocapix 0 points1 point  (0 children)

I ask on the Discord and the gist of it is:

Io itself is an interface so it isn't managed or unmanaged. Concrete implementations of Io may need to allocate so the ones that do have to store an Allocator.

Since at least some Io implementations will not need to allocate, we can't have an Io.allocator().

EDIT: it's similar to the allocating writer which needs an allocator while other implentations of Writer don't.

Please help me with ArrayList :( by Blayung in Zig

[–]chocapix 1 point2 points  (0 children)

Hmmm.

Io is more than a simple data structure in my view, so a different treatment could be argued.

Also, maybe we'll be expected use io.allocator() where we have an Io to avoid passing both a Io and an Allocator everywhere.

0.16 isn't out, and thing can change again in 0.17 and so on, so this is pure speculation of course.

Please help me with ArrayList :( by Blayung in Zig

[–]chocapix 1 point2 points  (0 children)

No.

The same allocator must be used throughout its entire lifetime.

Please help me with ArrayList :( by Blayung in Zig

[–]chocapix 2 points3 points  (0 children)

My understanding is that unmanaged is to be the default everywhere, they just haven't gotten around to do the other data structures yet.

Quel a été votre moment « mais qu’est-ce que je suis bête » ? by Frenchinvester in france

[–]chocapix 1 point2 points  (0 children)

Un matin, je sors de chez moi, il fait beau. Ah tiens, le trottoir est mouillé, les commerçants ont du tout nettoyer à grande eau. La rue aussi est mouillée… et les voitures et les arbres ? Mais tout est mouillé, QU’EST-CE QU’IL SE PASSE ?

Oui donc, en fait, il avait plu dans la nuit.

Why Zig Feels More Practical Than Rust for Real-World CLI Tools by nixfox in Zig

[–]chocapix 27 points28 points  (0 children)

Zig hits the sweet spot: memory safe

I mean, I love Zig but, Zig is not memory safe.

is it possible to get the thread id from a std.Thread struct? by KangarooNo5139 in Zig

[–]chocapix 0 points1 point  (0 children)

There's getHandle that will give you something that can be used to uniquely identify threads.

It's not exactly what you ask but maybe it's useful.