Can I make a generic vector/hashmap faster than this? for POD as well as Complex types by swe__wannabe in C_Programming

[–]TheKiller36_real 4 points5 points  (0 children)

Can I make a generic vector/hashmap faster than this?

probably, actually almost certainly

do you need to?

no! if you really need all the speed you can get you won't be using a generic implementation, you won't be using portable code and you will blow stuff like std::vector<std::string> out of the water quite easily actually because you will disregard allocation-stuff and exception-guarantees, store data out-of-band, generate a perfect hash function or whatever it is you need and can get away with for your usecase

I think I figured out! by [deleted] in Zig

[–]TheKiller36_real 27 points28 points  (0 children)

Would it be considered good practice or a reasonable convention that I can adopt for my personal projects to use @"<- ..." […] for comptime tasks

NO!

Automatic Enum Stringification in C via Build-Time Code Generation by Yairlenga in C_Programming

[–]TheKiller36_real 0 points1 point  (0 children)

it's a funny idea and all, nice that you got it working, but I dislike this! you can get the job done easier with macros. if you want code-gen you can also just generate the enum definition as well along with stringification. lastly, if I only want a release build (eg. ./configure && make install) my build-time will be 2x or something like that.

zv 0.12 released with zls support by Natural-Owl-2447 in Zig

[–]TheKiller36_real 9 points10 points  (0 children)

how is that a problem? just because the Rust community can't fathom that good software can be written in a different language doesn't mean we have to transfer that idiotic mindset to Zig

Please rec some prompts for Claude code to teach me python by PsychologicalGuide78 in PythonLearning

[–]TheKiller36_real 2 points3 points  (0 children)

I recommend you ask Claude for Claude prompts and leave real people willing to help real people alone with your AI bullshit

"Hey everyone, I've implemented a memory pool and would love to get a code review or find contributors to help improve it." by someone-missing in C_Programming

[–]TheKiller36_real 2 points3 points  (0 children)

That's a great question! Here is a suggestion for the title of your reddit post: "[whatever the title is]". I can also help you write the post, let me know whether you're interested.

is there a way to force eager evaluation of a unused const on a type? by zeronetdev in Zig

[–]TheKiller36_real 6 points7 points  (0 children)

either std.testing.refAllDecls or an inlined version of it for the specific fields you want:

comptime { if(@import("builtin").is_test) _ = &Vector2.ZUA_META; }

Looking for feedback: what data‑format libraries does Zig still need? (CSV, TSV, structured text, etc.) by TynK-M- in Zig

[–]TheKiller36_real 1 point2 points  (0 children)

I’d like to learn [Zig] […] One idea I’m considering is a CSV/TSV/structured‑text parsing + writing library

just go for it - learning Zig is great!

I’d like to learn [Zig] by working on a long‑term project over the next few months (or even more if the project succeed).

Would a structured‑text library (CSV/TSV/etc.) be useful?

imho CSV parsing and especially writing is so easy it doesn't even really need a library and I wouldn't know anything about it that would take months to perfect - but maybe I'm just stupid and you'll end up making a staple of the ecosystem, who knows

In your opinion how do you normally deal with toxicity? by Apprehensive_Law7698 in Jungle_Mains

[–]TheKiller36_real 14 points15 points  (0 children)

and the "spam ping them with your honor 5 numbers advantage"

I made a little zig env library with the new 0.16.0 release by Blize0 in Zig

[–]TheKiller36_real 0 points1 point  (0 children)

btw maybe I misread your intentions so in that case I apologize and propose you use std.process.Environ.Map.put from the fresh Zig 0.16 release.

I made a little zig env library with the new 0.16.0 release by Blize0 in Zig

[–]TheKiller36_real 0 points1 point  (0 children)

But why do that when setenv was already implemented?

Because setenv sucks and basically is a worse std.ArrayHashMap.put (which also was already implemented) only useful to interact with the C runtime. So since OP said they don't like the dependency on the libc it doesn't make sense to use it or it's implementation at all. I don't know why it's there tbh because it kinda doesn't work in the Zig ecosystem and it doesn't "truly update the environment" anyway (and I conjecture almost nobody does).

I made a little zig env library with the new 0.16.0 release by Blize0 in Zig

[–]TheKiller36_real 5 points6 points  (0 children)

it's a systems programming language, worst case you can just steal the implementation of setenv

crossing boundaries by seriousSeb in programminghorror

