Hello, folks! Newbie to D, have some questions!

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 20 07:14:16 PST 2017


timmyjose wrote:

> Very interesting reading about your experiences!
tnx. ;-)

> one thing I've observed is that so far (very very early of course) D 
> appears to be a lot more intuitive than C++
yeah. i almost finished writing my own nntp/email client (actually, i'm 
writing this post with it). something i wanted to do for almost a 
decade, but never dared with C/C++. and did that in a week with D. ;-)


> Just one question about the compilers though - I read on the Wiki 
> that there are three main compiler distros - dmd, ldc, and gdc. I 
> code primarily on a mac, and I have installed both dmd and ldc. A lot 
> of the flags appears to be similar, and for my small programs, 
> compilation and execution speed appeared to be almost identical. 
> However, the book suggested using dmd for dev and probably ldc/gdc 
> for releases. Is this really followed that much in practice, or 
> should I prefer dmd?
i myself is using dmd for everything. usually i found that even without 
-O (it means "optimize code" for dmd) my apps are fast enough. even my 
Speccy emulator is perfectly fine without -O (mind you, it emulates the 
whole 8-bit machine: CPU, FDD, sound processor, etc., and has to keep 
constant 50FPS to make sound smooth). that is, if you are doing heavy 
number crunching, for example, you may want to use ldc. otherwise, 
stick with dmd: i found that my code spending most of it's time waiting 
for some i/o completion. ;-)


> One more thing I noticed when I looked into the executable file 
> (using "nm -gU" on my mac) is that I found two interesting symbols - 
> _main and _Dmain. On Rust, for instance, the main function got turned 
> into _main, so I couldn't use a main in the C code that I was trying 
> to interop with from my Rust code. In this case, does the same 
> restriction apply (I am still way too far from dabbling in interop in 
> D as yet! :-)). I mean, suppose I write some sample code in C, and I 
> have a local main function to test the code out locally, will I have 
> to comment that out when invoking that library from D, or can I keep 
> that as is?
as your library will prolly not have "main()" (and will be built as a 
lib), there should be no problems. i.e. i never had any troubles with 
symbols with my .so and .a libs (all two of them ;-). i also wrote .so 
injection code (injecting .so written in D into running process), and 
had no problems with that too.


More information about the Digitalmars-d-learn mailing list