Examples using Tango

Justin C Calvarese jccalvarese at gmail.com
Wed Dec 29 14:13:52 PST 2010


== Quote from Daren Scot Wilson (darenw at darenscotwilson.com)'s article
> I've been interested for a long time in learning D and using it for image
> processing and physics number crunching.  Now I've got a few days in a row
> to study.   Unfortunately I'm getting stuck even with "Hello World" due to
> most examples of D I find seem to be using Phobos instead of Tango.

Have you tried these examples:
http://dsource.org/projects/tango/wiki/Tutorials

(I'm not a Tango-user, but I'm pretty sure there are some good Tango examples on some web page.)

If you'd be willing to spend some money, "Learn to Tango with D" is probably a good resource for learning Tango.


> Indeed, I'm not clear as to which is the best to use.  For me, "best" is
> defined primarily as "it works on my machine" but secondarily I care about
> speed and ease of use.
> I'm using LDC (the llvm-based compiler) because it's 64-bit and maybe can
> handle D2.   The D1/D2 doesn't matter a lot, though the statement "D version
> 2 which is recommended for new projects" on the home page sways me to use
> D2.

If you want to stick with LDC/Tango, D2 isn't an option yet. I don't know if Tango will ever be ported to D2.

Apparently LDC has experimental D2 support. According to its web page (http://dsource.org/projects/ldc): "D2 support is
highly experimental (read: unusable)". It doesn't sound like a fun place for a new user to be IMHO.


> But 64 bit is vital, since I want to work on huge arrays.   The only
> limitation of LDC is apparently it works only with Tango.
> If I could rub a genie's lamp and have three wishes granted, they are:
> 1) Is it possible to get the source and compile Phobos for use with LVM?

I won't say it's impossible, but I suspect it's non-trivial since I haven't heard that anyone has done it yet.


> 2) Existing code examples should always indicate whether they use Tango or
> Phobos.  Ideally, every example would be presented twice, once for each.
> This might be redundant or pointless for old-timers and D experts, but for
> newbies like me it would help avoid wasting time.

Since Tango and Phobos for D2 seem to be diverging rather than converging, it's going to be increasingly difficult to write
examples that do the same thing using both libraries. The example writer would basically be writing the 2 different
examples in many cases. Some library writers target both Phobos and Tango, and I suspect it can be very frustrating.


> 3)  I'd like to see a translation page with two columns, Phobos and Tango,
> showing how to do the most common things we all need to do - printf() or
> whatever, basic binary file i/o, etc. There could be a third column for C or
> C++ to help us C++ programmers make the transition.

That's not a bad idea for someone to do, but it's 3 times the effort of a single D example and requires knowledge of C++.
You may find this wiki page helpful: http://www.prowiki.org/wiki4d/wiki.cgi?ComingFrom/CPlusPlus

If dearth of Tango examples is a big concern of yours, I'd suggest that you consider starting off with D1 with Phobos (or
D2 with Phobos if you're more adventurous).

I don't know how vital 64-bit support is for you in the near term, but I know that Walter is working on 64-bit support for
DMD. I don't know if 64-bit will be available for DMD in a couple months or if it'll take 6 months, but I know that he's
working on it. I don't know the state of 64-bit in GDC, but it may be farther along than DMD (or it may be fully supported
already).

Anyway, it's your decision, and I suspect some other people will post even better advice than my few comments here.

Good luck!

jcc7


More information about the Digitalmars-d-learn mailing list