Live data from Hacker News

Lightpanda migrate DOM implementation to Zig

lightpanda.io

121–130 of 144 posts

Re: Lightpanda migrate DOM implementation to Zig

#121
post #84
post #73

Earlier quoted context omitted.

Not really modern, it is Object Pascal/Modula-2 repackaged in C like syntax. The only thing relatively modern would be compile time execution, if we forget about how long some languages have had reader macros, or similar capabilities like D's compile time metaprogramming. Also it is the wrong direction when the whole industry is moving into integrity by default on cyber security legislation. There are several example…

> Not really modern, it is Object Pascal/Modula-2 repackaged in C like syntax. That's your opinion, but I couldn't disagree more. It places partial evaluation as its biggest focus more so than any other language in history, and is also extraordinarily focused on tooling. There isn't any piece of information nor any technique that was known to the designers of those older languages and wasn't known to Zig's designer.…

> You certainly don't have to agree with my assessment, but you do need to acknowledge that some people very much see it that way, and don't think it's merely a "repackaged" Pascal-family language in any way.

My opinion is that 99% of those people never knew anything beyond C and C++ for systems programming, and even believe the urban myth that before C there were no systems programming languages.

Similar to those that only discover compiled languages and type systems exist, after spending several years with Python and JavaScript, and then even Go seems out of this world.

Re: Lightpanda migrate DOM implementation to Zig

#122
post #116
post #114

Earlier quoted context omitted.

> Except reference counting is one of the two classical GC algorithms (alongside tracing), so I think it's strange to treat it as "not a GC". But it is true that GC/no-GC distinction is not very meaningful given how different the tradeoffs that different GC algorithms make are. That's not the issue. Calling anything with opt-in reference counting a GC language. You're just fudging definitions to get to the desired ta…

> Calling anything with opt-in reference counting a GC language Except I never called it "a GC language" (whatever that means). I said, and I quote, "Rust does have a GC". And it does. Saying that it's "opt in" when most Rust programs use it (albeit to a lesser extent than Java or Go programs, provided we don't consider Rust's special case of a single reference to be GC) is misleading. > Rust has a clear purpose. To…

> Except I never called it "a GC language" (whatever that means). I said, and I quote, "Rust does have a GC".

Ok, semantics aside, my point still stands. C also has a GC. See Boehm GC. And before you complain RC is part of std I will point that std is optional and is on track to become a freestanding library.

> Can you accept that your prerequisites and compromises might not be universal

Not the way hardware is moving, which is to say more emphasis on more cores and with no more free lunch from hardware. Regardless of whether it is on-prem or in the cloud, mandatory GC is not a cost you can justify easily anymore.

> As a side note, I'll add that a tracing GC doesn't necessarily have a negative impact on speed, and may even have a positive one

Yeah, but it has a negative impact on memory. As witnessed in the latest RAM crisis, there is no guarantee you can just rely on more memory providing benefits.

> After all, I don't care if my user's credit-card data is stolen due to a UAF or due to SQL injection.

Sure, but those that see fewer UAF errors have more time to deal with logic errors. Of course there are confounding variables such as believing you are king of the world, or that Rust defends you from common mistakes, but overall for similar codebases you see fewer bugs.

Re: Lightpanda migrate DOM implementation to Zig

#123
post #54
post #43

Earlier quoted context omitted.

It has for Amazon, Adobe, Microsoft, Google and the Linux kernel. It remains to be seen which big name will make Zig unavoidable.

> It has for Amazon, Adobe, Microsoft, Google and the Linux kernel. I don't think so. I don't know about Adobe, but it's not a meaningful statement for the rest. Those companies default to writing safe code in languages other than Rust, and the Linux kernel defaults to unsafe code in C. BTW, languages favoured by those projects/companies do not reliably represent industry-wide preferences, let alone defaults. You cou…

I wonder what you consider a successful language.

Rust appeared in 2012. Zig in 2016. I consider them both two successful programming languages, but given they are only 4 years apart, it's easy to compare Zig today with 4-years-back Rust and see they are very far apart, in term of maturity, progress, community size and adoption.

Rust is a very successful language so far, but expecting that in 10y it can overthrow C++ is silly. Codebases add up more than they are replaced.

Re: Lightpanda migrate DOM implementation to Zig

#124

Earlier quoted context omitted.

>>It is a clear mandate on those companies that whatever used to be C or C++, should be written in Rust for green field development. >>Any hobby language author would like to have 1% of the said modest Rust's success, I really don't get the continuous downplay of such achievement. This is a political achievement, not technical one. People are bitter about it as it doesn't feel organic and feel pushed onto them.

