Skip to main content
15 events
when toggle format what by license comment
Jul 19, 2012 at 2:17 history made wiki Post Made Community Wiki by S. Carnahan
Nov 2, 2011 at 19:40 comment added jjcale One more advantage of C++ compared to C : One can use inline functions instead of macros.
Nov 2, 2011 at 15:01 comment added Thierry Zell @Tim: in answer to your first remark, in a lot of academic applications, "just get a bigger computer" just won't cut it. Many people have access to very powerful machines and routinely bring them to their knees. A lot of the problems push the boundaries so much that it is in that case cheaper to improve the code than to use a bigger machine. How do these problems relate to problems that non-academics really want to solve is another issue altogether.
Nov 2, 2011 at 8:51 comment added Max Horn The underlying idea here is the heuristic that in typical programs, 90% of the time are spent in 10% of the code (the percentages vary of course, but the idea stays the same). So a typical pattern is to implement time crucial parts in another language than the rest of the code. Examples include Sage (with python vs. cython; the latter looks like a subset of python, but compiles to native code), NumPy/SciPy (which use C code for critical parts), anything that uses BLAS/LAPACK, etc
Nov 2, 2011 at 8:47 comment added Max Horn @timur: This common knowledge then is wrong. Inheritance in itself slows down nothing. It is "virtual" methods (using C++ terms) that can cause overheads. But even that does not have to slow down things much, in light of just in time compilations, which can optimize things like that away. It is certainly possible to write top-notch highest speed code in C++, even when using inheritance. The common knowledge really is: By using high level constructs to write the general parts of your code, you safe time, which you can then invest in optimization the hell out of the time critical parts.
Nov 2, 2011 at 2:58 comment added timur It is a common knowledge that inheritance slows things down a lot. Template is the best.
Oct 14, 2010 at 13:06 comment added Tim van Beek @Felix and Alex: Actually this kind of discussion was one aspect of the story: "Why not use Java? Is garbage collection really an aspect? Is using inheritance really an performance aspect?" @felix: Do you have a concrete example (like a test program) and benchmarks that support your experience that using inheritance in C++ is a problem? Using object oriented design principles is supposed to simplify the design and conding process and maintainability. I understand that these aspects are of secondary importance :-)
Oct 14, 2010 at 0:24 comment added felix Yes, of course, it is not really object oriented anymore :) But then, a lot of use cases (at least in mathematics) of inheritance can be replaced with templates, overloading and a few if/then statements, and the result is something the compiler can heavily optimize without losing a certain generality on the implementation. And yes, I know that this isn't really what Tim wants, since C++ has no automatic garbage collection (which I think is a good thing).
Oct 14, 2010 at 0:05 comment added Alex B. Interesting, I didn't know that. But of course, it is debatable, how "object oriented" it is, not to use inheritance. Anyway, Tim was asking for the language to have a garbage collector as well, which, as far as I know, always produces overhead.
Oct 13, 2010 at 22:20 comment added felix Alex, you write "Already C++ produces so much more overhead than C [...]". This is not true in general, it clearly depends on how you write your programs. You can use a proper subset of C++ to write programs which are as fast as C programs (or in fact, generate the same machine code), but which are much more readable and both easier to write and maintain; for example, by using classes (but not inheritance!) and templates. (Of course, you shouldn't accidently pass objects by value.) Anyway, for me, C++ is the language of choice if I want to implement something which should better be efficient.
Oct 13, 2010 at 15:17 comment added Tim van Beek @Alex: thanks for pointing out your research focus :-). Actually I'm interested in all kinds of uses of computer programs in mathematics including number theory, not only numerical analysis (but I thought it would be helpful to focus on numerical analysis for this question).
Oct 13, 2010 at 13:49 comment added Alex B. Tim, I should have said that I am not working in numerical analysis. I regularly use computers to test hypotheses in number theory or group theory and the programs are usually much quicker to write than they will run. It is not uncommon to let a program run over the weekend or over a week, just to try lots of examples (and it often pays off). I don't know, whether numerical analysis people do that sort of thing, but I imagine so.
Oct 13, 2010 at 12:37 comment added Suvrit @Tim: Example, consider basic functions such as sin, cos, log, exp, pow --- I would be surprised if they were not implemented in Assembler.
Oct 13, 2010 at 10:52 comment added Tim van Beek Thanks for this answer! Of course, in the software industry, it is most of the time much cheaper to by better hardware than to pay people that optimize the running time of the software. I'm interested what mathematicians working in computational numerical analysis think about this, so your answer helpful. The problem with these "performance prejudice" that I referred to in my question is of course that no one specifies the kind of computations they refer to. Assembler? Really?
Oct 13, 2010 at 9:18 history answered Alex B. CC BY-SA 2.5