CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

C++ or Fortran

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree36Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2018, 07:43
Unhappy C++ or Fortran
  #1
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Dears

How Are you ?
Wish you are all fine

i am a fresh graduated Aerospace Engineer , during the 4 years in my department , i had to use matlab , so i didnt learn much about fortran or C/C++ .

i am started my Master Degree , and i will have to write a code for my simulation , and i really dont know what to choose , Fortran or C/c++ ??

someone told me that fortran is Dead , and people now uses C and learning fortran will make me a bad programmer , and it is a waste of time .

on the other side , someone told me that most of the big companies make its program based on fortran , and it is still being used and i really dont know want to choose ! My professor told me that i have to choose one and he refused to help me in choosing .

thank you very much
looking forward for your replies
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 07:57
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 31
akidess will become famous soon enough
Quote:
Originally Posted by AeroSonic View Post
Dears

How Are you ?
Wish you are all fine

i am a fresh graduated Aerospace Engineer , during the 4 years in my department , i had to use matlab , so i didnt learn much about fortran or C/C++ .

i am started my Master Degree , and i will have to write a code for my simulation , and i really dont know what to choose , Fortran or C/c++ ??

someone told me that fortran is Dead , and people now uses C and learning fortran will make me a bad programmer , and it is a waste of time .

on the other side , someone told me that most of the big companies make its program based on fortran , and it is still being used and i really dont know want to choose ! My professor told me that i have to choose one and he refused to help me in choosing .

thank you very much
looking forward for your replies
C is dead, people now use JavaScript :P
arjun, flotus1 and ssh123 like this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   September 26, 2018, 08:02
Default
  #3
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by akidess View Post
C is dead, people now use JavaScript :P
, what do you prefer then ?
for cfd
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 08:25
Default
  #4
Senior Member
 
piu58's Avatar
 
Uwe Pilz
Join Date: Feb 2017
Location: Leipzig, Germany
Posts: 744
Rep Power: 17
piu58 is on a distinguished road
It depends on what you intend.

Fortran code ist often faster than C++, because of the pointer concept in C++. A C/C++ compiler cannot decide from the pointers wheter two memory objects are identical. Thes prevents some optimization.

Of course both, Fortran and C++ are faster (in principle) than Java or C#. This depends on their strong object orientation: You are forced to use objects even if you don't need them. Memory cannot be reused in an easy way, and the memory management may eat a lot of calculation speed.

I don't think that Fortran is dead. There still exist large Fortran libraries which are still in use.

If you primary intention is to learn programming a contemporary language, use C++. If you want to write the fastest possible program, Fortran could be the better choice.
ssh123 likes this.
__________________
Uwe Pilz
--
Die der Hauptbewegung überlagerte Schwankungsbewegung ist in ihren Einzelheiten so hoffnungslos kompliziert, daß ihre theoretische Berechnung aussichtslos erscheint. (Hermann Schlichting, 1950)
piu58 is offline   Reply With Quote

Old   September 26, 2018, 09:00
Default
  #5
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by piu58 View Post
It depends on what you intend.

Fortran code ist often faster than C++, because of the pointer concept in C++. A C/C++ compiler cannot decide from the pointers wheter two memory objects are identical. Thes prevents some optimization.

Of course both, Fortran and C++ are faster (in principle) than Java or C#. This depends on their strong object orientation: You are forced to use objects even if you don't need them. Memory cannot be reused in an easy way, and the memory management may eat a lot of calculation speed.

I don't think that Fortran is dead. There still exist large Fortran libraries which are still in use.

If you primary intention is to learn programming a contemporary language, use C++. If you want to write the fastest possible program, Fortran could be the better choice.
thank you for your informative reply
i am looking for a speed program beside a language that gives me a chance while searching for a PhD degree .
someone told me that acceptance may depend on the language you use , if they use C++ , they will need someone who knows C++.
so i am looking also for wide-usage beside speed .

