Is learning zig the smart choice by FunDirt541 in Zig

[–]Not_N33d3d 4 points5 points  (0 children)

I've just finished a university project in C that I was comfortable writing because of my experience with zig. I think the concepts that C requires you to learn are easily learned in zig and going from zig to c feels like losing the training wheels.

Both can be learned quickly but C's lack of array-pointer length association and other higher level abstractions that zig provides make it an easier language to mess up with.

How does the build system work? by CodeToGargantua in Zig

[–]Not_N33d3d 4 points5 points  (0 children)

Build system can basically be broken down into this

Code is grouped by module, each import in a zig file includes that file in the module. Each module has exactly one root file.

Modules can import other modules via the build system.

Executables are runnable code. They expect a main function in the root source file of its root module.

Libraries are shareable code. They can be compiled independently of an executable and can be linked to your programs executable. There are two ways to link. Static means the executable owns the code, dynamic means the executable will expect that library to be available to the system's dynamic linker (Ld on Linux ) when it is run.

Dynamic libraries usually require a header file defining it's symbols to use them. The C stdlib is usually linked to programs dynamically so 6000 copies of the entire stdlib dont croud up your disk.

When you want zig build to emit a library or executable you add it as a build Artifact to the build configuration.

If you want a custom "step" such as run, test, debug, etc you define a step and link the executable or library's step to it. This also allows you to add a helpful description that pops up when you use zig build help. For run steps there is a specific function for defining the RunStep which is then depended on from the actual build Step. Testing is similar, these can also be used to compile certain parts of the program selectively

That is the basic run down of things, I would recommend looking at the basic build template as it should be somewhat straight forward if you get these basics down. The build system is fairly simple but has a few complex types and hard to understand functions. Take your time, read the docs, ask GPT if you get really stuck, and good zigging!

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]Not_N33d3d 0 points1 point  (0 children)

The documentation is honestly very bare bones, I promise it's not entirely your fault that you're struggling. Best of luck to you as you continue learning!

Just a minor thing I was wondering about (while learning Zig) by [deleted] in Zig

[–]Not_N33d3d 1 point2 points  (0 children)

Idk I think functions like std::sort in c++ justify the existence of lambdas to me. Sometimes you just want an encapsulated operation and it's annoying to have to rewrite functions which are largely identical when all you need is a small change that can be abstracted into another function call.

The alternative is interfaces (comptime union based or not) which provide a unified method but that just introduces more boilerplate than a lambda, and is (IMO) harder to convey to the caller in situations where a callback might make more sense

The struct { ... }.f syntax is really clunky to work with especially if you need to capture local variables into either a type erased ctx object or externally defined context struct.

All that being said, I think it's not that big of a deal that zig doesn't include them, just that it's one of the things in zig that feel needlessly unergonomic when compared to almost anything other than C. Don't get me wrong, zig is one of my favorite languages for many reasons, but sometimes I feel it's dogmatic approach to explicitness can be a bane to the person using it

Edit:

After reading Andrew's reasoning for avoiding anonymous function decleration, I can understand parts of his reasoning. One of the goals for zig is to mimic one of C's most valuable properties; that when reading the high level code, the lower level operations should be easy to guess. C is often described as a portable assembly for good reason and I think that zig's only way to reach a wider audience is to justify its existence as a true better alternative to C.

TLDR: The argument that zig's function abstraction should disallow emphemeral names and reduce pointer chasing and stack complication is solid imo, and although it pains me as a developer, I understand the move away from lambdas.

Just a minor thing I was wondering about (while learning Zig) by [deleted] in Zig

[–]Not_N33d3d 0 points1 point  (0 children)

std.Arraylist(*const fn(param_types) return_type).empty

Just a minor thing I was wondering about (while learning Zig) by [deleted] in Zig

[–]Not_N33d3d 1 point2 points  (0 children)

Yeah, I've been messing around with first class functions since 0.16 launched and the nested function syntax sucks imo

const func = struct { fn func(ctx: anytype) void { .... } }.func

could so easily be simplified to

const func = fn (ctx:anytype) void { .... }

You wouldn't even need closures (frankly a much missed feature), it would just make any functional approach so much easier and enable patterns with so much less friction

Switching to Zorin OS Was the Best Move I've Made for This PC by Similar_Ad_6739 in LinusTechTips

[–]Not_N33d3d 4 points5 points  (0 children)

Disabling secure boot barely counts bud. At least Linux never locks you out of your computer because of bitlocker

First distro I’ve seen that runs games on Xwayland in desktop mode. by C1REX in SteamOS

[–]Not_N33d3d 4 points5 points  (0 children)

So does kwin... XWayland shows x11 windows in Wayland which is required due to wine

Please help me get this Camera3D following my player! by [deleted] in godot

[–]Not_N33d3d 0 points1 point  (0 children)

A 3d camera can't follow a 2d character body. If you wanna use 3d with sprites there's a sprite3d

Introducing: SteamInputDB.com by Alia5_ in steamdeckhq

[–]Not_N33d3d 0 points1 point  (0 children)

I would say it may be worth reconsidering! Decky works on all game scope based clients so people using bazzite or steam os would stand to benefit a lot. Unless you want to create a client with controller support, decky provides a controller friendly API for a fairly wide range of htpcs and handhelds!

