Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

Why C is still in use especially in area of numerical optimization (instead of C++) ? C and C++ aren't fully compatible so mayby you know some differances that make the difference ?

share|improve this question
Ugh, I wish I had seen this question earlier so I could close it. Too late now since enough people have chimed in. But I swear if this shows up on Hacker News or some garbage like that, I will burniate this. –  chrisaycock Feb 27 '13 at 3:25
Feel free to close it. There is no value-added; same question has been asked a bazillion times already... –  Dirk Eddelbuettel Feb 27 '13 at 3:35
People voting for this obviously derive value. And why would it be too late to close it if the same question was asked already? Ironically if the question was about R or Matlab I do not think we would see above comments. –  Matt Wolf Feb 27 '13 at 8:35
In such a general form it fits Computational Science much more than here –  Alexey Kalmykov Feb 27 '13 at 11:06
@AlexeyKalmykov They aren't going to want it either. Nor would Stack Overflow or Programmers.SE take it. It's just a really awful question. –  chrisaycock Feb 27 '13 at 12:16
show 2 more comments

closed as not constructive by Danil Asotsky, Dirk Eddelbuettel, Clebson Derivan, chrisaycock Feb 27 '13 at 12:19

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

who told you that ? I am used to create new trade systems in C++ to make the customers requirements feasible.

CERN used C++ to prove higgs boson particle. I see people using C to program embedded like microwaves or fridges :D

but it is just my opnion, I would like to hear others.

share|improve this answer
are you referring to root.cern.ch/drupal ? amazing software +1 –  pyCthon Feb 27 '13 at 2:50
yup and they are porting it to C++11 –  Clebson Derivan Feb 27 '13 at 11:04
add comment

C is not used for any particular reason in numerical optimizations other than for legacy reasons. However, there are areas where C is preferred over C++ though even C is not the preferred language of choice. To mind comes programming FPGAs. Though VHDL and Verilog are by far the standards. But "behavioral synthesis" allows to utilize C or C relatives such as SystemC to transfer logic to HDL. In that C is the preferred choice over C++. (Though having started working with FPGAs I start to get the sense that VHDL and Verilog are so popular for good reasons; even though the learning curve is a lot steeper they are much closer to the core of the particular hardware logic (Gate Arrays have a vastly different structure than a CPU).

So, C has its applications and is the preferred choice of weapon in some areas but more often than not people prefer using what they are best at. At least in numerical optimization I do not see a single reason why C would be preferred over C++ and actually I doubt such claim.

share|improve this answer
FPGA's might not be a good fit for certain numerical optimization problems –  pyCthon Feb 27 '13 at 2:33
@pyCthon, that was not my point, the point was to show an example in where it makes sense to have C be the preferred language over C++ and to explain why it is that case. By the way, as you already touched on it, FPGAs might not but can be an excellent fit for solving optimization problems. –  Matt Wolf Feb 27 '13 at 3:03
I understand what you said pyCthon in fact when you need I/O you must think in a CPU like RISC. FGPA runs the whole application in one clock cycle. to create complex applications (eg to calculate a exotic derivative or option) IMHO FPGA is only part of the process. I mean, I could use it to decode market data in a fast way, replacing the ethernet card but I need a software to manage the data and coordinate not only the input but also the output when I need to send an order to a exchange for example. –  Clebson Derivan Feb 27 '13 at 11:12
@ClebsonDerivan, with all due respect but please look up the websites of Altera and Xilinx, you will notice that they heavily target Risk Management processes which do involve optimizations. But can we kind of stay on topic if possible? Again, this was just an example where C is preferred over C++. –  Matt Wolf Feb 27 '13 at 11:16
Freddy top500.org/lists/2012/11 all top computers are CPU/GPU based –  Clebson Derivan Feb 27 '13 at 11:25
show 1 more comment

I don't know how widely used C is over C++ when it comes to doing numerical optimization; however, if there is a preference towards C it likely comes from the fact that C++ name mangling is not standard making C++ libraries very hard to integrate into other languages and environments. With C you get a well known calling convention making it straightforward to integrate which is why you see C (and Fortran) libraries that are used in Python, R, Ruby, Java, C#, etc.

share|improve this answer
I think I disagree with this assertion. C++ projects like Boost, Eigen, Armadillo, half a dozen ML libraries, ... all do very well with C++ interfaces. And if you must, you can always use a C interface for glue (as eg offered by R and used by Rcpp). –  Dirk Eddelbuettel Feb 27 '13 at 2:17
Same here, if you are looking for a single language that is most perused to disseminate APIs, on which other libraries rely, whose interfaces are accessed/invoked, then it is surly C++. Plus do not forget that by far the still most supported of all financial APIs in aggregate is the C++ one. I think that speaks for itself. –  Matt Wolf Feb 27 '13 at 2:24
@Matt I agree with Louis, maintaining a binary compatible application against ever changing builds of the STL and/or boost is simply impossible; MATLAB for instance brings its own libstdc++ and hence makes it impossible to link to your code that needs a more/less modern version (yes even backward compatibility is prone to break) –  hroptatyr Sep 6 '13 at 6:12
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.