what do you think about the part " fortran makes me a bad programmer " ?
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 09:50
Default
  #6
Super Moderator
 
Praveen. C
Join Date: Mar 2009
Location: Bangalore
Posts: 346
Blog Entries: 6
Rep Power: 19
praveen is on a distinguished road
If you are going to be doing computational work for a living, then you should learn all three of them.

The speed advantage of fortran is not so important today unless you are going to be doing massively parallel computations.

When you are a beginner, the speed difference between fortran/C/C++ is not a relevant thing to worry about. You can write badly performing code in any language.

However, you can easily write badly performing C++ code if you unthinkingly use advanced concepts in C++. It is less easy to write bad code in fortran and C.

If you are going to do be doing a lot of multi-dimensional array based coding, then fortran is nice for that. This means it is great for cartesian and structured grid codes.
ssh123 likes this.
praveen is offline   Reply With Quote

Old   September 26, 2018, 09:53
Default
  #7
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,460
Rep Power: 50
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Quote:
what do you think about the part " fortran makes me a bad programmer " ?
Who said that and in which context? I can't really wrap my head around this statement.
Sure, someone who uses goto in 2018 should be punished and I would consider that bad programming. But if you start learning now, just learn modern Fortran.
Sushobhan likes this.
flotus1 is offline   Reply With Quote

Old   September 26, 2018, 10:08
Default
  #8
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by praveen View Post
If you are going to be doing computational work for a living, then you should learn all three of them.

The speed advantage of fortran is not so important today unless you are going to be doing massively parallel computations.

When you are a beginner, the speed difference between fortran/C/C++ is not a relevant thing to worry about. You can write badly performing code in any language.

However, you can easily write badly performing C++ code if you unthinkingly use advanced concepts in C++. It is less easy to write bad code in fortran and C.

If you are going to do be doing a lot of multi-dimensional array based coding, then fortran is nice for that. This means it is great for cartesian and structured grid codes.
i am looking for the one which will live longer , the one that i can find many people use it . i fear that if i learnt fortran , people may stop using it , and i fear if i learnt C++ i won't find many who use it . i cant judge based on the environment i live in , i want to know how people outside see it .
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 10:10
Default
  #9
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by flotus1 View Post
Who said that and in which context? I can't really wrap my head around this statement.
Sure, someone who uses goto in 2018 should be punished and I would consider that bad programming. But if you start learning now, just learn modern Fortran.
this is exactly what he said to me

"
It is not because Fortran is hard, it is, but this is not a problem. It is not because it is a dead language, it is, but this is not its major flaw. It is because fortran will make you a terrible programmer, not a bad one, not a slow, underqualified one, but a terrible one. A programmer that no one will want to read, understand, or maintain their code. The code you will write in fortran will be dead before it compiles already.
Scientific and research software is written in fortran. That used to be the case, but not anymore. Enormous codebases have been rewritten in C/C++ (e.g LAMMPS, LAPACK, ...) and more things are being rewritten. No one starts a project today in fortran no matter what. Learning fortran today is like mastering the design of sail ships, a skill highly in demand up to the 18th century but no one needs to do it now. Learn, and master, professionally, C++ and use it for any scientific simulations you are working on. If you truly know how to use it, you will realize why fortran is not faster than C++ or anything of that sort. You just need to know what you are doing."
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 10:23
Default
  #10
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,349
Rep Power: 36
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by AeroSonic View Post
this is exactly what he said to me

"
It is not because Fortran is hard, it is, but this is not a problem. It is not because it is a dead language, it is, but this is not its major flaw. It is because fortran will make you a terrible programmer, not a bad one, not a slow, underqualified one, but a terrible one. A programmer that no one will want to read, understand, or maintain their code. The code you will write in fortran will be dead before it compiles already.
Scientific and research software is written in fortran. That used to be the case, but not anymore. Enormous codebases have been rewritten in C/C++ (e.g LAMMPS, LAPACK, ...) and more things are being rewritten. No one starts a project today in fortran no matter what. Learning fortran today is like mastering the design of sail ships, a skill highly in demand up to the 18th century but no one needs to do it now. Learn, and master, professionally, C++ and use it for any scientific simulations you are working on. If you truly know how to use it, you will realize why fortran is not faster than C++ or anything of that sort. You just need to know what you are doing."

