News for hackers. Stuff that matters.
Re:Why Zig when there is already C++, D, and Rust? by exyi on Saturday January 16, 2021 @05:27AM (#25801376)
This seems like unsolvable problem - if you'd want to allow calling C macros from your new language, you would have to be C superset. So no memory/thread/... safety, weird syntax inherited from C, ...
Re:Why Zig when there is already C++, D, and Rust? by skohan on Saturday January 16, 2021 @06:01AM (#25801503)
This was one of the most redeeming things about Objective-C. It is a superset of C, and when I was working with it, I found myself writing the high-level stuff in ObjC, but with a lot of pure-C functions sprinkled in. It was really nice for working with C libraries like OpenGL, because you could find an example online and directly apply it without going through any kind of translation step. It was a really cool feature to have.
Re:Why Zig when there is already C++, D, and Rust? by pjmlp on Saturday January 16, 2021 @04:09PM (#25805534)
I share a similar experience with C++.

However that compatibility is also what makes Objective-C and C++ impossible to ever be fully safe, without breaking compatibility with the C subset.

Static analysis help, but only when all code is available.

Re:Why Zig when there is already C++, D, and Rust? by beagle3 on Saturday January 16, 2021 @07:43AM (#25801873)
It isn’t so black and white.

Nim, if you let it use C as a backend, will let you use C macros, despite being generally safe and not remotely a C superset.

Yes, the use of C macros (and any kind of ffi) is unsafe, that cannot be avoided. But it doesn’t need to be a c superset (and indeed, when you use JS as a backend, or the native LLVM backend, you get no access to C macros)

Re:Why Zig when there is already C++, D, and Rust? by rcxdude on Saturday January 16, 2021 @05:36AM (#25801414)
It's probably impossible in general, but you could probably deal with a bunch of common cases fairly easily (like constants)