Is C really used for a lot of Scientific Computing?
Asked Answered
B

10

11

I'm currently taking a math class in College called "Scientific Computing" and the professor told us that C is the most common language used for, well, scientific computing and am just wondering as to how accurate this professor is?

Badgett answered 13/9, 2009 at 3:3 Comment(2)
You might also be interested in #38739 .Ashlan
This and similar questions often get discussed at Computational Science. For anyone who stumbles on this thread, it's worth a look.Offside
A
28

In my business (particle physics) we pretty much moved from Fortran 77 straight to c++ and python. Those of us who care about programming all know C, but it is only written for niche applications (embedded DAQ boards, special purpose drivers, ...).

That being said, higher-level linear-algebra libraries often delegate to BLAS and LAPACK for the heavy lifting (this includes Eigen and numpy). Though originally written as Fortran libraries, the versions shipped nowadays on many systems are implemented in C.

In any case, learning C will give you a firm foundation for programming, and it is rarely profitable to argue with professors.

Ashlan answered 13/9, 2009 at 3:4 Comment(2)
"and it is rarely profitable to argue with professors"... lolThirza
+1 I would have written something similar (coming from a particle physicist in training ;-).Awfully
D
12

I don't think that your professor's answer is serving you well even if it is correct.

In my experience as a consultant for scientific computing and data systems C is certainly used a lot, but so are Fortran and C++. Python is by far the most commonly used scripting language.

I think that this is going to change. The big deal now is parallel computing and this is painful (MPI anyone?) in the traditional languages I've mentioned. My speculation is that a lot of the parallelization will (and should) be moved to virtual machines: Java or .NET; i.e., I think that parallelization should be the JIT's job. Whether that will be enabled with, say, Fortress, or one one of the traditional languages, I don't know. Intel is pushing parallel tools for C/C++, but I wonder if something like Terracotta might better in the long run (I haven't heard of anyone in the scientific community who's tried it---big finance has, but they are not so open).

If the question is what should you learn to get a job in scientific computing, then the first thing I'd say is that you're more likely to get hired for your scientific skills than your programming skills (which partially explains the sorry state of a lot of scientific code, for more on this see this SO topic). If you are going to be hired for your programming skills (probably HPC), then consider that in the opinion of this professor, those may be obsolete for newer projects in the not-so-distant future. It wouldn't hurt to know some Python, though, including NumPy.

Doane answered 13/9, 2009 at 3:40 Comment(1)
This is an interesting notion. Not the case in my business just now---much of our big crunching is IO bound or nearly so (lots of looking up data tables and writing results at multiple stages)---but very interesting. Right now we parallelise on a per-input file basis, and run on loosely coupled clusters. My crystal ball is cloudy, so I can't say when that might change.Ashlan
R
6

From what I have heard Fortran is very common for scientific purposes, but C is general purpose enough that for some it is a good solution for most any type of programming.

Recombination answered 13/9, 2009 at 3:7 Comment(0)
B
5

For bioinformatics and computational biology, C is very popular.

Balmoral answered 17/5, 2011 at 4:19 Comment(0)
J
4

A lot of "scientific computing" is handled in Mathematica, Matlab and other similar tools.

Well... under the hood, Matlab is written in C or C++, I think, but many parts of Mathematica are written in Mathematica itself. To be sure, for historical reasons, and also because C's intrinsic characteristics, many scientific and hi-tech computing software libraries and such are written in C/C++.

I suspect C/C++ will continue to enjoy a favorable edge for many real-time and high performance applications, maybe not so much for the raw computing itself (which can not be expressed in higher level languages), but for local optimization of tight loops, and for interfacing with various components, be they physical pieces of equipement, or software elements such as for example parallel computing frameworks.

As dmckee pointed out, the study of c provides a good foundation for programming at large, at least procedural programming. It also has practical applications, so your professor's opinion has some strong backing at this time. But, do! continue to challenge, respectfully, the wisdom received from your professors and elders, understanding that sometimes like good zen masters, they put you on a path, not so much for the destination but for the travel/process.

Junoesque answered 13/9, 2009 at 3:40 Comment(2)
Well all the linear algebra heavy-lifting in Matlab is delegated to LAPACK, which is built on Fortran. So by using Matlab you implicitly use Fortran compiled code for most of the time-consuming operations.Clea
@TimLin FWIW, MATLAB's FFT routines are C code generated by OCaml source code, for example.Expel
E
2

Is C really used for a lot of Scientific Computing?

Scientific computing encompasses many different things and, consequently, many different programming languages are used for scientific computing.

Traditionally, scientific computing meant high performance computing and was limited in scope to mostly linear algebra and some spectral methods (e.g. FFTs) and was mostly done in Fortran. Since then, the breadth of scientific computing has expanded enormously with many people now considering technical computing (e.g. massing data, graph plotting, prototyping) falling under the same heading and other people picking up new forms of high performance computing such as symbolic computations.

Languages like Python, R, Mathematica and MATLAB are commonly used for technical computing. Languages like C, C++ and Fortran are still used for number crunching. Languages like OCaml are used for large-scale symbolic computation.

Expel answered 17/4, 2012 at 8:1 Comment(0)
T
1

C is widely-used in programming. Most of us programmer ever coding in C especially when we're at college. It's just your professor preference I guess :-)

Tiresias answered 13/9, 2009 at 3:41 Comment(0)
B
1

As a professional programmer building software for scientists and engineers I can say that nearly all our numerical methodologies are written in C. So in our case it certainly is true. We have pockets of C++ and Fortran. In terms of performance it is hard to beat well coded C and a good compiler. Very, very occasionally we might dip into assembly.

But the world has changed a lot. Python is a wonderful language - the nicest language IMHO and can call native libraries. Then there is R again a source interpreted language but with a massive library of numerical methods all compiled C or C++. Then add all the new hardware accelerated methods such as openCL and the many bindings... C or Fortran is no longer the only answer. But for traditional CPU number crunching C and ASM is the best in class.

Bourbonism answered 26/2, 2016 at 21:51 Comment(0)
Q
0

From my experience working in different labs and research institutes, I would say learning a computer language only give you a foundation and a introduction to programming. C or Java would be a favorable language to pick up as introduction, so your professor is correct to certain extend.

Being able to apply your knowledge in 1 language to another language is the key to success in the computational/development work environment. As you move thru different companies/institutes/lab group, you'll find that each of them would have their own preferences in language/software. Being able to learn new things quickly is more important than trying to memorize the syntax of one particular language.

Of course, if you get to choose a language of your choice for a project, choose 1 that has the libraries that you need.

Quantitative answered 18/5, 2014 at 8:51 Comment(0)
W
0

Yes, ANSI C accompanied by MPI.

Sometimes people want to use "objective C", which means they put functions into methods of big class, and every examplar of it will run on separate core. Note that this is not C++, but "C with objects". None of C++ features is used except of method-object model. This is just wrapping same old C into "rational object model", allows to use intermediate layers and so on.

Good examples of above: LAMMPS.

Charm++ is another good way to obtain "good old C in modern manner".

On other hill of scientific languages are LISP, Haskell and other meta-lang groups. This is other, "soft" world of scientific programming, where time is not problem, but the existence of answer.

Worser answered 11/3, 2016 at 1:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.