<div dir="ltr">I'm not a programmer myself and used D for a project in computational electromagnetics. While I had to implement numerical integration and a bit of linear algebra which was annoying (would be really useful in phobos), it was a joy to work with and the resulting program was incredibly fast.<div>Most others used matlab and the difference in speed was more than a factor 100. Not only that, prototyping went quicker in D.</div><div><br></div><div>I've also written a simulation of the dual slit experiment which I'll drop somewhere on github once the code is presentable.</div><div><br></div><div>So, if you don't mind having to implement a few algorithms that are already available in numpy, D will be pleasant and fast.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-04 11:48 GMT+02:00 Chris via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sunday, 2 August 2015 at 16:25:18 UTC, Yura wrote:<br>
</span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear D coders/developers,<br>
<br>
I am just thinking on one project in computational chemistry, and it is sort of difficult for me to pick up the right language this project to be written. The project is going to deal with the generation of the molecular structures and will resemble to some extent some bio-informatic stuff. Personally I code in two languages - Python, and a little bit in C (just started to learn this language).<br>
<br>
While it is easy to code in Python there are two things I do not like:<br>
<br>
1) Python is slow for nested loops (much slower comparing to C)<br>
2) Python is not compiled. However, I want to work with a code which can be compiled and distributed as binaries (at least at the beginning).<br>
<br>
When it comes to C, it is very difficult to code (I am a chemist rather than computer scientist). The pointers, memory allocation, absence of the truly dynamically allocated arrays, etc, etc make the coding very long. C is too low level I believe.<br>
<br>
I just wander how D would be suitable for my purpose? Please, correct me if I am wrong, but in D the need of pointers is minimal, there is a garbage collector, the arrays can be dynamically allocated, the arrays can be sliced, ~=, etc which makes it similar to python at some extent. I tried to write a little code in D and it was very much intuitive and similar to what I did both in Python and C.<br>
<br>
Any hints/thoughts/advises?<br>
<br>
With kind regards,<br>
Yury<br>
</blockquote>
<br></div></div>
I agree with bachmeier. You cannot go wrong. You mentioned nested loops. D allows you to concatenate (or "pipe") loops. So instead of<br>
<br>
foreach<br>
{<br>
  foreach<br>
  {<br>
    foreach<br>
    {<br>
    }<br>
  }<br>
}<br>
<br>
you have something like<br>
<br>
int[] numbers = [-2, 1, 6, -3, 10];<br>
foreach (ref n; numbers<br>
  .map!(a => a * 5)  // multiply each value by 5<br>
  .filter!(a => a > 0))  // filter values that are 0 or less<br>
{<br>
  //  Do something<br>
}<br>
<br>
or just write<br>
<br>
auto result = numbers.map!(a => a * 5).filter!(a => a > 0);<br>
// ==> result = [5, 30, 50]<br>
<br>
You'd probably want to have a look at:<br>
<br>
<a href="http://dlang.org/phobos/std_algorithm.html" rel="noreferrer" target="_blank">http://dlang.org/phobos/std_algorithm.html</a><br>
<br>
and ranges (a very important concept in D):<br>
<br>
<a href="http://ddili.org/ders/d.en/ranges.html" rel="noreferrer" target="_blank">http://ddili.org/ders/d.en/ranges.html</a><br>
<a href="http://wiki.dlang.org/Component_programming_with_ranges" rel="noreferrer" target="_blank">http://wiki.dlang.org/Component_programming_with_ranges</a><br>
<br>
Excessive use of nested loops is not necessary in D nor is it very common. This makes the code easier to maintain and less buggy in the end.<br>
</blockquote></div><br></div>