![]() |
|
![]() |
| > remove libclang
So `zig cc` will have to go as well ? I was under the impression Zig as a drop-in C (cross-)compiler was one of its main selling points. |
![]() |
| Wow, that actually makes me want to look into zig a lot more. so many projects, rust included, get bogged down in design by committee and half baked decisions that please no one. |
![]() |
| Agreed. Andrew Kelley's ability to have, communicate and maintain a clear and consistent vision is one of the most refreshing things about Zig. I don't actually use it, but this might actually be the main thing attracting me to it.
Plenty has already been said about design-by-committee and relying overmuch on user feedback, but one thing that doesn't get mentioned as often is that this approach tends to transform additive bias[1] from a cognitive bias into an iron law. Once you let that happen, you're on a relatively short and slippery slope to having a kitchen sink language. And one refreshing thing about Zig is that's it's clearly working very hard at not becoming a kitchen sink language. I'm not sure I can say the same about most other newer systems programming languages. That doesn't mean having a BDFL is all kittens and rainbows, and I'm sure Andrew has made plenty of mistakes. But I've also never seen any indication that he's acted out of anything other than good faith. That last paragraph is possibly the closest I've ever seen to him saying something arrogant, and I see it as the exception that proves the rule. Finding such a tactful way to remind people that this is a BDFL project and he's the BDFL could not have been easy, and I imagine he put a lot of care into crafting that paragraph. 1: https://www.scientificamerican.com/article/our-brain-typical... |
![]() |
| > as someone who loves C and dislikes almost every implementation of C interop and FFI I’ve used in other languages (Rust is a notable exception to this),
Have you tried D? It can import C files as if they were D modules: https://dlang.org/spec/importc.html Basically, if there's a `hello.c` file next to your D file, you simply import it with:
And use the functions it provides. You can also import only a subset of it, of course:
Or rename the import:
The C stdlib is exposed by D's stdlib as if it were a D library: https://dlang.org/phobos/core_stdc_assert_.htmlC libraries (header files) can be compiled to D and then used as D modules as well, see https://github.com/jacob-carlborg/dstep Is that as good as Rust? |
![]() |
| This sounds amazing, and it's great that tooling is so strong of some "new kids on the block" (Zig, Rust), even better than C.
With hindsight, it is strange that the C community, with all the people and money behind it (and what scale!) never even managed to build a proper packaging manager (okay, there's now Conan, but that came from Python guys). But then, there even still isn't a perfect C string library around (something that would combine GLib, SDS, ICU, say, and then standardize it in C2038). [1] Hanson's C: Interfaces & Implementations (CII) - Str: https://cii.s3.amazonaws.com/book/pdf/quickref.pdf [2] ICU - https://icu.unicode.org [3] SDS - https://github.com/antirez/sds [4] GLib - https://docs.gtk.org/glib/struct.String.html |
![]() |
| > For example, the recommended way to start a project, with `zig init`, has a load of code that I really don't need when I just want a bare project to get started.
I recently started a new project. zig-init provides you with a working build.zig file and two very minimal project files under /src, one of which is a hello world binary and the other is a hello world library. > Also I've had a lot of issues getting editor integration to work correctly. ZLS is not at the same level of what you would expect from a more mature language. For example by default it will not help you with anything related to comptime. I highly recommend reading this fairly recent blog post by Loris Cro: https://kristoff.it/blog/improving-your-zls-experience/ It explains how you set up your build.zig and ZLS (a few lines of configuration) in order to get much more help from ZLS. It will then perform the equivalent of what `cargo check` (Rust) does. |
![]() |
| Tbf, when coming from the C/C++ ecosystem, these types of problems are 'just another Tuesday' (especially for cross-platform projects and the official VSCode C/C++ extension). |
![]() |
| According to the extension, ZLS is optional, but according to some zig docs I found, its part of the extension. I may have misread, I'll try this stuff again sometime |
![]() |
| Reflection proposals have been around at least since 2014, so I'd say it's exactly right to say that C++ fears it — otherwise it'd have arrived much sooner. |
![]() |
| It adds 65536 pointers to the binary. Alternative would be to use a hash map. I think if they made function that used inline for instead it would optimize to a switch. No need for a LUT.
godbolt: https://zig.godbolt.org/z/7b73aoosfIn zig-budoux, I also do comptime reflection on cImport struct to assert compile time that we won't produce broken runtime code https://github.com/Cloudef/zig-budoux/blob/master/src/c.zig#... |
![]() |
| Those function definitions really look amazingly readable. I've seen this done before in other languages and its usually quite horrible. Maybe Zig is worth learning? This is a killer feature. |
![]() |
| Thank Apple for Reader View in Safari. If you are as incompetent in visual design as the author of that page, you should really stay away from dark mode. Your readers will thank you. |
Do we know if this means the Reflection as mentioned in the article via @typeInfo will no longer work? or was it anyway comptime info? My Zig so far has been SoC level stuff, but using something like raylib or glfw is somewhere on my todo list, and this example sounds mighty useful. Anyway seems a strange thing to remove when Zig has the potential to be the new C. Hopefully also as stable for the next 30 years :)