Skip to content
All library documents

Why C Remains Useful for Numerical Libraries and Hardware Integration

Article Quant Q&A · Author: Qbik

Summary

The discussion questions whether C is preferred over C++ for numerical optimization and offers several possible explanations. One answer argues that C is not generally favored for numerical optimization today, with continued use often reflecting legacy code or individual familiarity. It mentions FPGA behavioral synthesis as an area where C can be used to describe logic, while noting that hardware description languages are more established and closer to the structure of the hardware.

A further explanation focuses on interoperability: C++ library name mangling is not standardized, which can complicate linking across languages and environments. C's widely recognized calling convention can make it easier to expose numerical libraries to tools such as Python, R, Java, and C#. The thread gives opinions and examples rather than comparative benchmarks or a systematic survey, so it does not establish how widely either language is used or prove that one is faster. Its main practical lesson is that compatibility and integration needs, legacy systems, and team expertise can matter as much as language features when choosing an implementation language.

Key ideas

  • C use in numerical optimization may reflect legacy systems rather than a technical advantage over C++.
  • C can be used in FPGA behavioral synthesis, though dedicated hardware description languages are more common.
  • C's conventional calling interface can simplify library integration across programming languages.
  • Language choice can depend on interoperability and existing expertise as well as performance.

Tags

Full text
# Why C is still in use especially in area of numerical optimization (instead of C++)?


# Why C is still in use especially in area of numerical optimization (instead of C++)?












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 ?

## Answer by Clebson Derivan (score 5)

https://quant.stackexchange.com/a/7387

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.

## Answer by Matt Wolf (score 5)

https://quant.stackexchange.com/a/7388

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.

## Answer by Louis Marascio (score 2)

https://quant.stackexchange.com/a/7389

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.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.