![]() So there are no differences? Well, not quite. So the main difference is in the programmer, not the language. I would, however, never write anything on my own in Fortran since I'm more comfortable with C and, as a consequence, the resulting code will be better, whatever you define that as. I did, however, also spend three years working in a group that used only Fortran, in which I have achieved a certain level of fluency. I myself consider C to be my "native" programming language. Ever notice how most authors or poets prefer to write in their native languages? Would you want to write poetry in a language in which you don't feel completely confident or at home? Of course not. This now leads to my second point: why do we still see differences? The problem is that most comparisons are made by Fortran programmers trying something in C or vice-versa. If you write, semantically, the same code in Fortran or in C, the compiler will, in both cases, produce the same assembly which will run just as fast. your program will be transformed into an abstract description by the front-end and then optimized and assembled by the back-end. Both gcc/gfortran and icc/ifc are just different front-ends to the same back-end, i.e. Dedicated C/Fortran compilers are a thing of the past. That's where C is too, so I'll replace C with C++ for the following.įirst of all, any discussion of Fortran/C having better compilers is moot. Yes, some modern implementations of the latest Fortran standards can do more than just that, but very few people actually use them, and so when we speak of Fortran, we think simple, static, and imperative language. Why? Well, otherwise it's apples and oranges to compare a full-fledged dynamically typed object-oriented language with something as static as Fortran. Note in the following that I will talk about C and not C++. I'm also throwing my two cents in kind of late, but I've only just seen this thread and I feel that, for posterity, there are a few points that desperately need to be made. I have spent over 2 years of programming in C++ daily, and almost a year programming in modern Fortran daily (in finite elements area). Non-experts tend to write pretty good Fortran programs, but horrible C++ programs (talking from my own experience).ĭisclaimer: I personally like Fortran a lot and I prefer it over C++ for numeric computing. ![]() one needs to create or reuse classes for array manipulation, and handle memory management by hand or using some library like Teuchos from Trilinos). It is also possible to write array algorithms in C++, but in my experience, it requires much more computer science knowledge and in general more work (i.e. In particular I think that it is easier to write fast programs in Fortran than in C++, by a scientist (not necessarily a computer science expert).Ĭ++ is a general purpose language, so one can express any algorithm in it, and it is most definitely better for algorithms that can't be expressed using arrays, from HPC field probably some graphs, mesh generators, symbolic manipulation and so on. However I think that Fortran is better for numeric scientific computing, for algorithms that can be expressed using arrays and don't need other sophisticated data structures, so in fields like finite differences/elements, PDE solvers, electronic structure calculations. I think that both C++ and Fortran are good enough and work well. Always remember that your time is more valuable than CPU time! I'd recommend to anyone going into computational science to start with a dynamic high-level language such as Python. However, there's more to programming than just Fortran and C++. Assuming, of course, that your problem is suited to Fortran. ![]() If you start out with little programming experience and only have so much time to learn that aspect of your job, you probably get a better return on investment learning Fortran than learning C++. Skill dependence: it takes a lot more programming experience to write good C++ programs than to write good Fortran programs. C++ is better suited for complex and highly dynamic data structures. Fortran programmers end up using arrays even in non-obvious cases (e.g. If your problem can be described in terms of simple data structures and in particular arrays, Fortran is well adapted. ![]() ![]() Problem dependence: Fortran excels at array processing. I'll leave (3) aside for the moment because it depends on everyone's individual situation. As so often, the choice depends on (1) the problem you are trying to solve, (2) the skills you have, and (3) the people you work with (unless it's a solo project). ![]()
0 Comments
Leave a Reply. |