<p><br>
Le 18 févr. 2012 06:18, "Christopher Jordan-Squire" <<a href="mailto:cjordan1@uw.edu">cjordan1@uw.edu</a>> a écrit :<br>
><br>
> On Fri, Feb 17, 2012 at 8:30 PM, Sturla Molden <<a href="mailto:sturla@molden.no">sturla@molden.no</a>> wrote:<br>
> ><br>
> ><br>
> > Den 18. feb. 2012 kl. 05:01 skrev Jason Grout <<a href="mailto:jason-sage@creativetrax.com">jason-sage@creativetrax.com</a>>:<br>
> ><br>
> >> On 2/17/12 9:54 PM, Sturla Molden wrote:<br>
> >>> We would have to write a C++ programming tutorial that is based on Pyton knowledge instead of C knowledge.<br>
> >><br>
> >> I personally would love such a thing.  It's been a while since I did<br>
> >> anything nontrivial on my own in C++.<br>
> >><br>
> ><br>
> > One example: How do we code multiple return values?<br>
> ><br>
> > In Python:<br>
> > - Return a tuple.<br>
> ><br>
> > In C:<br>
> > - Use pointers (evilness)<br>
> ><br>
> > In C++:<br>
> > - Return a std::tuple, as you would in Python.<br>
> > - Use references, as you would in Fortran or Pascal.<br>
> > - Use pointers, as you would in C.<br>
> ><br>
> > C++ textbooks always pick the last...<br>
> ><br>
> > I would show the first and the second method, and perhaps intentionally forget the last.<br>
> ><br>
> > Sturla<br>
> ><br>
><br>
> I can add my own 2 cents about cython vs. C vs. C++, based on summer<br>
> coding experiences.<br>
><br>
> I was an intern at Enthought, sharing an office with Mark W. (Which<br>
> was a treat. I recommend you all quit your day jobs and haunt whatever<br>
> office Mark is inhabiting.) I was trying to optimize some code and<br>
> that lead to experimenting with both cython and C.<br>
><br>
> Dealing with the C internals of numpy was frustrating. Since C doesn't<br>
> have templating but numpy kinda needs it, instead python scripts go<br>
> over and manually perform templating. Not the most obvious thing.<br>
> There were other issues  in the background--including C doesn't allow<br>
> for abstraction (i.e. easy to read), lots of pointer-fu is required,<br>
> and the C API is lightly documented and already plenty difficult.</p>
<p>Please understand that the argument is not to maintain a status quo.</p>
<p>Lack of API documentation, internals that need significant work are certainly issues. I fail to see how writing in C++ will solve the documentation issues.</p>
<p>On the abstraction side of things, let's agree to disagree. Plenty of complex projects are written in both languages to make this a matter of mostly subjective matter.</p>
<p>><br>
> On the flip side, cython looked pretty...but I didn't get the<br>
> performance gains I wanted, and had to spend a lot of time figuring<br>
> out if it was cython, needing to add types, buggy support for numpy,<br>
> or actually the algorithm. The C files generated by cython were<br>
> enormous and difficult to read. They really weren't meant for human<br>
> consumption. As Sturla has said, regardless of the quality of the<br>
> current product, it isn't stable.</p>
<p>Sturla represents only himself on this issue. Cython is widely held as a successful and very useful tool. Many more projects in the scipy community uses cython compared to C++.</p>
<p> And even if it looks friendly<br>
> there's magic going on under the hood. Magic means it's hard to<br>
> diagnose and fix problems. At least one very smart person has told me<br>
> they find cython most useful for wrapping C/C++ libraries and exposing<br>
> them to python, which is a far cry from library writing. (Of course<br>
> Wes McKinney, a cython evangelist, uses it all over his pandas<br>
> library.)</p>
<p>I am not very smart, but this is certainly close to what I had in mind as well :) As you know, the lack of clear abstraction between c and c python wrapping is one of the major issue in numpy. Cython is certainly one of the most capable tool out there to avoid tedious reference bug chasing.</p>

<p>><br>
> In comparison, there are a number of high quality, performant,<br>
> open-source C++ based array libraries out there with very friendly<br>
> API's. Things like eigen<br>
> (<a href="http://eigen.tuxfamily.org/index.php?title=Main_Page">http://eigen.tuxfamily.org/index.php?title=Main_Page</a>) and Armadillo<br>
> (<a href="http://arma.sourceforge.net/">http://arma.sourceforge.net/</a>). They seem to have plenty of users and<br>
> more devs than </p>
<p>eigen is a typical example of code i hope numpy will never be close to. This is again quite subjective, but it also shows that we have quite different ideas on what maintainable/readable code means. Which is of course quite alright. But it means a choice needs to be made. If a majority of people find eigen more readable than a well written C library, then I don't think anyone can reasonably argue against going to c++.</p>

<p>><br>
> On the broader topic of recruitment...sure, cython has a lower barrier<br>
> to entry than C++. But there are many, many more C++ developers and<br>
> resources out there than cython resources. And it likely will stay<br>
> that way for quite some </p>
<p> I may not have explained it very well: my whole point is that we don't recruite people, where I understand recruit as hiring full time, profesional programmers.We need more people who can casually spend a few hours - typically grad students, scientists with an itch. There is no doubt that more professional programmers know c++ compared to C. But a community project like numpy has different requirements than a "professional" project.</p>

<p>David<br>
><br>
> -Chris<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > NumPy-Discussion mailing list<br>
> > <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> > <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</p>