Fortran compiler WIP in Go

With programming almost free, I notice that more people (including me) are trying to write Fortran compilers. Here is one in Go by tannevaled.

My ChatGPT dot says

It looks like a serious early engineering project, rather than just a collection of ambitious claims. It is still too early to judge whether it will become a useful general-purpose Fortran implementation or achieve its performance goals.

I inspected and tested version 0.5.0, at commit 5f329d8. The strongest signs are:

  • There is substantial working code for free- and fixed-form parsing, an AST, semantic analysis, and notebook-style session state. The tests address Fortran-specific issues, not just simple examples.
  • A small evaluator compiles supported constructs into typed closures. Its tests exercise array layout, matrix operations, loops, bounds, and rejection of unsupported constructs. Evaluator tests
  • The project has fuzz and resource-exhaustion tests, differential testing against gfortran, and a framework for comparing execution backends. The latest commit describes a detected semantic regression and a targeted fix, which is a good sign of an actual test-and-correct cycle.
  • I built it and ran its Go tests on Linux: all 10 test-bearing packages passed, as did race tests and vet. A WebAssembly cross-build also succeeded. Sixteen tests requiring external tools or corpora were skipped, so that is not a full validation. A cross-build does not establish that browser execution works.

Fortran needs a bootstrapping compiler in modern Fortran itself! Had a top-notch intrinsic string type been available from the onset, or at least since Fortran 2003, this would have been much easier.

Now this is the task worthy of a capable ai assistant, I wonder if the assistants used by @Beliavsky , @jacobwilliams et al are capable of this?

1 Like

Another new project:

The supported language is Fortran-like

N = 5
FACT = 1
DO I = 1, N
  FACT = FACT * I
END
PRINT FACT

but actual Fortran

N = 5
FACT = 1
DO I = 1, N
  FACT = FACT * I
END DO
PRINT*,FACT
END

is rejected. The site runs the program and displays bytecode.

(I remember, like 15-20 years ago, Richard Maine saying something similar at c.l.f.)

I understand that interpreted languages need to be implemented in some other languge. But for a compiled one, that actually prevented people from contributing.

1 Like