News for hackers. Stuff that matters.
Re:Using Zig's translate-C to understand weird C code by caslon on Wednesday November 03, 2021 @06:21AM (#29092803)
Am I the only one who thinks that Zig's syntax looks incredibly ugly? I've never seen a snippet that didn't make my eyes glaze over from the syntax. What am I not getting here?
Re:Using Zig's translate-C to understand weird C code by kristoff_it on Wednesday November 03, 2021 @08:59AM (#29093962)
This particular example is machine-generated code created by translate-c, it's meant to be semantically equivalent to the C code and even uses language features that you're normally not even supposed to use (c pointers).

Reasonable Zig code looks more like this:

https://github.com/riverwm/river/blob/master/riverctl/main.z...

That said I think it's fine if you don't like the syntax. I think that some complaints are honestly too superficial to be legitimate (like complaining about builtins being prefixed with @), but at the same time Zig is often times prioritizing explicitness over "good looking".

I personally consider Swift a very good looking language, but then I look at all the new features that got added since I used it last, remember that I value simplicity over aesthetics, and go back to Zig.

Re:Using Zig's translate-C to understand weird C code by dragonelite on Wednesday November 03, 2021 @10:02AM (#29094675)
Ooh that looks a bit like Rust having quickly scrolling by. I have been keeping a eye on Zig but I'm waiting till the package manager stuff has been finalized and implemented.
Re:Using Zig's translate-C to understand weird C code by capableweb on Wednesday November 03, 2021 @06:29AM (#29092859)
> Am I the only one who thinks that Zig's syntax looks incredibly ugly?

It's very subjective what is beautiful or ugly, of course. It'd be more interesting if you can offer specific critique rather than just calling it ugly.

You're probably not the only one, I for one would call any non-lisp "ugly", but again, highly subjective, as many others find some C-like code beautiful but other C-like code ugly.

Re:Using Zig's translate-C to understand weird C code by jcelerier on Wednesday November 03, 2021 @06:40AM (#29092930)
> It's very subjective what is beautiful or ugly, of course.

if it was, something like trypophobia would not exist

Re:Using Zig's translate-C to understand weird C code by capableweb on Wednesday November 03, 2021 @06:43AM (#29092952)
What? Are you arguing that because a phobia (that not everyone had) exists, beauty is not subjective but absolute? I'd love to see how you measure beauty if so, including the "beauty of code".
Re:Using Zig's translate-C to understand weird C code by Talanes on Wednesday November 03, 2021 @03:57PM (#29099525)
Trypophobia proves beauty subjective, not the other way around. I can find an image beautiful that someone with trypophobia finds deeply unsettling.
Re:Using Zig's translate-C to understand weird C code by jcelerier on Sunday November 07, 2021 @04:36AM (#29137839)
Objective / subjective does not mean that things cannot be experienced relatively. Someone colourblind isn't able to distinguish all colours, yet it does not mean that colours as a frequency of electromagnetic radiation are subjective, only their experience is.
Re:Using Zig's translate-C to understand weird C code by cies on Wednesday November 03, 2021 @08:21AM (#29093610)
It is common to make stuff you dont generally want in your code (but still need to be able to do because the language is sufficiently powerful) look ugly.

Like unsafePerformIO in Haskell.

Re:Using Zig's translate-C to understand weird C code by deaddodo on Wednesday November 03, 2021 @03:58PM (#29099530)
As someone who likes both C and Zig for their simplicity and explicitness, I don’t find it “ugly”.

I do find it practical, with an aesthetically barebones approach.

Re:Using Zig's translate-C to understand weird C code by pjmlp on Wednesday November 03, 2021 @06:48AM (#29092980)
You are not alone, if I miss @ everywhere I will just start an Objective-C project.

Then using modules with JavaScript AMD pattern is also not appealing.

Re:Using Zig's translate-C to understand weird C code by AnIdiotOnTheNet on Wednesday November 03, 2021 @09:46AM (#29094469)
If using '@' to prefix builtins[0] is the biggest complaint[1] people have about Zig, then Zig must doing a pretty good job.

[0] or really any statement at all about aesthetics

[1] I know for a fact pjmlp will also complain about lack of built-in gc or ref-count pointer safety.

Re:Using Zig's translate-C to understand weird C code by pjmlp on Wednesday November 03, 2021 @09:52AM (#29094530)
Paying attention it seems.
Re:Using Zig's translate-C to understand weird C code by matheusmoreira on Wednesday November 03, 2021 @07:34AM (#29093283)
Yeah. I think I'm so used to C by now that I just can't handle anything that doesn't look like C. It's like my brain just ignores text when it can't recognize the C code patterns.

Semantically Zig is really interesting though.

Re:Using Zig's translate-C to understand weird C code by skocznymroczny on Wednesday November 03, 2021 @09:45AM (#29094458)
I feel similar when it comes to non-OOP code. I don't like free functions and global variables just hanging there.
Re:Using Zig's translate-C to understand weird C code by kristoff_it on Wednesday November 03, 2021 @10:37AM (#29095246)
OOP might have helped popularize usage of the dot notation, but namespaces are a different thing.

Zig has no inheritance but everything is namespaced, including declaring functions inside struct definitions so that you can use them as if they were methods.

Re:Using Zig's translate-C to understand weird C code by matheusmoreira on Wednesday November 03, 2021 @10:07AM (#29094741)
Yeah, me neither. Names must belong to some namespace, it really bothers me when code starts binding common nouns in a global context. C lacks namespaces so I use prefixes instead. At least this solution doesn't screw up the ABI like in C++.

I hate global variables so much it's one of the reasons I got rid of libc. Freestanding C turned out to be a superior language just because it lacks all the libc cruft.

I ultimately dropped Ruby because of global state. It's such a wonderful language but it has one fatal flaw: lack of proper modules. The require method just executes Ruby source files, modifying the global state of the interpreter. It ceased to be a beautiful language once I realized this. Python's modules are superior, and the Javascript approach is the best one: just a normal function that returns a normal object containing exported data and functions. Javascript modules are c.ompletely reified.

Re:Using Zig's translate-C to understand weird C code by foxfluff on Wednesday November 03, 2021 @06:55AM (#29093025)
Yeah, the syntax doesn't really excite to me too much. Which is a shame, because I would like to see a modernized "better C" that isn't more verbose than C.