Live data from Hacker News

Zig Libc

ziglang.org

161–170 of 196 posts

Re: Zig Libc

#161

Earlier quoted context omitted.

That's something I've always admired about Zig. A lot of languages claim to be a C replacement, but Zig is the second language I've seen that seemed like it had a reasonable plan to do so at any appreciable scale. The language makes working with the C ABI pretty easy, but it also has a build system that can seamlessly integrate Zig and C together, as well as having a translate-c that actually works shockingly well in…

D can import C files directly, and can do C-source to D-source translation. D can compile a project with a C and a D source file with: dmd foo.d bar.c ./foo

> C-source to D-source translation.

I'm not so familiar with D, what is the state of this sort of feature? Is it a built-in tool, or are you talking about the ctod project I found?

In most languages, I've found that source translation features to be woefully lacking and almost always require human intervention. By contrast, it feels like Zig's `translate-c` goes the extra mile in trying to convert the source to something that Zig can work with as-is. It does this by making use of language features and compiler built-ins that are rather rare to see outside of `translate-c`.

Obviously the stacks of @as, @fooCast, and @truncate you are left with isn't idiomatic Zig, but I find it easier to start with working, yet non-idiomatic code than 90% working code that merely underwent a syntactic change.

Re: Zig Libc

#162
post #139

Earlier quoted context omitted.

D can import C files directly, and can do C-source to D-source translation. D can compile a project with a C and a D source file with: dmd foo.d bar.c ./foo

Do you have to bring up D in every Zig related post? I do like D. I've written a game in it and enjoyed it a lot. I would encourage others to check it out. But it's not a C replacement. BetterC feels like an afterthought. A nice bonus. Not a primary focus. E.g. the language is designed to use exceptions for error handling, so of course there's no feature for BetterC dedicated to error handling. Being a better C is th…

I think the history of D having a garbage collector (and arguably exceptions / RTTI) from the beginning really cemented its fate. We all know that there's a "BetterC" mode that turns it off - but because the D ecosystem initially started with the GC-ed runtime, most of the D code written so far (including most of the standard library) isn't compatible with this at all.

If D really wants to compete with others for a "better C replacement", I think the language might need some kind of big overhaul (a re-launch?). It's evident that there's a smaller, more beautiful language that can potentially be born from D, but in order for this language to succeed it needs to trim down all the baggage that comes from its GC-managed past. I think the best place to start is to properly remove GC / exception handling / RTTI from the languge cleanly, rewrite the standard library to work with BetterC mode, and probably also change the name to something else (needs a re-brand...)

Re: Zig Libc

#163
post #139

Earlier quoted context omitted.

Do you have to bring up D in every Zig related post? I do like D. I've written a game in it and enjoyed it a lot. I would encourage others to check it out. But it's not a C replacement. BetterC feels like an afterthought. A nice bonus. Not a primary focus. E.g. the language is designed to use exceptions for error handling, so of course there's no feature for BetterC dedicated to error handling. Being a better C is th…

C++ is more C-like than Zig and Rust, so it's more likely to become a C replacement.

I do feel like allowing for in-place source upgrading was critical to C++'s early successes. However, I feel like this ultimately worked against C++, since it also wed the language to many of C's warts and footguns.

Re: Zig Libc

#164
post #139

Earlier quoted context omitted.

Do you have to bring up D in every Zig related post? I do like D. I've written a game in it and enjoyed it a lot. I would encourage others to check it out. But it's not a C replacement. BetterC feels like an afterthought. A nice bonus. Not a primary focus. E.g. the language is designed to use exceptions for error handling, so of course there's no feature for BetterC dedicated to error handling. Being a better C is th…

This is, like, the most ironic comment ever posted on HN. An article about cat nutrition could hit the front page and the Rust fanbois would hijack the conversation. In this case, however, Walter was not the one that brought up D. He was replying to a comment by someone promoting Zig with the claim that only Zig and C++ have ever had a strategy to replace C. That is objectively false. There's no way to look at what D…