In my personal very subjective opinion, I agree with the gist of the message. If you have to learn and program then use C++.

It is not just about writing the code one time, it is about maintaining it, adding and removing features to it and then reusing it in future.
arjun is offline   Reply With Quote

Old   September 26, 2018, 10:26
Default
  #11
Super Moderator
 
Praveen. C
Join Date: Mar 2009
Location: Bangalore
Posts: 346
Blog Entries: 6
Rep Power: 19
praveen is on a distinguished road
For a student, the language you use may depend on whether your advisor already has some code on which they want you to work.

Learning the basics of fortran/C/C++ wont take you too much time. You can do that over the course of your master program.

Mastering any one of them will take longer than your master program.

I think it is quite true that most new major scientific software projects are NOT started in Fortran and will be in C++. That means definitely learn C++ also.

You seem to be worrying about your future employment prospects. Then you should be ready to learn new skills. The days when you could master one skill and get lifelong employment in industry are probably gone.
praveen is offline   Reply With Quote

Old   September 26, 2018, 10:59
Default
  #12
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by arjun View Post
In my personal very subjective opinion, I agree with the gist of the message. If you have to learn and program then use C++.

It is not just about writing the code one time, it is about maintaining it, adding and removing features to it and then reusing it in future.
so in long run , and for editing , modifying , C++ is better ?
but isnt worrying to think about , that company like ansys use fortran inside its product ? it is like people still using it , and modify it .

i am sorry if i ask much , but i really want to be sure about my decision
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 11:01
Default
  #13
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by praveen View Post
For a student, the language you use may depend on whether your advisor already has some code on which they want you to work.

Learning the basics of fortran/C/C++ wont take you too much time. You can do that over the course of your master program.

Mastering any one of them will take longer than your master program.

I think it is quite true that most new major scientific software projects are NOT started in Fortran and will be in C++. That means definitely learn C++ also.

You seem to be worrying about your future employment prospects. Then you should be ready to learn new skills. The days when you could master one skill and get lifelong employment in industry are probably gone.

i think i will start from scratch , that is why my supervisor made it up to me to choose one of them .

so you think it will be better to learn C++ rather than Fortran right ?
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 11:20
Default
  #14
Super Moderator
 
Praveen. C
Join Date: Mar 2009
Location: Bangalore
Posts: 346
Blog Entries: 6
Rep Power: 19
praveen is on a distinguished road
Quote:
Originally Posted by AeroSonic View Post
i think i will start from scratch , that is why my supervisor made it up to me to choose one of them .

so you think it will be better to learn C++ rather than Fortran right ?
Yes, learn C++ if you are free to choose. Two books I liked

Bjarne Stroustrup, A Tour of C++ (Very short book, he also has a much bigger book on C++)

Peter Gottschling, Discovering Modern C++: An Intensive Course for Scientists, Engineers and Programmers

Once you have some experience coding in one language, it will be easier to learn another language, if you need to do so.
ssh123 likes this.
praveen is offline   Reply With Quote

Old   September 26, 2018, 12:03
Default
  #15
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Quote:
Originally Posted by praveen View Post
Yes, learn C++ if you are free to choose. Two books I liked

Bjarne Stroustrup, A Tour of C++ (Very short book, he also has a much bigger book on C++)

Peter Gottschling, Discovering Modern C++: An Intensive Course for Scientists, Engineers and Programmers

Once you have some experience coding in one language, it will be easier to learn another language, if you need to do so.
thank you
what is better , working on Windows or Linux ?
AeroSonic is offline   Reply With Quote

