Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not for speed reasons alone. It's certainly possible to tune C code to have roughly equivalent performance to Fortran.

The real appeal for using Fortran is that for beginners it's a much easier language to pick up than C (much less footguns, for one), and that working with (dense) multidimensional arrays is very nice, roughly on par with high-level languages like numpy, R, or MATLAB.



To expand on this, I think the footguns you're talking about are specifically performance related.

Just an example: How do you specify a fast readonly array in C? If I recall correctly it's

restrict const * const int my_array[n]

In Fortran?

integer(4), intent(in) :: my_array(n)

Not even starting with array ops, multidimensionals, array slicing etc., that's already a big win in readability. Having a pass-by-reference language by default is refreshing for HPC purposes.

That being said there are disadvantages compared to C. Biggest one IMO is the lack of inline declarations, which especially makes privatizing things in OpenMP and OpenACC code a bit more tricky, i.e. it needs to be explicit.


> How do you specify a fast readonly array in C?

Generally in the function declaration rather than the variable declaration, but to declare a non-aliasing pointer to array of constant ints would be

  const int (restrict *my_array)[N];
or

  int const (*restrict my_array)[N];
and the other two variations thereof.


Gentle reminder to future language designers: whatever else you decide to take from C, please, please don't take declarator syntax. This thread showcases why.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: