www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Questions regarding D

reply William Newbery <wnewbery hotmail.co.uk> writes:
I use c++ extensivly, however I find several shortcoming of c++ highly
annoying, and it looks as if D addresses most of these problems for me, however
I'm not certain on certain points as Ive either been unable to find any good
info, or the info I found was very out of date.

1)IDE support: Is there a Visual Studio 2008 plugin avaible for programming D?
If not are there any windows IDE's for D that are at least comparable to VS (ie
built in debugger, good autocompletion, can go straight to where something was
defined/declared, etc)?

2)Garbage Collection: Can the garbage collector just be removed from projects
or be completly replaced by a diffrent form of garbage collection, eg refrence
counting?

3)Compatibility between D compilers: Does the D standard enforce binary
compatibility between compilers. Eg if I compiled a libary with the DMD
compiler and gave the static lib to someone that uses some other D compiler,
will they be able to use my lib without any problems?

4)Support for directX: Specificaly I need to  be able to use d3d9, d3dx9,
d3d10, d3dx10 and xAudio2.

5)Support for classes in dynamic libaries, and the ability to dynamicaly load
these libaries.
Jan 14 2009
next sibling parent BCS <ao pathlink.com> writes:
Reply to William,

 I use c++ extensivly, however I find several shortcoming of c++ highly
 annoying, and it looks as if D addresses most of these problems for
 me, however I'm not certain on certain points as Ive either been
 unable to find any good info, or the info I found was very out of
 date.
 
 1)IDE support: Is there a Visual Studio 2008 plugin avaible for
 programming D? If not are there any windows IDE's for D that are at
 least comparable to VS (ie built in debugger, good autocompletion, can
 go straight to where something was defined/declared, etc)?
 
The best IDE for D is the Descent plugin for eclipse. It is in development so it's not as god as VS. Regarding debuggers, last I checked there were a few windows debuggers but I've never been a big fan of any thing other then the VS debugger and then to some extent, not even that.
 2)Garbage Collection: Can the garbage collector just be removed from
 projects or be completly replaced by a diffrent form of garbage
 collection, eg refrence counting?
 
The GC is plugable, IIRC Tango and Phobos have different GCs. If you are willing to avoid a number of constructs (AA's, the ~ operator, using .length) you can turn off the GC and get by with manual memory management. This is not recommended in most cases. OTOH for embedded systems and that sort of thing it is possible.
 3)Compatibility between D compilers: Does the D standard enforce
 binary compatibility between compilers. Eg if I compiled a libary with
 the DMD compiler and gave the static lib to someone that uses some
 other D compiler, will they be able to use my lib without any
 problems?
At this time there is only DMD, gdc, and an LLVM based compiler. On Linux DMD and gdc should work together (them might be some issues regarding different versions of the standard lib so don't take that as gospel). On windows, I seem to recall that gdc doesn't work well so it's not really an issue. as for the LLVM thing I don't know.
 
 4)Support for directX: Specificaly I need to  be able to use d3d9,
 d3dx9, d3d10, d3dx10 and xAudio2.
 
I think they work, I know someone who was playing with them. In general, any C lib can be used assuming you can get stuff to link (There ares some tools for this but I've never been forced to use them).
 5)Support for classes in dynamic libaries, and the ability to
 dynamicaly load these libaries.
 
D supports DLLs (for the most part, there are some issues you would need to be aware of but last I head there were no roadblocks) but doesn't have any special devices for that. I've never used them.
Jan 14 2009
prev sibling next sibling parent reply "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Wed, Jan 14, 2009 at 2:58 PM, William Newbery <wnewbery hotmail.co.uk> wrote:

 4)Support for directX: Specificaly I need to  be able to use d3d9, d3dx9,
d3d10, d3dx10 and xAudio2.
It's entirely possible. D natively supports COM interfaces and the Windows calling convention, so it's really just a matter of porting the headers from C++. There are ports of DirectX 9 and possibly 8 (though that doesn't help you..) headers already. The other small hurdle is linking against the DirectX DLLs - thankfully MS has put D3DX in a DLL of its own and you no longer have to deal with the static linking BS that used to be necessary. More or less it's a matter of just using implib (comes with DMC, I think, or DMD) on the DLL with the /system flag and including the .def file it generates on the command line when you compile/link your program. I don't think anyone's taken a shot at porting the DX10 headers, so you'd be on your own there.
 5)Support for classes in dynamic libaries, and the ability to dynamicaly load
