Fortran-like language: boreas

Fortran mostly evolves in a backwards-compatible way. I have wondered what a statically typed language for scientific programming would look like without that constraint. The following project, which I think is interesting, is one answer. It is more concise than Fortran, which has been criticized for verbosity. ChatGPT mostly approves of it.

A converter from Fortran to boreas is provided. A Fortran programmer can quickly grasp boreas code, for example

! Boreas: a Fortran-flavored language. Keywords are case-insensitive.

function square(real :: x) -> real
  return x * x
end function

function fib(int :: n) -> int
  if n < 2 then
    return n
  end if
  return fib(n - 1) + fib(n - 2)
end function

program demo
  int :: i
  int :: count = 0
  real :: total = 0.0
  real[5] :: xs
  int[5] :: ys = [1, 2, 3, 4, 5]

  do i = 1, 5
    xs[i] = square(real(i))
    total = total + xs[i]
  end do
  println("squares:", xs)
  println("total =", total)

  ys = ys * 2 + 1                 ! whole-array arithmetic
  println("ys =", ys, " middle =", ys[2:4])

  do i = 1, 20
    if mod(i, 3) == 0 then
      cycle
    else if i > 10 then
      exit
    else
      count = count + 1
    end if
  end do
  println("kept", count)

  println("fib(15) =", fib(15))
end program demo

If I work on a language variant it will be convertible to Fortran. For example, the ofort REPL converts const n = 5 to integer, parameter :: n = 5.

1 Like