On Tuesday, 5 December 2017 at 16:06:19 UTC, Mike Parker wrote:
This is the first post in a new tutorial series I'm doing on
the blog.
Hi Mike,
Nice.
It's always much easier to comment than to write an article from
scratch. So take all this with a grain of salt:
Overall I find that it'd be much nicer if you focus on C-D
interaction only. Currently you've added a lot of things that
people really would already know before reading the text: I think
preknowledge should be how to create programs in C and in D
(including compilers, etc.). Especially on a second read, it's a
lot of scrolling back and forth to find the good nuggets of info.
- I would make it clearer that you are discussing calling C code
from a D application. If you are going to discuss the other way
around too, always make it super clear in which language the
"main" part of the program is. Perhaps explain the differences in
how to setup a "hello world" (e.g. druntime initialization).
- I would remove all related to DMC, it's needless extra
complication.
- Add a sentence that all should work identically for GDC and
LDC, except for the `-m32mscoff` (I think `-m32` or `-m64` is
superfluous for LDC).
- The text about "both files have the same name" is also
needless, I think. You are writing a text about how to call
C-code from D-code, using the commandline no less! ;-) Instead,
I would add the output filename explicitly on the cmdlines. It's
short, and more clearly shows which files are created when.
- Commandline invocation and installation of compilers is mixed
now; pull it apart for clarity. Fit the installation of
compilers in one or two sentences (D and C).
- typo: "offical" --> "official"
- The code fragments don't need to be packed tight. Perhaps add
comments inside them, to beef them up a bit and make them stick
out more. (you could add comments about "forward declaration",
"definition", ...)
- Separate the hello world example into its own section: "see how
easy it is?" :-)
Ideas:
- Idea for future texts: how to set this up using dub, and other
build mechanisms like cmake, makefile, IDEs, ...
- Perhaps an example of why one might want this, external
libraries is what I am thinking. Forward reference to future blog
article? (dstep?)
Cheers,
Johan