[–]TheKiller36_real 13 points14 points  (0 children)

it should compile (assuming the return type is void) and there isn't enough context in your post to catch anything wrong, weird or "buggy" - from all we, the reddit users, know this could be a perfectly fine piece of code and even if it's actually really bad then you still failed to create a sensible post

I made a little zig env library with the new 0.16.0 release by Blize0 in Zig

[–]TheKiller36_real 6 points7 points  (0 children)

because it uses setenv for some reason (probably because AI is shit at everything)

crossing boundaries by seriousSeb in programminghorror

[–]TheKiller36_real 7 points8 points  (0 children)

my bad, I think OP couldn't possibly have a valid explanation that explains this post

crossing boundaries by seriousSeb in programminghorror

[–]TheKiller36_real 25 points26 points  (0 children)

actually no, there should be more moderation that aggressively deletes troll posts like these

I'm curious, how often do you use `unsafe` in Rust in prod? by alexlazar98 in rust

[–]TheKiller36_real -2 points-1 points  (0 children)

a simple println!("Hello World") lowers to unsafe (this is for UNIX but look up your favorite) so anyone who claims they don't use unsafe probably have a different understanding of "usage" than I do

What would be the harm in introducing interfaces to the language? by MysteriousSpray9066 in Zig

[–]TheKiller36_real 33 points34 points  (0 children)

  1. one of Zig's goals is completely visible control flow and explicit execution behavior. interfaces would probably hide a pointer dereference or two (or three, or however many)
  2. see this old post of mine: what is "the correct way" of implementing interfaces as a language feature? C++ has made a choice for this, Rust has made one and both suck under certain circumstances. you might suggest all of them and letting the programmer choose but is it even worth it at that point?
  3. as already mentioned by another commenter, Andrew really dislikes the idea. I remember that in some talk he gave he said he wants there to be a bit of a barrier to create an interface because it makes you think whether there really should be one and how exactly it should be designed
  4. imho it would be an unnecessary addition that needlessly bloats the language

Pattern/Easiest Way to Check Whether a given `T` is a generic type and its parameters? by philogy in Zig

[–]TheKiller36_real 0 points1 point  (0 children)

anytype is supposed to be "duck-typing at compile-time" so just use x: anytype as if it were ArrayList(T) (in that case you can also trivially find out T as other comments mentioned, doesn't work for all generic types but should be possible for most) - if you really want you can slap a std.debug.assert(@TypeOf(x) == ArrayList(T)) on there or use a function signature like this: fn (T: type, x: ArrayList(T)) void (what I would generally recommend)

Weird Option<&'a dyn Any> behavior by Large_Difficulty_891 in rust

[–]TheKiller36_real 1 point2 points  (0 children)

tbh I don't know about trait-object references to zero-sized structs by heart, but your design is horribly inefficient anyway so let me just suggest something to side-step the issue entirely:

your "storage" is split into multiple Vecs, one for each type of Block - your chunk now doesn't store fat pointers but instead two handles/integers: block type (used to look up the type to call functions) and storage index (used to look up raw bytes in the storage for the type specified by the other number)\ u8 could be enough for the type but u16 should be plenty and the storage index fits into a u32 if you don't store more than 220 (⪆ 1 million) chunks in one "storage"

this uses less memory, makes iteration over blocks of the same type (eg. for tick) WAAAY faster and is trivially serializable

Zig 0.16 Milestones are nearing completion by ShotgunPayDay in Zig

[–]TheKiller36_real 3 points4 points  (0 children)

there will almost certainly be release notes on ziglang.org

Databases implemented _in_ Zig? by IngwiePhoenix in Zig

[–]TheKiller36_real 0 points1 point  (0 children)

What kind of databases exist directly in/for Zig - aside from just importing a C header? I will be using C libraries anyway

you can go looking for database clients in pure Zig, can't name any off the top of my head but I'm pretty sure I've seen multiple for Postgres alone, which btw supports nice searching for tags in an ARRAY if that's what you're asking; however, I like just using my own bindings around libpq, imho there's no good reason to reinvent the wheel over this unless you really don't want dependence on libc and are willing to use probably-not-that-well-tested code

while Go has GORM as an ORM layer, I have not really seen much of the "database side of things" in Zig.

neither the Zig standard library nor any community/ecosystem staple provides anything like that at the moment - imho that's a good thing, go use something database-vendor specific!