www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C++ to D: Help please

reply %u <mail home.com> writes:
I requested some assistance with operator overlaoding yesterday
and I really appreciate the assistance provided. However, trying
to incorporate the example just confused me a little more, it does
not meld well with the code I translated from the tutorial I am
reading. I am hoping that one of you experienced programmers out
there could lend me a hand converting this small program to D.

Not really interested in staying true to form with the way C++
does it because I don't know that much C++, just trying to learn D
from the example. As just hoping to capture all the functionality
of provided in the program so that I can observe the transition
from C++ to D in a complete and useful example.

The code is here:
http://www.relisoft.com/win32/source/generic.zip

Again, thank you all very much.
Feb 23 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
%u:

 I am hoping that one of you experienced programmers out
 there could lend me a hand converting this small program to D.

If you show specific problems some people here will try to help. But I think most people are not willing to translate a multi-module C++ program to D for you. If you aren't able to translate that, start from something smaller, like 10-lines long console programs, implement some of the missing ones here: http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_D Bye, bearophile
Feb 23 2011
parent reply %u <mail home.com> writes:
bearophile,

You do have a point there, and I actually expected that response.
I would have posted my attempt at implementation, but am unable to
transfer info between the computer I'm typing this message on and
the one I'm programming on at the moment.

I have no problems converting small problems. Hence why I'm not
trying to convert small scripts. My problems are in understanding
the inner workings of multimodule programs, how to create them,
create the make file to use in comepiling them, and then since I'm
reading C/C++ (which I don't know much about) but trying to learn
D, how to do it correctly in D?

I do appreciate your response though.

Have a blessed day.
Feb 23 2011
parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
%u Wrote:


 I have no problems converting small problems. Hence why I'm not
 trying to convert small scripts. My problems are in understanding
 the inner workings of multimodule programs, how to create them,
 create the make file to use in comepiling them, and then since I'm
 reading C/C++ (which I don't know much about) but trying to learn
 D, how to do it correctly in D?

Well using one language you aren't familiar with to learn another is probably not the best strategy. For one thing C++ uses namespaces and D uses modules. They are both about name-space but are very different approaches. If you want to learn about modules then write a simple application. Place all functions in one module/file and import that into a file that contains the main function. Then call $ dmd file1.d file2.d
Feb 24 2011
parent reply "Tyro[a.c.edwards]" <nospam home.com> writes:
On 2/25/2011 3:33 AM, Jesse Phillips wrote:
 Well using one language you aren't familiar with to learn another is probably
not the best strategy.

 For one thing C++ uses namespaces and D uses modules. They are both about
name-space but are very different approaches. If you want to learn about
modules then write a simple application. Place all functions in one module/file
and import that into a file that contains the main function. Then call $ dmd
file1.d file2.d

Right again. It would be great to have complete tutorials for D. But the fact is we don't, so one has little choice but to use another language's tutorial. Truth be told, I was hoping that Bartosz Milewski, a very active programmer in the D community would see my post and, would realize that I was using his tutorials and offer to port them to D so that the community as a whole would benefit from them. I've gotten away of trying to ask authors directly to convert their material to D because that rarely ever works. As far as learning the differences between C++ and D, I really have no desire. I'm what you might call an advanced beginning D programmer. Lost but not dumb: I do know how the D module system works and I have an inkling of how C++ namespaces work. I know the basics of programming (in D language, but the basics translate to any other language quite easily) and am looking for ways to use that to do something useful. Unfortunately, the more complete/useful tutorials are written in C/C++ and not my language of choice: D. The authors of those tutorials have no interest in D or probably have never even heard of D and would care less about it's existence because it does not positively affect their financial well being. I will eventually port the program, because that is what I want to do. But the fact is, that will take several months using a trial and error approach. I was just hoping to get through the process a little faster and learning from that example, go ahead and port the rest of the tutorials on Bartosz's site. Sorry for assuming someone would be willing to offer to lend a hand in doing so. I would offer to compensate that individual for time lost doing the conversion but I have no idea what would be a reasonable offer and refrained from doing so because I had no desire to offend anyone here. Well, thank you all.
Feb 24 2011
parent Jesse Phillips <jessekphillips+D gmail.com> writes:
Well I guess my point was to use a language you are very familiar with to
obtain examples. There have been some attempts and such tutorials:

http://www.prowiki.org/wiki4d/wiki.cgi?ComingFrom#SpecificLanguage

But Java I think is the most thorough and out of date (pre-D1). There is also a
porting guide for C++, but it is a hard read and definitely expects solid
knowledge of C++.

http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx

Personally I would like to try and port your program to learn more about C++.
But it is Windows related and my dev box is Linux. I just don't find Windows a
fun environment to do coding. (I'm also running out of space since I only gave
x86-64 Vista 30GB to work with).
Feb 24 2011