| Thread Closed |
Are pointers important for scientific research? |
Share Thread |
| May8-10, 07:13 PM | #1 |
|
|
Are pointers important for scientific research?
A lot of scientific programs are CPU-intensive, so speed is important. Pointers have to do with memory management, which I presume is important since there are often so many array values that memory management becomes important. yet, I don't see it used very often. Are they used very often?
|
| May8-10, 07:24 PM | #2 |
|
|
C/C++. Which seems to be one of the most popular languages for scientific computing.
|
| May8-10, 07:29 PM | #3 |
|
|
I thought that was FORTRAN for numeric intensive computing, Prolog or Lisp for artificial intelligence / language parsing, ADA for space shuttle things and other things that can't go wrong and what-ever ML-spawn for simulations and physics.
But C's probably also decent enough for the first, apparently FORTRAN has better libraries or something, I never got why they all use FORTRAN for that why C is just as good, if not better. Maybe COBOL works well too. But to answer your quaestion, pointers are essential and people use pointers implicitly more than they realize. But it depends for what, pointers don't magically 'speed up' things, they just help you program things that would be really cumbersome to program without. Edit: Also, an array is a pointer, an array of integers is a pointer of type integer, so yeah, if you use array you use pointers. |
| May8-10, 07:38 PM | #4 |
|
Mentor
|
Are pointers important for scientific research?
No religious arguments on the whether C/C++ is a good or bad language, or on its merits as a language for scientific programming.
In C and in C++ when you pass a primitive array (e.g. double array[3]) to a function you are passing a pointer. C, for good or for bad, pushes things to pointers rather quickly. C++ uses references as well as pointers. References are essentially pointers, but with some of the loosy-goosy nature of raw pointers in C. C++ offers containers in the Standard Template Library that go well beyond the simple pointers and references. Sometimes these container objects can be very useful, but sometimes they are quite hoggish of CPU and memory. As far as whether pointers and their more advanced kin are used in scientific programming: Yes. All the time. |
| May8-10, 07:40 PM | #5 |
|
Mentor
|
Pointers are used a lot in C and C++, particular in functions that have "call by reference" parameters,. Pointers don't necessarily have to do with memory management, as such, but can be used to provide access to a chunk of data rather than having to deal with the individual items of data. For example, a function can be passed the address of a block of memory, rather than the memory block itself.
Certain data structures, such as linked lists, queues, and such, are often implemented so that the individual components that make up the list or queue have pointers to the next and/or preceding structure in the list. |
| May8-10, 07:50 PM | #6 |
|
Mentor
|
Raw pointers (but not references) are pretty much verboten in real-time high-reliability applications such as flight software. Then again, so is almost all of the STL. |
| May8-10, 07:58 PM | #7 |
|
Recognitions:
|
Seems like a very odd question, asking whether a particular programming-language construct is important to scientific research or not.
I know a lot of stuff I do is still written in fairly old fortran, and doesn't use pointers much. But in general it just depends on which language you use. I'd say that in my experience though, most of the work towards optimizing in scientific computing, both with respect to memory and speed, tends to be oriented towards optimizing at the mathematical/algorithmic level rather than at the programming-language/hardware level. That's where the big gains are to be had. Low-level optimization can often be a waste of time, given the rate at which hardware and compilers change. |
| May8-10, 08:06 PM | #8 |
|
Mentor
|
On the other hand, even the best algorithm can be implemented stupidly. Passing by copy as opposed to reference, etc, can really slow things down. |
| May9-10, 08:51 AM | #9 |
|
|
At least in C++, the goal is generally to use raw pointers only when absolutely necessary by letting the "dirty work" be hidden by things like STL containers and smart pointers.
However, you're still going to need to know how pointers work if you want to be proficient with C++ or C. |
| May9-10, 11:33 AM | #10 |
|
Mentor
|
Regarding STL containers and smart pointers, some organizations ban the use of these. These same organizations are also likely to ban or strongly limit the use of new and delete (and malloc and free). That's because these organizations are building real-time / embedded software. A lot of avionics code is now written in C++. |
| May9-10, 06:02 PM | #11 |
|
Recognitions:
|
|
| May13-10, 09:32 PM | #12 |
|
|
That said, pass by [const] reference should pretty much be the default for non-POD function arguments in C++. I personally am in the "only use pointer arguments when the parameter is optional" camp. YMMV. |
| May14-10, 09:06 AM | #13 |
|
Mentor
|
From my experience, those skill sets are nearly orthogonal to one another. Scientists and engineers, for the most part, make for rather lousy programmers. So why do organizations involved in scientific programming even allow scientists and engineers to write code? The answer is simple: Lousy as the typical scientist/engineer may be regarding programming skills, the scientific reasoning skills of the typical computer programmer are even worse. |
| Thread Closed |
| Tags |
| inquilinekea |
Similar discussions for: Are pointers important for scientific research?
|
||||
| Thread | Forum | Replies | ||
| Scientific Research in a Gas Balloon | General Physics | 0 | ||
| The Most Important Scientific Concept To Understand | General Discussion | 19 | ||