5 ms·
I remember having a "malloc" moment moving from fortran to c. "You mean ... I can just ask for more memory?!"
by kitd 6y ago
I remember having a "malloc" moment moving from fortran to c. "You mean ... I can just ask for more memory?!"
- kergonath 6y agoInterestingly, since Fortran 90, using dynamical allocation is much more developer-friendly than in C (I know, low bar). Fortran’s allocatable variables can’t leak memory, can’t be used after being deallocated, and can’t be deallocated twice. Bounds checking is also trivial and all decent compilers have a flag to do it automatically.
- necheffa 6y agoThe only problem is that the rest of the language is developer unfriendly, plus you have old school FORTRAN programmers who think it is perfectly acceptable and modern to use statically allocated arrays on the stack just because they aren't COMMON blocks.
- kergonath 6y agoFair enough. The language has quite a bit of bagage and some habits are hard to break. That said, it is not unpleasant to use for numerical codes, when you’re not working with people stuck in 1977 (so, no common blocks, everything in modules, decent array syntax, etc). It fits its niche quite well, with Python for everything else.
- pletnes 6y agoInterestingly the language doesn’t define stack/heap allocated so sometimes there’s a compiler flag to put «stack arrays» on the heap, since implementations are free to choose anyway.
- pletnes 6y agoYou can do that in Fortran, too, since 1990ish. Out of curiosity, when did you last write Fortran code?
- kitd 6y agoThis was F77. Never had the joy of F90