Choosing a Degree: Physics/Astrophysics & Fortran

In summary, the conversation suggests that for a physics/astrophysics major, C++ is a better language to learn than C. Fortran is also useful for simulations and can be a good combination with C++. There are two schools of thought on scientific programming, with some favoring C++ and others favoring Fortran. Learning C++ also means learning C, but it can be more difficult to downgrade from C++ to C than to upgrade from C to C++. It is important to learn how to program rather than focusing on a specific language. Some people can program well in multiple languages, while others struggle to adapt.
  • #1
HeLiXe
440
1
Which one is better for a physics/astrophysics major? I will be taking Fortran as well.
 
Physics news on Phys.org
  • #2
I got the advice to learn C++ from a postdoc, but he gave no particular reason for that other than he'll be using it for dataselection. I don't know what is suitable for simulations.

A friend of mine used Fortran for his thesis where he modeled airflow in windmillparks.
 
  • #3
C+=2 is my personal favorite.

But really, C++. Very few scenarios where you actually need C and I doubt, being a physicist, that you will be doing much systems programming.
 
  • #4
C++ and Fortran is a good combination. Knowledge of basic C is useful.

In scientific programming, there seems to be two schools - proponents of C++ and proponents for Fortran. I think the Fortran school represents legacy programmers (old-timers).
 
  • #5
Downgrading from C++ to C is probably easier than upgrading from C to C++.
 
  • #6
I'm not too sure how it works in the physics world, but in finance C is outdated and no one really uses it anymore. Hope that helps.
 
  • #7
C is the basis for C++. C is not object oriented, C++ CAN be object oriented, or you can just use C and say that you are using C++. If you want a language that forces you to be object oriented whether you like it or not, go with JAVA.

I think C++ is best and what follows from Borek's statement is that if you learn C++, you will then already know C it's just that if you then want to program in C, you'll have to remember that you can't use any of the object oriented methodologies.
 
  • #8
eXorikos said:
A friend of mine used Fortran for his thesis where he modeled airflow in windmillparks.
Cool! Thanks eXorikos
PhDorBust said:
C+=2 is my personal favorite.

But really, C++. Very few scenarios where you actually need C and I doubt, being a physicist, that you will be doing much systems programming.
Thank you so much PhDorBust
Astronuc said:
C++ and Fortran is a good combination. Knowledge of basic C is useful.

In scientific programming, there seems to be two schools - proponents of C++ and proponents for Fortran. I think the Fortran school represents legacy programmers (old-timers).
Thanks a zillion Astronuc
Borek said:
Downgrading from C++ to C is probably easier than upgrading from C to C++.
lol Thanks Borek
DeadOriginal said:
I'm not too sure how it works in the physics world, but in finance C is outdated and no one really uses it anymore. Hope that helps.
Yes this is helpful, thank you very much.
phinds said:
C is the basis for C++. C is not object oriented, C++ CAN be object oriented, or you can just use C and say that you are using C++. If you want a language that forces you to be object oriented whether you like it or not, go with JAVA.

I think C++ is best and what follows from Borek's statement is that if you learn C++, you will then already know C it's just that if you then want to program in C, you'll have to remember that you can't use any of the object oriented methodologies.

Thanks so much phinds, this is very helpful! I take it then that once one has taken C++, one will also know C from what you have said here. We worked with Java in intro programming, but of course it wasn't exhaustive.

I appreciate your response everyone! I will take C++.
 
  • #9
HeLiXe said:
Thanks so much phinds, this is very helpful! I take it then that once one has taken C++, one will also know C from what you have said here.

Yeah, the fundamental underlying language of C++ is just plain old C, so you don't have any choice but to learn C on the way to C++, but C++ overlays all kinds of cool capabilities based on making it object oriented. You don't always need them but when you DO need them, there just isn't any substitue in basic C.
 
  • #10
HeLiXe said:
Thanks so much phinds, this is very helpful! I take it then that once one has taken C++, one will also know C from what you have said here.

Yes. The only problem is to learn which parts of what you know you have to forget.
 
  • #11
Borek said:
Yes. The only problem is to learn which parts of what you know you have to forget.

In my experience, this is much harder than it sounds.
 
  • #12
Personally, I think it is much better to know how to program than any (or many) particular language(s). I know people who can program badly in many languages.
 
  • #13
Vanadium 50 said:
I know people who can program badly in many languages.

Count me in. While I have learned to not use goto back in eighties, I am afraid most of my code has nothing to do with languages I am using. I bogged down somewhere between Pascal and C++.
 
  • #14
As they say, some people can write FORTRAN in any language.
 
  • #15
phinds said:
Yeah, the fundamental underlying language of C++ is just plain old C, so you don't have any choice but to learn C on the way to C++, but C++ overlays all kinds of cool capabilities based on making it object oriented. You don't always need them but when you DO need them, there just isn't any substitue in basic C.
Thanks again phinds. For some reason my school is not offering C++ in the Fall. There is only C, C#, and Object Oriented Programming with Java. They had it in the Spring, but not in the summer, and I thought they would have it for Fall. I'm not sure why they are not offering it.
Borek said:
Yes. The only problem is to learn which parts of what you know you have to forget.
@_@
Vanadium 50 said:
Personally, I think it is much better to know how to program than any (or many) particular language(s). I know people who can program badly in many languages.

I am asking because I did intro to comp programming last semester, and the only other courses being offered are language courses and object oriented programming with Java :/ I just found out there is no C++. I was also wondering because some fields use some languages more than others, so I was wondering which is best for the field I want to go into.
 
  • #16
C++ is also object oriented, so Java might be a good idea. Object oriented programming is something totally different from other languages.

