Linked by Amjith Ramanujam on Wed 20th Aug 2008 19:37 UTC
General Development DevX interviewed Bjarne Stroustrup about C++0x, the new C++ standard that is due in 2009. Bjarne Stroustrup has classified the new features into three categories Concurrency, Libraries and Language. The changes introduced in the Concurrency makes C++ more standardized and easy to use on multi-core processors. It is good to see that some of the commonly used libraries are becoming standard (eg: unordered_maps and regex).
Thread beginning with comment 327487
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[2]: what is C++ best for?
by tyrione on Wed 20th Aug 2008 23:41 UTC in reply to "RE: what is C++ best for?"
tyrione
Member since:
2005-11-21

Fortran isn't touched when it comes to precision when doing Numerical Analysis.

Reply Parent Bookmark Score: 2

RE[3]: what is C++ best for?
by ebasconp on Wed 20th Aug 2008 23:52 in reply to "RE[2]: what is C++ best for?"
ebasconp Member since:
2006-05-09

Although its fame, I do not find Fortran better than C or C++ for mathematical operations.

Reply Parent Bookmark Score: 3

RE[3]: what is C++ best for?
by jacquouille on Wed 20th Aug 2008 23:55 in reply to "RE[2]: what is C++ best for?"
jacquouille Member since:
2006-01-02

Precision is not a language feature, it's a library feature. Don't know if by precision you mean number of significant digits or numerical stability of algorithms, but in both cases this should go into libraries. The language itself should only provide the bare minimum i.e. the IEEE754 floating-point types supported by CPUs.

Fortran indeed used to have by far the best math libraries, but, mark my words! We're a new generation of C++ math software coming to challenge that situation, and template metaprogramming will be a huge strength here.

Reply Parent Bookmark Score: 1

RE[4]: what is C++ best for?
by ashigabou on Thu 21st Aug 2008 02:27 in reply to "RE[3]: what is C++ best for?"
ashigabou Member since:
2005-11-11

We're a new generation of C++ math software coming to challenge that situation, and template metaprogramming will be a huge strength here.


I think it is kind of missing the point. Template meta-programming does not bring much: it gives you speed and memory savings, at the cost of totally unreadable and uncomprehensible code. The problem of meta-programming is that it is a really bad tool at what it is used for (parsing mathematical operations). I agree that dealing with complex linear algebra kind of things wo using a lot of memory is still an unsolved problem, but I think using a much higher level to parse mathematical expressions is a much better way to solve the problem (e.g. you would have pseudo-code mathematics parsed by something like lisp).

For example, fftw, the reference open source fft library, although implemented in C, is actually generated by a specialized ocaml generator (the meat of fftw is in the ocaml code). This is certainly a more elegant, more powerful approach than C++ meta programming, which is really just an hack with an awful syntax.

Reply Parent Bookmark Score: 3

RE[4]: what is C++ best for?
by tyrione on Thu 21st Aug 2008 04:15 in reply to "RE[3]: what is C++ best for?"
tyrione Member since:
2005-11-21

There is a reason why most of the floating point component tests are still written in Fortran.

http://www.spec.org/cpu/CFP2000/

I'm not knocking C--I like C and anyone who says it's obsolete is either under 30 or just delusional.

I'm looking forward to OpenCL and using it's C implementaiton.

Reply Parent Bookmark Score: 2

RE[3]: what is C++ best for?
by ashigabou on Thu 21st Aug 2008 02:04 in reply to "RE[2]: what is C++ best for?"
ashigabou Member since:
2005-11-11

Fortran isn't touched when it comes to precision when doing Numerical Analysis.


Nothing to do with precision. Fortran use the same format than C those days on common machines (IEEE floating point); if you implement the same algorithm, you can in theory have exactly the same results (although differences with compilers mean this will never happen in practice). There is a lot of expertise in fortran numerical code, though, which is why you still have so much code implemented in fortran and used today (blas, lapack, optimization, etc...).

Fortran beats down C (and C++, they are the same here) because it does not have pointers, or more exactly does not have the aliasing problem (different pointers pointing at the same memory address), which makes optimization by compilers so difficult. That's why Fortran is still much faster than C or C++ on most benchmarks.

