Live data from Hacker News

Next C compiler is a D compiler: Introducing DMD's ImportC

briancallahan.net

41–50 of 89 posts

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#41
post #26

What I don't like about LDC, is you have to install the entire Visual Studio if you want a static build [1]. Contrast this with Go, Nim, Rust, Zig and others, that don't put this burden developers. Is DMD any different in this regard? 1. https://github.com/ldc-developers/ldc/issues/4047

DMD doesn't require anything else. Except for Win64, where it needs the VS C runtime library and linker.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#42

Earlier quoted context omitted.

I don't think it's your mistake. It seems HN automatically removes certain leading/trailing words from titles so as to reduce clickbait but it doesn't seem to be very smart about it.

It gets annoying, because in cases like this it doesn't make sense, but in other cases it actually changes the meaning of the title. I honestly don't understand it given the prohibition against submitters changing the title.

More importantly, this change is silent.

I'd be much less annoyed by it if dang finally made it a pre-submit check (maybe with a checkbox "Overrule") like the "too long" check. But no, it seems to be important that the submitter has to check manually whether the title he just typed in is still there.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#43

Earlier quoted context omitted.

Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen ( https://github.com/eqrion/cbindgen ) can help with generation of header files. Static linking is possible as well. Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

I don't think Rust will ever consider FFI'in with another language "100% safe."

You can use C libraries in Rust, even compiled .so files where you dont have the corresponding C headers.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#44
post #4

That's impressive, i thought the preprocessor wasn't planned, looks like it takes care of it too, i guess it's time to revisit D, C but better

My experience with D is always a joyful one. If it isn't because it is a relatively straightforward language to learn then it is learning something new now and then that just makes life to much more easier.

Infact, D was the first language I learnt templating in and I really like it (or rather, the way D goes about it - made it much more approachable for me).

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#45
post #25

Earlier quoted context omitted.

I haven't used Zig, but DMD can compile C projects directly using makefiles or by simply putting the .c files on the dmd command line.

Do you plan on giving Zig a try? (They seem to be doing a lot right.) Taking the opportunity here to point people to "Adding Modules to C in 10 Lines of Code" from NWCPP earlier this year: https://www.youtube.com/watch?v=2ImfbGm0fls > (The pitfalls you mention running into there wrt to different compiler instances is itself a decent case study in not relying on singletons http://www.object-oriented-security.org/lets-…

> Do you plan on giving Zig a try? (They seem to be doing a lot right.)

All this Zig spam is getting very tiring.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#46
post #4

That's impressive, i thought the preprocessor wasn't planned, looks like it takes care of it too, i guess it's time to revisit D, C but better

My experience with D is always a joyful one. If it isn't because it is a relatively straightforward language to learn then it is learning something new now and then that just makes life to much more easier. Infact, D was the first language I learnt templating in and I really like it (or rather, the way D goes about it - made it much more approachable for me).

I wasn't going to add templates to D until I figured out a way to make them simple.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#47

Hello Walter, do you have any advice on integrating Rust and D? Especially regarding GC

Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen ( https://github.com/eqrion/cbindgen ) can help with generation of header files. Static linking is possible as well. Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

> Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely

You can just as easily declare D code to be extern(C) and have rust treat it as a C library.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#48
post #25

Earlier quoted context omitted.

Do you plan on giving Zig a try? (They seem to be doing a lot right.) Taking the opportunity here to point people to "Adding Modules to C in 10 Lines of Code" from NWCPP earlier this year: https://www.youtube.com/watch?v=2ImfbGm0fls > (The pitfalls you mention running into there wrt to different compiler instances is itself a decent case study in not relying on singletons http://www.object-oriented-security.org/lets-…

> Do you plan on giving Zig a try? (They seem to be doing a lot right.) All this Zig spam is getting very tiring.

In a conversation about languages with this kind of C interop, how can you omit Zig?

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#49

Earlier quoted context omitted.

> Do you plan on giving Zig a try? (They seem to be doing a lot right.) All this Zig spam is getting very tiring.

In a conversation about languages with this kind of C interop, how can you omit Zig?

> In a conversation about languages with this kind of C interop

It's not. It's a discussion about "the C compiler built into the Digital Mars D compiler".

Please stop with all the Zig spam.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#50

> Error: C designator-list not supported yet I guess only a subset of C11 is supported? Is there all of C89?

Designator-list support has since been added. The multi-layer designators are still to be done, though (they're rarely used, so are a lower priority).

I think something along those lines (rarely used...) was also given by the C++ Committee as justification why so much of the C99 designated init feature set was left out of C++20, which is a bit of a shame. All C99 designated-init 'sub-features' complement each other nicely once you start using them. It's a great way for building 'data-centric' APIs.

For instance check out this call to create a 3D-API pipeline-state-object in C99:

https://github.com/floooh/sokol-samples/blob/ad9047e228a8441...

Post reply on HN