these libaries.
You're on Windows, so no. Well, for the most part, no. SOs on Linux work perfectly. DLLs on Windows are not sufficient for what D needs to do proper dynamic linking. Namely, there are issues with TypeInfo - the runtime type information that the D runtime uses to perform all sorts of useful things, like throwing exceptions and sorting arrays and doing downcasts. What ends up happening is that the RTTI is duplicated in both the EXE and the DLL, and the runtime does no stitching up or removing of redundancy in those situations, leading to.. odd behavior. The GC and DLLs also have strange interactions - it's entirely possible to set up the GC to collect data inside the DLL, but unloading the DLL sometimes results in a segfault for reasons behind my understanding. You do have options. DDL is a project which aims to perform dynamic linking on Windows, and it works damn well. It also has a lot of useful utility functions to i.e. look up symbols and types by name in the dynamic library. There's also another project unrelated to D called EDLL which more or less does the same things that DDL does; I don't know if anyone has successfully used it with D.
Jan 14 2009
next sibling parent reply William Newbery <wnewbery hotmail.co.uk> writes:
Jarrett Billingsley Wrote:

 On Wed, Jan 14, 2009 at 2:58 PM, William Newbery <wnewbery hotmail.co.uk>
wrote:
 5)Support for classes in dynamic libaries, and the ability to dynamicaly load
these libaries.
You're on Windows, so no. Well, for the most part, no. SOs on Linux work perfectly. DLLs on Windows are not sufficient for what D needs to do proper dynamic linking. Namely, there are issues with TypeInfo - the runtime type information that the D runtime uses to perform all sorts of useful things, like throwing exceptions and sorting arrays and doing downcasts. What ends up happening is that the RTTI is duplicated in both the EXE and the DLL, and the runtime does no stitching up or removing of redundancy in those situations, leading to.. odd behavior. The GC and DLLs also have strange interactions - it's entirely possible to set up the GC to collect data inside the DLL, but unloading the DLL sometimes results in a segfault for reasons behind my understanding. You do have options. DDL is a project which aims to perform dynamic linking on Windows, and it works damn well. It also has a lot of useful utility functions to i.e. look up symbols and types by name in the dynamic library. There's also another project unrelated to D called EDLL which more or less does the same things that DDL does; I don't know if anyone has successfully used it with D.
Is there some way around this, I dont really care if D needs to use its own dynamic libary format rather than the windows dll, I just want some external file that D can load and execute (ie it doesnt need to be able to contain resources, or have its own HINSTANCE, or any of the other things dlls can have beyond simply containing classes, functions, etc), and they dont have to be compatible with anything outside of D at all.
Jan 14 2009
next sibling parent Bill Baxter <wbaxter gmail.com> writes:
On Thu, Jan 15, 2009 at 7:35 AM, William Newbery <wnewbery hotmail.co.uk> w=
rote:
 Jarrett Billingsley Wrote:

 On Wed, Jan 14, 2009 at 2:58 PM, William Newbery <wnewbery hotmail.co.uk=
wrote:
 5)Support for classes in dynamic libaries, and the ability to dynamica=
ly load these libaries.
 You're on Windows, so no.  Well, for the most part, no.  SOs on Linux
 work perfectly.  DLLs on Windows are not sufficient for what D needs
 to do proper dynamic linking.  Namely, there are issues with TypeInfo
 - the runtime type information that the D runtime uses to perform all
 sorts of useful things, like throwing exceptions and sorting arrays
 and doing downcasts.  What ends up happening is that the RTTI is
 duplicated in both the EXE and the DLL, and the runtime does no
 stitching up or removing of redundancy in those situations, leading
 to.. odd behavior.  The GC and DLLs also have strange interactions -
 it's entirely possible to set up the GC to collect data inside the
 DLL, but unloading the DLL sometimes results in a segfault for reasons
 behind my understanding.

 You do have options.  DDL is a project which aims to perform dynamic
 linking on Windows, and it works damn well.  It also has a lot of
 useful utility functions to i.e. look up symbols and types by name in
 the dynamic library.  There's also another project unrelated to D
 called EDLL which more or less does the same things that DDL does; I
 don't know if anyone has successfully used it with D.
