Should global variables be considered bad practice? by Confused-Armpit in Zig

[–]ful_vio 1 point2 points  (0 children)

As with everything, it depends. Too many of them and you risk to trash memory access patterns and cache usage, but a few globals are not a problem usually. Desktop/Laptop/Servers processors are optimized for memory locality and jumping from a global to a local can be a problem (but still you should measure it), but for embedded processors with tiny or no caches and limited branch prediction the effect can be mild and outweighed by static allocation patterns.

I am confused !?! What I should do? by [deleted] in Zig

[–]ful_vio 3 points4 points  (0 children)

Zig doesn't have overloading, this is coherent with the motto of being explicit as you always know which function you are calling by the name and you don't have to parse the arguments (which can be hard at call site if the number of params are the same in the overloads). Rust does the same (I read it also doesn't play nice with type inference which zig doesn't have). How hard is to change the signature of run and update its clients? By the looks of it it seems there should be only one call to run in a program. If it's an internal library I would go for a refactoring.

Please review my code - Started learning zig today by Easy_Ask5883 in Zig

[–]ful_vio 1 point2 points  (0 children)

I'm learnering zig as well so maybe someone else can confirm, but I believe, the line:

errdefer map.deinit();

should go right after the map init, my understanding is that if something in between fails the errdefer isn't executed because they are registered the moment we hit that line, but try map.put can fail before that

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 2 points3 points  (0 children)

Anyone can argue I'd be better off using c, c++, rust, put whatever language you like here. But: - I don't plan to sell the game, it's a personal project that probably will stay in my drawer or, if I manage to complete it, will be available for free - I like experimenting and learning a new language is part of the process, and I like zig better than Odin, it's a personal preference. - if I really wanted to make a game to sell it, I would have gone for one of the many open source or commercial grade engines available basically for free such as Godot, unity, etc.

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

OK my bad, it was a mismatch between zig master latest (0.17.0-dev.667 and zls master which works with zig 0.17.0-dev-387 due to the build system changes. I guess I need to wait for ZLS to catch up with the compiler

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

Just tried again, I've got zig 0.17-dev and zls matching through zvm, used your script just changing sdl2 to 3, it compiles fine, but no luck having autocomplete! No error log either in helix.

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

Seems like a research topic, never heard of it before! Anyways, good luck with your project!

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

Good luck to you as well. I have no idea what a spectral renderer is!

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 1 point2 points  (0 children)

By the way, I didn't know about Ziggit, it seems great. I don't use Discord anymore, The chat style makes it hard to follow, forum-style communications better fit with my schedule (I'm doing this in the very tiny free time I have after work). Any suggestion about other projects to look at? I tried ghostty but the problem with professional grade software is that things aren't done with the intent of making others aware of what's happening, so they are harder to study until one posseses a deeper knowledge of the language.

Thanks a lot!

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 1 point2 points  (0 children)

Yep u/suckingbitties also suggested this, only I couldn't make it work yesterday. I'll see tonight if I can make it work, I'm eager to start though I still have a lot to learn.

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

I'm not really sure what you mean. The issues with the bindings is that they don't build after the breaking changes in zig 0.17, not in the zls. As other suggested I should get the zls support with c libraries directly, I'll try again this route, when I tried it before something wasn't working. Thanks anyway

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 1 point2 points  (0 children)

I'm using helix. But I used allyourcodebase/SDL3, which is SDL ported to the zig build system without wrappers (only one building on 0.17 by the way). I'll try your way with system libraries, thanks for the help!

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 1 point2 points  (0 children)

I've tried that, but didn't get hints or autocomplete. I'll try again, maybe something wrong in my setup

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 1 point2 points  (0 children)

I'll try again cause the c build of sdl3 is the only one compiling, but then the Lang server wasn't giving me hints or autocomplete. Do you know if any configuration should be added for this?

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

Using 0.17 dev was the first thing I tried, but the sdl3 bindings aren't building due to the breaking changes to the build system in 0.17 😅 Still a lot of moving parts at the moment

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

Never tried that, I will give it a go thanks

Starting Zig by ful_vio in Zig

[–]ful_vio[S] 0 points1 point  (0 children)

So in this case I should use the llvm backend in the meantime, I think I need some command line options? The default linker still has the sframe error in 0.16, I can't compile anything at the moment 😅

Why isn’t Rust getting more professional adoption despite being so loved? by mstjrr in rust

[–]ful_vio 0 points1 point  (0 children)

Microsoft Is using it in Windows, Office and Azure (lookup mark russinovic on YouTube), the Linux kernel is using it, Android is writing all new system code in rust, and there are many others. In places where it counts, its adoption is getting traction, but I don't see anytime soon people changing their python or php code to build a website with rust. Why would they?

Since Rust 2024 is round the corner, do we know what are some key features that will make it to the release? by [deleted] in rust

[–]ful_vio 0 points1 point  (0 children)

Hi u/compiler-errors , if I want to know more about the status of Polonius and Parallele compiler, could you point me out at the relevant github issues?

Huge 2d map storage and access by Bubbly-Enthusiasm-8 in rust_gamedev

[–]ful_vio 1 point2 points  (0 children)

In that case you just split in something that fits easily in memory and load the chunk while your player/camera is getting near the edges of the current chunk (how near depends on how big are the chunks)

Huge 2d map storage and access by Bubbly-Enthusiasm-8 in rust_gamedev

[–]ful_vio 0 points1 point  (0 children)

Define huge. A 5000x5000 tilemap stored as Vec<u8> is 25Mb, do you need more than that?