There is technical achievement in: > Anyone deploying serverless code into Amazon instances is running of top of Firecracker, my phone has Rust code running on it, and whatever Windows 11 draws something into the screen, it goes through Rust rewrite of the GDI regions logic, all the Azure networking traffic going through Azure Boost cards does so via Rust firmware. Ignoring it doesn't make those achievements politica…

I was referring to mandate to use it at big companies. This is a political achievement. Teams/contributors making their own choice and then shipping good software counts as technical one but that wasn't the main point of the post I replied to.

Re: Lightpanda migrate DOM implementation to Zig

#125
post #122
post #116

Earlier quoted context omitted.

> Calling anything with opt-in reference counting a GC language Except I never called it "a GC language" (whatever that means). I said, and I quote, "Rust does have a GC". And it does. Saying that it's "opt in" when most Rust programs use it (albeit to a lesser extent than Java or Go programs, provided we don't consider Rust's special case of a single reference to be GC) is misleading. > Rust has a clear purpose. To…

> Except I never called it "a GC language" (whatever that means). I said, and I quote, "Rust does have a GC". Ok, semantics aside, my point still stands. C also has a GC. See Boehm GC. And before you complain RC is part of std I will point that std is optional and is on track to become a freestanding library. > Can you accept that your prerequisites and compromises might not be universal Not the way hardware is movin…

> C also has a GC. See Boehm GC. And before you complain RC is part of std I will point that std is optional and is on track to become a freestanding library.

Come on. The majority of Rust programs use the GC. I don't understand why it's important to you to debate this obvious point. Rust has a GC and most Rust programs use it (albeit to a much lesser extent than Java/Python/Go etc.). I don't understand why it's a big deal.

You want to add the caveat that some Rust programs don't use the GC and it's even possible to not use the standard library at all? Fine.

> Not the way hardware is moving, which is to say more emphasis on more cores and with no more free lunch from hardware. Regardless of whether it is on-prem or in the cloud, mandatory GC is not a cost you can justify easily anymore.

This is simply not true. There are and have always been types of software that, for whatever reason, need low-level control over memory usage, but the overall number of such cases has been steadily decreasing over the past decades and is continuing to do so.

> As witnessed in the latest RAM crisis, there is no guarantee you can just rely on more memory providing benefits.

What you say about RAM prices is true, but it still doesn't change the economics of RAM/CPU sufficiently. There is a direct correspondence between how much extra RAM a tracing collector needs and the amount of available CPU (through the allocation rate). Regardless of how memory management is done (even manually), reducing footprint requires using more CPU, so the question isn't "is RAM expensive?" but "what is the relative cost of RAM and CPU when I can exchange one for the other?" The RAM/CPU ratios available in virtually all on-prem or cloud offerings are favourable to tracing algorithms.

If you're interested in the subject, here's an interesting keynote from the last International Symposium on Memory Management (ISMM): https://youtu.be/mLNFVNXbw7I

> Sure, but those that see fewer UAF errors have more time to deal with logic errors.

I think that's a valid argument, but so is mine. If we knew the best path to software correctness, we'd all be doing it.

> Of course there are confounding variables such as believing you are king of the world, or that Rust defends you from common mistakes, but overall for similar codebases you see fewer bugs.

I understand that's something you believe, but it's not supported empirically, and as someone who's been deep in the software correctness and formal verification world for many, many years, I can tell you that it's clear we don't know what the "right" approach is (or even that there is one right approach) and that very little is obvious. Things that we thought were obvious turned out to be wrong.

It's certainly reasonable to believe that the Rust approach leads to more correctness than the Zig approach, and some believe that, and it's equally reasonable to believe that the Zig approach leads to more correctness than the Rust approach, and some people believe that. It's also reasonable to believe that a different approaches is better for correctness in different circumstances. We just don't know, and there are reasonable justifications in both directions. So until we know, different people will make different choices, based on their own good reasons, and maybe at some point in the future we'll be able to have some empirical data that gives us something more grounded in fact.

Re: Lightpanda migrate DOM implementation to Zig

#126
post #88
post #27

Earlier quoted context omitted.

The fact that Zig doesn't have Rust's guarantees doesn't mean Zig does not have safety checks. The safety checks that Zig does have are different , and are different in a way that's uniquely useful for this particular project. Zig's check absolutely don't go to the extent that Rust's do, which is kind of the point here. If you do need to go beyond safe code in Rust, Zig is safer than unsafe code in Rust. Saying Zig l…

I never said Zig has no safety features. What I said is true, though. If it would have Rusts guarantees (as in: The same) it would be more complex.

I mean if we're going to nitpick:

>>> its lack of safety checks

>> Saying Zig lacks safety checks is unfortunate,

> I never said Zig has no safety features.

You did. Or, alternatively, if you don't equate "checks" with "features", then I never said you said that so what are you complaining about?

> If it would have Rusts guarantees (as in: The same) it would be more complex.

Which is true (if tautological), and is basically what the GP said:

> Zig's manual memory management might actually be more ergonomic for a DOM implementation specifically because you can model the graph relationships more directly without fighting the compiler, provided you have a robust strategy for the arena allocation

Both you and the GP agree that Rust is more complex.

You objected to this with:

> It's unfortunate that "writing safe code" is constantly being phrased in this way.

Upon which I commented that Zig does have safety features, even if they're not covering you as well as Rust's ones. Which is, again, inline with "provided you have a robust strategy for the arena allocation."

Now, if you think I'm going overboard with this, I agree with you -- and this is the exact feeling I have when I look at Rust :)

Re: Lightpanda migrate DOM implementation to Zig

#127

Earlier quoted context omitted.

Yeah that's certainly possible but leaking a pointer like this seems like it would be really easy to spot?

It's harder than you'd expect. Depending on what kind of bucketing an arena does (by size or by type), a stale reference may end up pointing to another piece of memory of the correct type, which is still wrong, but more subtly than a crash.

Look at the architecture of lightpanda and come back with a response.

Re: Lightpanda migrate DOM implementation to Zig

#128
post #102
post #72

Earlier quoted context omitted.

It is a clear mandate on those companies that whatever used to be C or C++, should be written in Rust for green field development. Whatever could be done in programming languages with automatic memory management was already being done. Anyone deploying serverless code into Amazon instances is running of top of Firecracker, my phone has Rust code running on it, and whatever Windows 11 draws something into the screen,…

> It is a clear mandate on those companies that whatever used to be C or C++, should be written in Rust for green field development. Whatever could be done in programming languages with automatic memory management was already being done. I don't know how true either of these statements is or to what extent the mandate is enforced (at my company we also have language mandates, but what they mean is that to use a diffe…

P.S.

I spoke with someone at AWS, and he says that there is an investment in using Rust for low-level code, but there is no company-wide mandate, and projects are free to pick C or C++.

Re: Lightpanda migrate DOM implementation to Zig

#129
post #121
post #84

Earlier quoted context omitted.

> Not really modern, it is Object Pascal/Modula-2 repackaged in C like syntax. That's your opinion, but I couldn't disagree more. It places partial evaluation as its biggest focus more so than any other language in history, and is also extraordinarily focused on tooling. There isn't any piece of information nor any technique that was known to the designers of those older languages and wasn't known to Zig's designer.…

> You certainly don't have to agree with my assessment, but you do need to acknowledge that some people very much see it that way, and don't think it's merely a "repackaged" Pascal-family language in any way. My opinion is that 99% of those people never knew anything beyond C and C++ for systems programming, and even believe the urban myth that before C there were no systems programming languages. Similar to those th…

I don't know about the numbers. Some of Zig's famous proponents are Rust experts. I don't know the specific percentages, but you could level a similar accusation at Rust's proponents, too, i.e. that they have insufficient exposure to alternative techniques. And BTW, Zig's approach is completely different from that of C, C++, Rust, or the Pascal family languages. So if we were to go by percentages, we could dismiss all criticisms against Zig on the same basis (i.e. most people may think it's like C++, or C, or Modula, but since it isn't, then their criticisms are irrelevant). In fact, because Rust is a fairly old language and Zig isn't, it's more likely that more Zig developers are familiar with Rust than vice-versa.

But also I don't see why that even matters. If even some people with a lot of experience in other approaches to systems programming and even with experience with deeper aspects of software correctness accept this assessment, then you can't waive it away. It's okay to think we're wrong - after all no one has the sufficient empirical evidence to support their claim either way - but you cannot ignore the fact that some of those with extensive experience disagree with you, just as I'm happy to accept that some of them disagree with me.

Re: Lightpanda migrate DOM implementation to Zig

#130

Earlier quoted context omitted.

It's harder than you'd expect. Depending on what kind of bucketing an arena does (by size or by type), a stale reference may end up pointing to another piece of memory of the correct type, which is still wrong, but more subtly than a crash.

Look at the architecture of lightpanda and come back with a response.

I'm not familiar enough with Zig to want to dive into architecture, the point I wanted to make is general to arenas in any language that can have a stale reference.

I once had a stale stack reference bug in C that lived for a year, because the exact same object was created at the exact same offset every time it was used, which is a similar situation.

Post reply on HN