Side-by-side, interactive cheatsheets for Fortran programmers
comparing Fortran to other languages. Every example runs live in your browser β no setup, no installation.
Choose your own path by reordering languages
Where a Fortran programmer stops declaring the machine and starts describing the problem. Ruby trades static types, kinds, and fixed-size arrays for a dynamic, garbage-collected world where every value β even an integer β is an object, arrays are 0-based and grow on demand, and dictionaries, closures, and exceptions are everyday tools.
implicit none, no KIND β a variable takes any object on assignment, and integers grow to arbitrary precision with no overflownumbers[0], and push/pop resize in place, with no allocatable or allocateEnumerable β map, select, and reduce replace the index loops and temporary result arrays you write by hand in Fortranraise and begin/rescue/ensure replace iostat status codes and the halt-only stop/error stopπ¨ Python alone is the wrong comparison β the right one is NumPy. A pure-Python loop over numbers runs roughly a hundred times slower than the Fortran it replaces, so a reader who ports a kernel that way concludes the move was a mistake. NumPy is a Fortran-shaped library wearing a Python face: typed, fixed-shape, contiguous arrays with whole-array operators, and numpy.linalg calling LAPACK, which is itself Fortran.
a * 2 repeats it and a + b concatenates β both legal, neither arithmetic, and no error to tell you. Port array code to NumPy, never to listssum/maxval as reductions, WHERE as a boolean mask, matmul as @, transpose as .Tvalues(2:4) becomes values[1:4], the cache-friendly loop nesting flips, and the arbitrary lower bound (dimension(0:n)) is gone with no replacementintent(in)/intent(out) have no equivalent, and neither does implicit none β a misspelled name on the left-hand side quietly creates a second variableintent attributes you already write, turns an intent(out) argument into the return value, and handles the layout transposition β so the realistic end state is a Fortran core with a Python shellThe other ubiquitous systems language β but C is row-major where Fortran is column-major, and passes by value where Fortran passes by reference, two classic sources of real interop bugs between them.
intent(out) parameter needs an explicit pointer and & in Cpow() from <math.h> is the only way, and ^ means bitwise XORWhere column-major stops being a rule and becomes a stride constant. The conventions a Fortran programmer works around every day β 1-based subscripts, everything by reference, the trailing underscore, the array descriptor β are all visible here as offsets, addresses and symbol names.
intent(in) included, so a call site is a row of lea instructions rather than movssubroutine work becomes the symbol work_ β lowercased and underscored, which is exactly what you must write on the C side when linking by handvalues(:) argument arrives as a descriptor β a struct holding the pointer and the bounds β which is why size() works inside the callee and why an explicit interface is mandatoryBuilt for exact money math, not floating-point science. COBOL's PIC 9V9 fixed-point fields store decimal digits exactly β the opposite tradeoff from Fortran's binary REAL/DOUBLE PRECISION, which is precisely why COBOL, not Fortran, runs the world's bank ledgers.
PIC 9V9 fixed-point decimal fields store money exactly β no IEEE 754 rounding error the way Fortran's REAL always carriesprogram ... end program blockINTENT system, just shared global WORKING-STORAGE fieldsLOGICAL type β there is no boolean type otherwiseMOVE, not =, is the assignment verb, and CALL can only invoke a genuine subprogram, never a paragraphA close cousin from the same structured-programming era. Pascal's var/const parameter modes map almost directly onto Fortran's intent(inout)/intent(in) β but Pascal has no whole-array arithmetic at all, unlike Fortran.
var and const parameters mirror Fortran's intent(inout)/intent(in) almost exactly β a rare direct correspondenceprices := prices * 0.9 needs an explicit for loop, unlike Fortran's native array arithmetic** exponentiation operator β Power() from the Math unit is the only way to raise to a powerrepeat...until is a post-tested loop with no direct Fortran equivalentBuilt for exactly Fortran's audience β high-performance numerical computing β with Python-like syntax and an intent-like argument model.
mut parameters map onto Fortran's intent(inout) almost directly β borrowed (read-only) is the default, just like intent(in)SIMD[DType, width] vector types are an explicit, type-level take on the same hardware vectorization Fortran's compiler infers automaticallyraise/raises gives Mojo a genuine catchable-error mechanism Fortran has never hadBuilt explicitly to replace Fortran in scientific computing. Julia arrays are column-major for BLAS/LAPACK compatibility, just like Fortran β but * means real matrix multiplication in Julia, not the elementwise operation it always is in Fortran.
* between two matrices is genuine linear-algebra multiplication in Julia; Fortran's * is always elementwise, with matmul() for the real thingArray programming taken to its extreme. Where Fortran writes a loop over each element, APL has no loop at all β 2Γ1 2 3 4 5 doubles a whole array in one glyph, and reduction operators replace both sum() and hand-written accumulator loops alike.
2Γnumbers scales a whole array with no do loop, more radical than even Fortran's own native array arithmetic2Γ3+4 is 14, not 10, a rule Fortran's ordinary math notation shares nothing with+/, Γ/, β/) replace Fortran's sum(), product loops, and maxval() all with one composable operator(+/Γ·β’) is the average function, something Fortran has no syntax to expressThe other vector-native language β but where Fortran demands exact shape conformance for elementwise arithmetic, R silently recycles mismatched-length vectors to fit.
numbers * 2 needs no loop in either languageLOGICAL equivalent β a variable's type is just whatever value it currently holdsNA is a first-class missing-value marker with no Fortran equivalent β the closest approximation is IEEE NaNCloser than it looks. Odin is one of the very few modern languages that kept whole-array arithmetic, ships a builtin matrix type with real matrix multiply, and has complex as a primitive β then adds slices that carry their length, real generics, and #soa.
prices * 0.9 scales every element, at any length, with no loop and no temporarymatrix[R, C]T is builtin and * is a genuine matrix product, so matmul(a, b) becomes a * b β and complex keeps its operators toolen is always right and no interface block has to stay in syncallocatable becomes make/delete plus defer β no automatic deallocation, but an arena can hand a whole solve its own memory and drop it in one call#soa is the array-of-derived-type split without losing the field syntaxThe language Forth was written to replace, on the job it was written for. Forth's first real work was pointing radio telescopes at the National Radio Astronomy Observatory β work otherwise done in Fortran and assembly β and Charles Moore wrote it because the alternatives were too slow to iterate with on a machine sitting at the instrument. No other pair on this site carries a language's birth.
DO, and they disagree: Fortran's bounds are inclusive, Forth's are half-open and the limit is pushed FIRSTDIMENSION becomes CREATE β¦ ALLOT β an address, no shape, no bound, and a count you keep correct by handCOMMON block is the default rather than a thing you declareREAL at all in this build: fractional quantities are scaled integers printed with pictured numeric outputimplicit none to remember β an unknown word is an error when the line is read, not a new variable