Is there some way around this, I dont really care if D needs to use its o=
wn dynamic libary format rather than the windows dll, I just want some exte= rnal file that D can load and execute (ie it doesnt need to be able to cont= ain resources, or have its own HINSTANCE, or any of the other things dlls c= an have beyond simply containing classes, functions, etc), and they dont ha= ve to be compatible with anything outside of D at all. Yes DDL is exactly that way to work around it. See this very interesting presentation about it here: http://petermodzelewski.blogspot.com/2008/11/tango-conference-2008-ddl-talk= .html --bb
Jan 14 2009
prev sibling parent reply "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Wed, Jan 14, 2009 at 5:35 PM, William Newbery <wnewbery hotmail.co.uk> wrote:
 You do have options.  DDL is a project which aims to perform dynamic
 linking on Windows, and it works damn well.  It also has a lot of
 useful utility functions to i.e. look up symbols and types by name in
 the dynamic library.  There's also another project unrelated to D
 called EDLL which more or less does the same things that DDL does; I
 don't know if anyone has successfully used it with D.
Is there some way around this, I dont really care if D needs to use its own dynamic libary format rather than the windows dll, I just want some external file that D can load and execute (ie it doesnt need to be able to contain resources, or have its own HINSTANCE, or any of the other things dlls can have beyond simply containing classes, functions, etc), and they dont have to be compatible with anything outside of D at all.
..yeah, I said DDL and EDLL.
Jan 14 2009
parent William Newbery <wnewbery hotmail.co.uk> writes:
Jarrett Billingsley Wrote:

 On Wed, Jan 14, 2009 at 5:35 PM, William Newbery <wnewbery hotmail.co.uk>
wrote:
 You do have options.  DDL is a project which aims to perform dynamic
 linking on Windows, and it works damn well.  It also has a lot of
 useful utility functions to i.e. look up symbols and types by name in
 the dynamic library.  There's also another project unrelated to D
 called EDLL which more or less does the same things that DDL does; I
 don't know if anyone has successfully used it with D.
Is there some way around this, I dont really care if D needs to use its own dynamic libary format rather than the windows dll, I just want some external file that D can load and execute (ie it doesnt need to be able to contain resources, or have its own HINSTANCE, or any of the other things dlls can have beyond simply containing classes, functions, etc), and they dont have to be compatible with anything outside of D at all.
..yeah, I said DDL and EDLL.
Sorry, the way I read it I thought you meant they were just libaries that tried to make windows dlls more easy to work with, such as ensureing there was only one gc running, and merging the RTTI if its duplicated, etc.
Jan 15 2009
prev sibling parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Thu, 15 Jan 2009 00:17:30 +0300, Jarrett Billingsley
<jarrett.billingsley gmail.com> wrote:

 On Wed, Jan 14, 2009 at 2:58 PM, William Newbery  
 <wnewbery hotmail.co.uk> wrote:

 4)Support for directX: Specificaly I need to  be able to use d3d9,  
 d3dx9, d3d10, d3dx10 and xAudio2.
It's entirely possible. D natively supports COM interfaces and the Windows calling convention, so it's really just a matter of porting the headers from C++. There are ports of DirectX 9 and possibly 8 (though that doesn't help you..) headers already. The other small hurdle is linking against the DirectX DLLs - thankfully MS has put D3DX in a DLL of its own and you no longer have to deal with the static linking BS that used to be necessary. More or less it's a matter of just using implib (comes with DMC, I think, or DMD) on the DLL with the /system flag and including the .def file it generates on the command line when you compile/link your program. I don't think anyone's taken a shot at porting the DX10 headers, so you'd be on your own there.
DX10 headers have been ported long ago: http://dsource.org/projects/bindings/browser/trunk/win32/directx
 5)Support for classes in dynamic libaries, and the ability to  
 dynamicaly load these libaries.
