<div dir="ltr">On 2 June 2013 21:46, Joseph Rushton Wakeling <span dir="ltr"><<a href="mailto:joseph.wakeling@webdrake.net" target="_blank">joseph.wakeling@webdrake.net</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 06/02/2013 08:33 AM, Manu wrote:<br>

> Most of these guys are mathematicians and physicists first, and programmers second.<br>
<br>
</div>You've hit the nail on the head, but it's also a question of priorities.  It's<br>
_essential_ that the maths or physics be understood and done right.</blockquote><div><br></div><div style>Well this is another classic point actually. I've been asked by my friends at Cambridge to give their code a once-over for them on many occasions, and while I may not understand exactly what their code does, I can often spot boat-loads of simple functional errors. Like basic programming bugs; out-by-ones, pointer logic fails, clear lack of understanding of floating point, or logical structure that will clearly lead to incorrect/unexpected edge cases.</div>
<div style>And it blows my mind that they then run this code on their big sets of data, write some big analysis/conclusions, and present this statistical data in some journal somewhere, and are generally accepted as an authority and taken seriously!</div>
<div style><br></div><div style>*brain asplode*</div><div><br></div><div style>I can tell you I usually offer more in the way of fixing basic logical errors than actually making it run faster ;)</div><div style>And they don't come to me with everything, just the occasional thing that they have a hunch should probably be faster than it is.</div>
<div><br></div><div style>I hope my experience there isn't too common, but I actually get the feeling it's more common that you'd like to think!</div><div style>This is a crowd I'd actually love to promote D to! But the tools they need aren't all there yet...</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">It's essential that the programs correctly reflect that maths or physics.  It's<br>

merely _desirable_ that the programs run as fast as possible, or be well<br>
designed from a maintenance point of view, or any of the other things that<br>
matter to trained software developers.  (In my day job I have to continually<br>
force myself to _not_ refactor or optimize my code, even though I'd get a lot of<br>
pleasure out of doing so, because it's working adequately and my work priority<br>
is to get results out of it.)<br>
<br>
That in turn leads to a hiring situation where the preference is to have<br>
mathematicians or physicists who can program, rather than programmers who can<br>
learn the maths.  It doesn't help that because of the way academic funding is<br>
made available, the pay scales mean that it's not really possible to attract<br>
top-level developers (unless they have some kind of keen moral desire to work on<br>
academic research); in addition, you usually have to hire them as PhD students<br>
or postdocs or so on (I've also seen masters' students roped in to this end),<br>
which obviously constrains the range of people that you can hire and the range<br>
of skills that will be available, and also the degree of commitment these people<br>
can put into long-term vision and maintenance of the codebase.<br>
<br>
There's also a training problem -- in my experience, most physics undergraduates<br>
are given a crash course in C++ in their first year and not much in the way of<br>
real computer science or development training.  In my case as a maths<br>
undergraduate the first opportunity to learn programming was in the 3rd year of<br>
my degree course, and it was a crash course in a very narrow subset of C<br>
dedicated towards numerical programming.  And if (like me) you then go on into<br>
research, you largely have to self-teach, which can lead to some very<br>
idiosyncratic approaches.<br></blockquote><div><br></div><div style>Yeah, this is an interesting point. These friends of mine all write C code, not even C++.</div><div style>Why is that?</div><div style>I guess it's promoted, because they're supposed to be into the whole 'HPC' thing, but C is really not a good language for doing maths!</div>
<div style><br></div><div style>I see stuff like this:</div><div style>float ***cubicMatrix = (float***)malloc(sizeof(float**)depth);</div><div style>for(int z=0; z<width; z++)</div><div style>{</div><div style>  cubicMatrix[z] = (float**)malloc(sizeof(float**)*height);</div>
<div>  for(int y=0; y<height; y++)</div><div>  {</div><div>    cubicMatrix[z][y] = (float*)malloc(sizeof(float*)*width);</div><div>  }</div><div style>}</div><div><br></div><div style>Seriously, float***. Each 1d row is an individual allocation!</div>
<div style>And then somewhere later on they want to iterate a column rather than a row, and get confused about the pointer arithmetic (well, maybe not precisely that, but you get the idea).</div><div><br></div><div><br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I hope that this will change, because programming is now an absolutely essential<br>
part of just about every avenue of scientific research.  But as it stands, it's<br>
a serious problem.<br>
</blockquote></div><br></div></div>