Live data from Hacker News

Zig's Incremental Compilation Internals

mlugg.co.uk

291–292 of 292 posts

Re: Zig's Incremental Compilation Internals

#291
post #289

Earlier quoted context omitted.

> the zunsafe api is basically unused. One library uses it (OpenSSL) for good reasons Wait, so there are escape hatches? But… you’ve repeatedly said, many times, that there are zero escape hatches? And now here you’re saying not only that there only are escape hatches, but there’s a good reason to use them? Damn. Misrepresenting `unsafe{}` whilst saying your language is better because there are no escape hatches and…

From the second paragraph of fil-c.org: "Fil-C has no unsafe statement and only limited FFI to unsafe code." `zunsafe_call` is a weird thing to get hung up on as an "escape hatch", considering it's just a super limited form of FFI, intentionally designed so that it's only usable for OpenSSL's use case. > Misrepresenting `unsafe{}` `unsafe` lets you write Rust code that violates any reasonable definition of memory saf…

> Unlike other approaches to increasing the safety of C, Fil-C achieves complete memory safety with zero escape hatches.

Except there is an escape hatch, by your own admission above?

> `zunsafe_call` is a weird thing to get hung up on as an "escape hatch"

from the docs:

> unsigned long zunsafe_call(const char* symbol_name, ...);

> Performs an unsafe call to Yolo-land.

That’s just a `unsafe{ func(…) }` escape hatch

> intentionally designed so that it's only usable for OpenSSL's use case.

Cool motive, still an escape-hatch =)

Do you have the backbone to update the fil-c website to correct the record, and let the person you retweeted here[1] know that the escape hatch row is incorrect?

Or… is what everyone says about you here true?

1. https://x.com/filpizlo/status/2081765923757903940

Re: Zig's Incremental Compilation Internals

#292
post #257

Earlier quoted context omitted.

With FFM you can do unsafe things, such as call native code and directly manipulate memory read from or written to by native code.

Eh, I don't really count FFM. Would you have said JNI before Java 22? FFM is little more than a convenient wrapper around the same that can be dome with JNI.

Yes, I would have said JNI (and JNI still exists). But FFM is much more than a wrapper. In most situations it offers a significant performance boost over JNI. E.g. see https://github.com/Glavo/java-ffi-benchmark, which is a bit out of date, and FFM is even better now especially in the cases it was behind in those benchmarks.

Also, the integrity story is different for them. JNI is able to arbitrarily call Java methods and read/write variables, bypassing Java's access control. FFM doesn't. So really, the only integrity issue with FFM is the native code's own memory safety. With JNI, there are bigger risks (e.g. JNI can mutate Java strings).

Post reply on HN