You're on Windows, so no. Well, for the most part, no. SOs on Linux work perfectly. DLLs on Windows are not sufficient for what D needs to do proper dynamic linking. Namely, there are issues with TypeInfo - the runtime type information that the D runtime uses to perform all sorts of useful things, like throwing exceptions and sorting arrays and doing downcasts. What ends up happening is that the RTTI is duplicated in both the EXE and the DLL, and the runtime does no stitching up or removing of redundancy in those situations, leading to.. odd behavior. The GC and DLLs also have strange interactions - it's entirely possible to set up the GC to collect data inside the DLL, but unloading the DLL sometimes results in a segfault for reasons behind my understanding. You do have options. DDL is a project which aims to perform dynamic linking on Windows, and it works damn well. It also has a lot of useful utility functions to i.e. look up symbols and types by name in the dynamic library. There's also another project unrelated to D called EDLL which more or less does the same things that DDL does; I don't know if anyone has successfully used it with D.
Jan 15 2009
next sibling parent Bill Baxter <wbaxter gmail.com> writes:
On Thu, Jan 15, 2009 at 5:58 PM, Denis Koroskin <2korden gmail.com> wrote:
 On Thu, 15 Jan 2009 00:17:30 +0300, Jarrett Billingsley
 <jarrett.billingsley gmail.com> wrote:

 On Wed, Jan 14, 2009 at 2:58 PM, William Newbery <wnewbery hotmail.co.uk>
 wrote:

 4)Support for directX: Specificaly I need to  be able to use d3d9, d3dx9,
 d3d10, d3dx10 and xAudio2.
It's entirely possible. D natively supports COM interfaces and the Windows calling convention, so it's really just a matter of porting the headers from C++. There are ports of DirectX 9 and possibly 8 (though that doesn't help you..) headers already. The other small hurdle is linking against the DirectX DLLs - thankfully MS has put D3DX in a DLL of its own and you no longer have to deal with the static linking BS that used to be necessary. More or less it's a matter of just using implib (comes with DMC, I think, or DMD) on the DLL with the /system flag and including the .def file it generates on the command line when you compile/link your program. I don't think anyone's taken a shot at porting the DX10 headers, so you'd be on your own there.
DX10 headers have been ported long ago: http://dsource.org/projects/bindings/browser/trunk/win32/directx
Nifty. Are there any samples anywhere? I'd like to play around with DX10 some on my new vista laptop. And here I was thinking I'd have to do it in C++. --bb
Jan 15 2009
prev sibling parent "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Thu, Jan 15, 2009 at 3:58 AM, Denis Koroskin <2korden gmail.com> wrote:
 DX10 headers have been ported long ago:
 http://dsource.org/projects/bindings/browser/trunk/win32/directx
Well awesome!
Jan 15 2009
prev sibling parent "Denis Koroskin" <2korden gmail.com> writes:
On Wed, 14 Jan 2009 22:58:55 +0300, William Newbery <wnewbery hotmail.co.uk>
wrote:

 I use c++ extensivly, however I find several shortcoming of c++ highly  
 annoying, and it looks as if D addresses most of these problems for me,  
 however I'm not certain on certain points as Ive either been unable to  
 find any good info, or the info I found was very out of date.

 1)IDE support: Is there a Visual Studio 2008 plugin avaible for  
 programming D? If not are there any windows IDE's for D that are at  
 least comparable to VS (ie built in debugger, good autocompletion, can  
 go straight to where something was defined/declared, etc)?
Descent is pretty good, it has integrated debugger, too. Some of its features are shown here: http://www.youtube.com/user/asterite
 2)Garbage Collection: Can the garbage collector just be removed from  
 projects or be completly replaced by a diffrent form of garbage  
 collection, eg refrence counting?

 3)Compatibility between D compilers: Does the D standard enforce binary  
 compatibility between compilers. Eg if I compiled a libary with the DMD  
 compiler and gave the static lib to someone that uses some other D  
 compiler, will they be able to use my lib without any problems?

 4)Support for directX: Specificaly I need to  be able to use d3d9,  
 d3dx9, d3d10, d3dx10 and xAudio2.

 5)Support for classes in dynamic libaries, and the ability to dynamicaly  
 load these libaries.
Jan 15 2009