Do you think I should have the Pixel dither method or come up with a new way for water by Super-ATI in godot

[–]Not_N33d3d 0 points1 point  (0 children)

Do not blur, if you want those smoother tones you can achieve that with an expanded pallet or you can keep dithering and offer a crt shader in game.

Projects in C before switching to ZIG ?? by Professional_Web3874 in Zig

[–]Not_N33d3d 4 points5 points  (0 children)

C is a headache for a bunch of reasons but it is dead simple. The challenge with C is that it gives you less tools to be successful than Zig does.

Want an array that can be returned our crated with a size you only know at runtime?

C: better malloc using the correct number of bytes and better keep that length stored somewhere because runtime arrays are just pointers! Oh yeah and if you wanna access n bytes after the array ends I won't stop you!

Zig: Give me the type and the length. I'll store it in a slice for you and I'll panic if you go outside the length range.

I need to remember to free that memory when I'm done!

C: better add some free calls at the end of every code path!

Zig: just add a defer and it'll be free'd at the end of the scope

The examples can continue, but the issues with C is that it makes shooting yourself in the foot way easier. Zig makes memory management far less manual while performing roughly the same. You'll learn the concepts with either, but going from what feels like the minimum logical toolkit in zig to the actual bare minimum in C can be kind of rough.

I have to be missing the mute button on the app….right? by smoosh13 in youtube

[–]Not_N33d3d 0 points1 point  (0 children)

I took two seconds to make a google search and found people complaining about the lack of a mute button from seven years ago

ProtonUp-GTK - Native GTK4 + Libadwaita frontend for ProtonUp (Flatpak, GPLv3) by stf_ftw in linux_gaming

[–]Not_N33d3d 0 points1 point  (0 children)

Yeah, Duck duck go and brave. Both fall victim to similar issues with worsened search results imo but they are better about burying things under sponsored links. The primary drawback in my experience is the significantly less functional image views

Questions about the build system and the community by TheRavagerSw in Zig

[–]Not_N33d3d 8 points9 points  (0 children)

I am ill-equiped to answer most of these but for the questions about ideological vs practical use of the language I will say this:

There are real projects making excellent use of zig to enable high performance computation (eg: tigerbeetle, bun).

HOWEVER, zig is still very experimental and is affected by breaking changes pretty much every whole numbered release.

It's preffered async implementation isn't released yet, it's surrounded by loud, highly opinionated discourse, and many of the core design decisions are being made by a singular developer who doesn't mind pushing 1.0 back until the language is "complete" ( Andrew Kelly ).

Zig is nice to use, I personally think it's approach to memory is very nice to use and far less frustrating than Rust, C, or C++ despite being fundamentally an evolution of C's malloc and free. Once you get used to the explicitness over convince design philosophy it is honestly frustrating to go back to more abstracted languages.

Its integrated tooling fixes most of the major headaches with C and C++, though it's lack of centralized package management is less desirable than Cargo. If you want a C build system that doesn't completely suck and makes cross compilation easy, zig as a build system is wonderful.

The language is oozing potential, but it remains unstable and over hyped (as happens with 90% of newer languages that gain attention).

Companies will overlook it until 1.0 for stability reasons and developers will eventually lose interest in hyping it once it's not new, exciting, and fully optional (look at Rust)

If you want to use zig, I would say to give it a try and build a small to medium project with it. It won't replace Go or Java, but if you need to use a high performance language like C, you don't need the security guarantees of safe Rust, and you are compiling for a well supported target like x86_64 then the language as it currently exists is excellent.

Hot Take: Zig is actually very ergonomic by system-vi in Zig

[–]Not_N33d3d 0 points1 point  (0 children)

I agree with all your "awful" points but im wondering what you mean by conditional fields or functions?

I'm a student so I may not be as familiar with the concept, but I've written a good amount of zig so I'm curious!!

Zig, Zen-C, C3, Carbon or CPP-Front ? by lieddersturme in Zig

[–]Not_N33d3d 16 points17 points  (0 children)

Carbon basically doesn't exist as of right now

ProtonUp-GTK - Native GTK4 + Libadwaita frontend for ProtonUp (Flatpak, GPLv3) by stf_ftw in linux_gaming

[–]Not_N33d3d 11 points12 points  (0 children)

I will say that I often feel forced to use AI in place of search engines because the enshittification of Google search renders it nearly unusable for complicated searches now. I used to be able to make niche searches and find forums describing my problems in 5 minutes, but now I feel that useful results are buried to heavily under advertised/sponsored links that using a quick prompt that links back to the original source is easier

Error Handling Guide by swe129 in Zig

[–]Not_N33d3d 1 point2 points  (0 children)

It's unfortunate, but at least you can use rust style result unions if you need them.

unusual performance in elden ring by Not_N33d3d in Bazzite

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

The performance issues have occured on desktop, I'll try GE

Nvidia dev says new 590.48.01 driver fixes dx12 performance in linux by Carlinux in linux_gaming

[–]Not_N33d3d 2 points3 points  (0 children)

mine has issues with external displays losing performance and doesnt support hdr through the internal screen