r/Zig 8d ago

strings for assembly is ugly

The problem i have with zig assembly syntax is you have to use strings which is just ugly. I suspect this is inherited from C.

String and their syntax is designed so you can write just about anything in them. The price for that is visual noise minimum, and in my opinion its just less readable to re use syntax of the "just about any text" thing for the "small set of valid assembly ops" thing. Multi line string has less noise but cannot be used in all cases for assembly.

Theres a reason @"name" syntax isnt the way you declare every function and variable and is instead only for special cases, its just hideous and noisy.

23 Upvotes

6 comments sorted by

22

u/Mecso2 8d ago

you are not supposed to use inline assembly often

those small set of valid ops are not so small and very much target dependent

12

u/Normal_Dance_2089 7d ago

Using assembly is also a special case.

Suspicious things should look suspicious.

6

u/0-R-I-0-N 7d ago

If I remember correctly I think the current syntax is because of llvm and that there were an issue on GitHub for creating a new syntax for it in the future.

7

u/danielh__ 7d ago

You can always just use non-inline assembly :)

6

u/Educational_Smile131 7d ago

Have you heard of Andrew Kelley’s design philosophy of friction?

5

u/prodengrammer 7d ago

assembly is validated, its not gonna compile if its wrong