Learning C has the advantage of learning how to manage your memory you use. Java does this automatically, but C++ doesn't.
 
  • #17
The argument against C++ is that it's simply a bad language. The reason it's a bad language is that they tried too hard to maintain backward compatibility with C. C is actually quite a nice language; it's a simple tool specialized for certain specific jobs.

More global advice for science grad students: don't waste your time learning lots of computer languages or doing lots of coding. Spend your time doing science.
 
  • #18
eXorikos said:
C++ is also object oriented, so Java might be a good idea. Object oriented programming is something totally different from other languages.

Learning C has the advantage of learning how to manage your memory you use. Java does this automatically, but C++ doesn't.
Thanks eXorikos! I'm all confused now...so sorry if this is overkill...Do you think I should do both C and object oriented with Java? Maybe it's not necessary to take all these classes, and I can take the OOP w/Java and learn C++ by other means? I wonder if it is necessary to take the course to "prove" that you have learned it.
 
  • #19
bcrowell said:
The argument against C++ is that it's simply a bad language. The reason it's a bad language is that they tried too hard to maintain backward compatibility with C. C is actually quite a nice language; it's a simple tool specialized for certain specific jobs.

More global advice for science grad students: don't waste your time learning lots of computer languages or doing lots of coding. Spend your time doing science.

Thanks Ben.
 
  • #20
If you take one programming course that will be sufficient and it doesn't matter what language. It's impossible to learn every language. You'll learn other languages if you should ever need them. Basic programming skills is what you need, not syntax.
 
  • #21
Thanks! I don't want to learn every language lol, just the necessary ones which I understand to be fortran and a C language. But thanks again, you and everyone else have been a great help and things are in perspective now.
 
  • #22
bcrowell said:
The argument against C++ is that it's simply a bad language. The reason it's a bad language is that they tried too hard to maintain backward compatibility with C. C is actually quite a nice language; it's a simple tool specialized for certain specific jobs.

It depends on what you are using the language for. If you are doing algorithmic programming, fortran is the right language. If you want large scale architecture, you'd like to use Java. If you want to use declarative style, then Haskell and ML. If you want to use low level languages, you use C.

The trouble is that in the "real world" you have to do algorithmic programming with large scale architectures with declarative bits and parts in which you have to go low level. At that point, you don't have any choice but to use C++.

More global advice for science grad students: don't waste your time learning lots of computer languages or doing lots of coding. Spend your time doing science.

No. No. No. No.

For some things the science *is* the coding. The nice thing about some science problems is that in order to get something done you *have* to look at the low level computer bits. You spend weeks looking at cache hits, because that's the difference between code that takes three weeks to run, and code that doesn't run at all.

Computational astrophysics is very computational.
 
  • #23
If it is 500 lines of code, then it really doesn't matter, and you are probably better off doing it in Python.

If it is 50K or 500K or 5M lines of code, you are going to have to do it in something like C++.
 
  • #24
gloriacollins said:
Choose C++ and Fortran... it will be good... :)
:D Thanks gloriacollins
twofish-quant said:
It depends on what you are using the language for. If you are doing algorithmic programming, fortran is the right language. If you want large scale architecture, you'd like to use Java. If you want to use declarative style, then Haskell and ML. If you want to use low level languages, you use C.

The trouble is that in the "real world" you have to do algorithmic programming with large scale architectures with declarative bits and parts in which you have to go low level. At that point, you don't have any choice but to use C++.



No. No. No. No.

For some things the science *is* the coding. The nice thing about some science problems is that in order to get something done you *have* to look at the low level computer bits. You spend weeks looking at cache hits, because that's the difference between code that takes three weeks to run, and code that doesn't run at all.

Computational astrophysics is very computational.
Thank you very much twofish-quant! This is great info :)
 
  • #25
Also C++ is one of those things that you never fully learn. I've been programming C++ for over 20 years, and I'm still learning new stuff about the language.
 

1. What is the difference between physics and astrophysics?

Physics is a broad field that studies the fundamental principles of nature and the properties of matter and energy. Astrophysics is a subfield of physics that specifically focuses on the study of celestial objects, such as stars, galaxies, and planets.

2. Why should I choose to major in physics or astrophysics?

Majoring in physics or astrophysics can open up a wide range of career opportunities in fields such as research, academia, engineering, and data analysis. These degrees also provide a strong foundation in critical thinking, problem-solving, and analytical skills.

3. What is Fortran and why is it important for studying physics or astrophysics?

Fortran is a programming language that is commonly used in scientific computing, including physics and astrophysics. It is designed for high performance and efficient calculations, making it a valuable tool for analyzing large datasets and complex mathematical models.

4. Can I major in physics or astrophysics without prior experience in these fields?

Yes, you do not need prior experience in physics or astrophysics to major in these fields. However, a strong foundation in mathematics, computer science, and problem-solving skills is essential for success in these majors.

5. What are some potential career paths for someone with a degree in physics or astrophysics?

Graduates with degrees in physics or astrophysics can pursue careers in research institutions, government agencies, aerospace and defense industries, and universities. They can also work in fields such as data analysis, software development, and engineering.

Similar threads

Replies
60
Views
3K
Replies
8
Views
1K
  • STEM Academic Advising
Replies
0
Views
83
  • STEM Academic Advising
Replies
3
Views
1K
  • New Member Introductions
Replies
1
Views
56
  • STEM Academic Advising
Replies
5
Views
2K
  • STEM Academic Advising
Replies
7
Views
2K
  • STEM Academic Advising
Replies
3
Views
1K
  • STEM Academic Advising
Replies
7
Views
1K
  • STEM Academic Advising
Replies
26
Views
2K
Back
Top