It has also an array concept: that's why most C++ is a really poor language IMO for numerical code, because everybody has a different, incompatible class for vectors, so the speed you gain from being in C++ is lost converting formats between libraries. This and the fact that the language is way too complicated IMO. I personally believe that C++ is a niche language: it is still the only "industry" language you can use when you need ten of thousand objects touching each other (heavy GUI, games), but I would never use C++ if I had a valid other choice.

Reply Parent Bookmark Score: 3

RE[4]: what is C++ best for?
by Hakime on Thu 21st Aug 2008 10:22 in reply to "RE[3]: what is C++ best for?"
Hakime Member since:
2005-11-16

"Fortran beats down C (and C++, they are the same here) because it does not have pointers, or more exactly does not have the aliasing problem (different pointers pointing at the same memory address), which makes optimization by compilers so difficult."

This is not really true. Since Fortran 90, the language has added support for pointers which basically work as in C but are less extensively used compared to the C and less powerful, for example pointer arithmetic is not supported, no pointer to a pointer to a variable declaration, no function pointers.

So declaring a pointer to a real number would be written in Fortran 90 as:

REAL, POINTER :: p1

Making p1 to point to a variable var would give

p1 => var.

So pointers exist in Fortran, they are less powerful than in C but the fortran syntax is less complex and also the language adds several nice features as, the possibility of testing the association status of a pointer to a variable, the possibility to disassociated a pointer to a target and a TARGET attribute that allows the compiler to know that a particular variable could be pointed by a pointer and therefore it must not be optimized out of existence.

Pointers in Fortran can poin to any variable type, to derived data types and to arrays. They can be used to implement dynamic memory allocation and to construct various types of dynamic data structures.

So now why Fortran is faster than C in numerical code? Well i don't think it is a language related question (C is quite a fast and low level language), i rather think that compilers make all the difference here. I mean, Fortran compilers are built and optimized to create the fastest numerical code possible. They are designed to produce only fast numerical code. C or C++ compilers have a larger field of application, they compile very different king of applications where optimizations strategies can be very different.

Fortran compilers are number crunching, number crunching, number crunching, they have been built for that for several decades... they know only that but they do it very well.

Also besides the performance question, Fortran is by far the most used language for coding numerical applications among scientists because it offers a lot of features that are important for this audience. Matrix representation, direct matrix multiplication, better implementation for complex numbers, more flexible manipulation of arrays, easier to read, easier to port, easier to maintain. All of those make this language a very attractive solution for scientists and engineers who code numerical applications.

Edited 2008-08-21 10:26 UTC

Reply Parent Bookmark Score: 2

RE[3]: what is C++ best for?
by saucerful on Thu 21st Aug 2008 04:28 in reply to "RE[2]: what is C++ best for?"
saucerful Member since:
2008-06-12

Fortran isn't touched when it comes to precision when doing Numerical Analysis.


Bullshit.

The C library MPFR implements arbitrary precision math with correct rounding. It supports all the basic operations you expect as well as a bunch of others that I have found useful for my research (e.g. polylogarithm). Unless you're doing actual mathematics (in which case you want to either use interval arithmetic (for which there is MPFI) or work over an algebraic number field(I recommend using Sage)), there is nothing more you can ask for in terms of precision. As for performance, I can't complain, though I don't know what Fortran is like.

Off-topic: To be honest, I have neither agreed with nor learned from anything that you ever post here. How do you have 2 fans?

Edited 2008-08-21 04:30 UTC

Reply Parent Bookmark Score: 2

RE[3]: what is C++ best for?
by FunkyELF on Thu 21st Aug 2008 08:34 in reply to "RE[2]: what is C++ best for?"
FunkyELF Member since:
2006-07-26

Fortran isn't touched when it comes to precision when doing Numerical Analysis.


Yeah, but its readability is like LISP or Prolog.
The Fortran language itself encourages spaghetti code.
Too many implicit rules about variables with names beginning with a letter between i and n automatically being integers.

Python 3000 (or if you put from __future__ import division) is the first language that handles numbers the way I think is most natural. It, like Fortran, allows you to create variables on the fly but it does it in a way that makes sense. If you assign 1 it will be an integer, if you assign 1.0 it will be a float. All divisions are floating divisions. This is natural. If you want integer division you have to use //.

Reply Parent Bookmark Score: 2