Old   September 26, 2018, 17:03
Default
  #16
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,213
Blog Entries: 29
Rep Power: 41
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
C++ is certainly giving you more chances to find a job. This is a fact.

Yet, today, Fortran is probably even more capable than C++.

Maybe FORTRAN created bad programmers 30 years ago. But today, if you are a bad programmer, it is only your fault.

Nonetheless, algorithms are naturally procedural, and fancy OO stuff is not gonna give you performance there.
AeroSonic likes this.
sbaffini is offline   Reply With Quote

Old   September 26, 2018, 19:27
Default
  #17
Senior Member
 
andy
Join Date: May 2009
Posts: 358
Rep Power: 19
andy_ is on a distinguished road
Quote:
Originally Posted by AeroSonic View Post
i am started my Master Degree , and i will have to write a code for my simulation , and i really dont know what to choose , Fortran or C/c++ ??
The choice of language would normally follow from the main language used by your group and the language of the libraries to be used. I would suggest asking your professor about the libraries that will be used on the course.

C++ is a ridiculous programming language but it is widely used. Fortran was the programming language for numerical methods but it has grown and rather lost it's way. C is a bit awkward but is likely the most flexible to use with other software, libraries and scripting. I would perhaps suggest C with a view to adding C++ and/or Fortran at a later date.
AeroSonic likes this.
andy_ is offline   Reply With Quote

Old   September 27, 2018, 02:21
Default
  #18
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 11
TurbJet is on a distinguished road
I would personally recommend C++. More and more open source solvers are based on C++ now. Those top-notch universities, e.g., Stanford, choosing C++ as their major language for their solvers, such as CharLES.

I don't think modern C++ would be slower than Fortran anymore. Many comparisons have been done on this topic. Well, at least for all I know, there is not much of difference between C++ and Fortran in terms of speed and efficiency.

Plus, the C++ has more active communities and more open-source libraries than Fortran does. Those linear libraries, such as Boost, Eigen, work very well on C++. They can be great resources if you want to use linear algebra libraries.

But I'll say C++ is difficult than Fortran to learn. The learning curve is pretty sharp. Fortran is much easier in this way. But personally, I am really uncomfortable with the Fortran syntax. They are really wired (from the way I see it).


PS: maybe in the future, Julia would be the major language in the CFD community. Who knows, right?
AeroSonic likes this.

Last edited by TurbJet; September 28, 2018 at 01:34.
TurbJet is offline   Reply With Quote

Old   September 27, 2018, 05:49
Default
  #19
Member
 
AeroSonic's Avatar
 
Yusuf Elbadry
Join Date: Sep 2018
Posts: 65
Rep Power: 9
AeroSonic is on a distinguished road
Thank you all

i think i am going to go with C++ , i see many says it is more use-able , more editable .

my question , should i work on Windows or Linux ?
AeroSonic is offline   Reply With Quote

Old   September 27, 2018, 05:53
Default
  #20
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,213
Blog Entries: 29
Rep Power: 41
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Quote:
Originally Posted by AeroSonic View Post
Thank you all

i think i am going to go with C++ , i see many says it is more use-able , more editable .

my question , should i work on Windows or Linux ?
Linux hands down... I can't think of a single library or relevant development tool that is available in Windows and not Linux.
Sushobhan and AeroSonic like this.
sbaffini is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User fortran to input/output file in a parallel run doublestrong CFX 5 March 31, 2017 09:15
Fortran Compiler-CFX12.1 Araz CFX 13 March 27, 2017 06:37
CFD Code Conversion from Intel Fortran to GNU Fortran pitto Main CFD Forum 4 August 4, 2016 15:51
Using Fortran with CFX: How to connect Fortran to CFX? l.te CFX 0 October 21, 2012 12:42
visual fortran Monica Main CFD Forum 1 August 28, 2004 21:45


All times are GMT -4. The time now is 11:46.