> claim that only Zig and C++ have ever had a strategy to replace C

What I actually said was that it was the second language I have seen to do so at any appreciable scale. I never claimed to know all languages. There was also an implication that I think that even if a language claims to be a C replacement, its ability to do so might exceed its ambition.

That said I also hold no ill will towards Walter Bright, and in fact was hoping that someone like him would hop into the conversation to try and sell people on why their language was also worthy of consideration. I don't even mind the response to Walter's post, because they bring real-world Dlang experience to the table as a rebuttal.

On the other hand, I find it difficult to find value in your post except as a misguided and arguably bad-faith attempt to stir the pot.

Re: Zig Libc

#165

Earlier quoted context omitted.

Hey it’s only the first week of February - isn’t it a bit early to be vying for most egregious example of a false equivalence?

No, the point is valid. The reason milch is saying "it's only two words what's your problem" isn't because it's only two words, it's because they are expressing a message he finds to be acceptable. The parent poster was attempting to point that out by showing there are "two words" messages he wouldn't support.

Advocating for the removal of an abusive government agency that has been around for only a handful of years is very fucking different from professing white supremacist views.

Trying to compare those because "they're only two words!" is textbook false equivalence.

https://en.wikipedia.org/wiki/False_equivalence#Examples

Re: Zig Libc

#166

Earlier quoted context omitted.

How many laws has the Trump administration flat out ignored? You're cheerleading the introduction of a lawless society. Perhaps you should reconsider your frame of reference.

Cheerleading laws to be enforced is the opposite of cheerleading the introduction of a lawless society.

Their underlying point is that you're actually being very selective in which laws you want enforced.

For starters, I doubt you've brayed as loudly for the prosecution of business owners who employ illegal migrants, as you are for the migrants themselves. (You certainly didn't mention illegal biz owners in this comment chain.) Likewise, the crimes ICE commits already exceed the crimes of those they're hunting, but you haven't acknowledged that.

Which means you don't actually believe in the law as an impartial force of justice, despite what you might tell yourself. You believe in it as a tool of power, to be wielded strongly against those you dislike, and lightly or not at all, against those you favor.

You believe in power and order, not justice and fairness.

Re: Zig Libc

#167

Earlier quoted context omitted.

Hey it’s only the first week of February - isn’t it a bit early to be vying for most egregious example of a false equivalence?

No, the point is valid. The reason milch is saying "it's only two words what's your problem" isn't because it's only two words, it's because they are expressing a message he finds to be acceptable. The parent poster was attempting to point that out by showing there are "two words" messages he wouldn't support.

The poster I replied to made an over exaggerated statement about the prominence of these two words, which I found hilarious, in the same way a teenager saying "I am LITERALLY DYING right now" after the barista spelled their name wrong on their coffee order would be hilarious. This was a very slight inconvenience to the poster's day (at best) that they could have dropped after deciding they don't care about events happening in a country they don't live in.

Re: Zig Libc

#168
post #49

Earlier quoted context omitted.

You must have not tried this with an LLM agent in the past few months.

i tested sonnet 4.5 just last week on a zig codebase and it has to be instructed the std.ArrayList syntax every time.

Are you using an agent? It can quickly notice the issue and fix it. Obviously if it's trained on an older version it won't know the new APIs.

Re: Zig Libc

#170

Earlier quoted context omitted.

yeah I just thought there are "compiler shenanigans" involved with printf! zig's va arg being broken is sad, I am so zig-pilled, I wish we could just call extern "C" functions with a tuple in place of va arg =D

The only thing C compilers do for printf, is static analyze the format string for API usage errors. Afaik such isn't possible in zig currently. But idk why'd you downgrade yourself to using the printf interface, when std.Io.Writer has a `print` interface where fmt is comptime and args can be reflected so it catches errors without special compiler shenigans.

I'm thinking: do a translate-c and then statically catch errors using my zig-clr tool.
Post reply on HN