by WalterBright · 2y ago · 0 comments
dmd hello.c
./hello
hello world
This helps enormously in binding to existing C libraries.What conclusion should we draw about Aro based on what you’re saying?
The post title is "Aro, Zig's new C compiler", not just about Aro or Zig. In fact, just by virtue of being about Aro, it is also about C compilers - as the title clearly says, whether you (pedantically) like it or not. And D is a language that is used as a better C too, apart from other things. In fact, lang C -> lang D, says something significant to this discussion, right?
>Could you draw a comparison for those who came here for Zig and not D?
Sigh.
More pedantic talk.
Shall we start drawing Venn diagrams to clarify things?
Is it not possible that there can be different groups of people, some of whom are interested in Zig, others in Zig and Aro, others in C compilers generally, and others in D with some of those groups overlapping? That's what Venn diagrams are meant to show.
Generally speaking, the more you stray from the most concrete topic at hand (in this case Aro and only Aro), the more it becomes appropriate to explain and elaborate on the relation between that and whatever you've decided to talk about instead. In my view, anyway.
how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind.
I can't waste my time explaining things multiple times to different people who don't get it, when others have got it.
maybe check my answers to the other people in this subthread, if you are that interested, for what is such a trivially obvious matter.
good luck.
D would deserve attention too, in a separate post, or here if it was explained how it relates to Aro.
For me, I appreciate the perspective and opinions of someone else in the industry with proven results. D is a major language, you can't deny that.
Maybe this post he should have went into a little more detail but I do not think he posted this with ill intent.
If anything I'm sure he would love to continue a dialog about the design decisions that led him to implement the same feature - and maybe this was his way of starting the conversation.
Given that he is a 15 year member of our community, and has earned 70k karma, we should give him the benefit of the doubt.
The last sentence, or, indeed, the whole comment, can be read like "We did this for D, and it works well. [go for it]".
I don't think D is casting any shadow on Zig. Both languages play in the same field, D is older but I feel like we hear about Zig way more these days.
His comment is likely to interest people interested in Zig or PLs in general.
The comment as is might lack some finesse but I don't think it deserves this level of aggressiveness.
no, it is not. in the fine tradition of hn, let me reply by saying, "that's like, just your opinion, man". which is not worth more than any other people's opinion on this site. maybe worth less.
e.g.:
>D would deserve attention too if ...
so now you are telling everyone what deserves attention?
then what have you done to deserve attention yourself (to your comments, that is)?
walter has done plenty. he created the D language, and still maintains it, along with others, like, you know, Andrei, for one. Google who that is.
Google about Walter to know what other stuff he has done before, like you know, the Zortech C++ compiler.
Last I tried, I found some compiler options and commands to do it, but they were badly explained, I tried for hours and it just didn't work at all, so I gave up.
I am currently adding AArch64 support to DMD's code generator. dmd doesn't run on my Raspberry Pi (yet!), so I use sshfs to access the Pi's filesystem from Ubuntu, compile programs on Ubuntu, transfer the .o file to the Pi, link it on the Pi, and run it on the Pi.
I'm sorry you're having trouble with this, so I recommend posting on the D forums, and people are there to help!
As far as I can tell, D's DMD can cross compile but not link. I probably missed that before (actually, I think I was trying with LDC, I found the page where they document the process while searching for it just now: https://wiki.dlang.org/Cross-compiling_with_LDC if you try those options, nothing works, at least from MacOS).
I just tried and this only works with the -c option (compile, but not link):
dmd -os=linux -c source/app.d
Without `-c`:``` Error: linker exited with status 1 cc app.o -o app -m64 -Xlinker -no_compact_unwind -L/Users/me/dlang/dmd-2.109.1/osx/bin/../lib -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm (dmd-2.109.1) ```
I am sure Walter knows how to compile on one machine, then go to another machine and do the linking or whatever is needed. I know nothing about those, but with Zig I need not know anything other than which flag to use to cross compile. It's a huge difference. D should do that, otherwise it's just not competitive for people like me (I am just an average joe programmer who knows how to write code but has very little interest in learning how linkers work).
Zig is notable for putting a lot of work into hard-coding basic C libraries, though of course you still need a scattering of other C libraries for most real-world programs.
(for a sufficiently advanced language ecosystem, the language's own libraries should be easy enough)
- get a suitable cross compiler toolchain
- pick whether you want dynamic or static linking (most likely static when the target system does not come with /nix/store)
- compile all prerequisites for the library such as transitive dependencies
- compile the library with the cross compiler for the selected target arch
All in one command line call, that does not require you to 'apt-get install' any of the tools manually:
nix-build '<nixpkgs>' -A pkgsStatic.libpng --arg crossSystem '{ config = "armv7a-unknown-linux-gnueabihf"; }'What I need to work reliably from C++ are 1. instantiation of imported templates, ideally including CRTP, and 2. handling in D of exceptions thrown from C++, because if I use a C++ library that throws, I need to be able to handle the exception.
So far I’ve found languages that can import template classes and functions from C++ (usually by extending LLVM/Clang), but no languages that have good, reliable cross-platform C++ exception handling.