GCC SC approves inclusion of Algol 68 Front End

25 days ago (gcc.gnu.org)

In my mind this highlights something I've been thinking about, the differences between FOSS influenced by corporate needs vs FOSS driven by the hacker community.

FOSS driven by hackers is about increasing and maintaining support (old and new hardware, languages etc..) while FOSS influenced by corporate needs is about standardizing around 'blessed' platforms like is happening in Linux distributions with adoption of Rust (architectures unsupported by Rust lose support).

  • > while FOSS influenced by corporate needs is about standardizing around 'blessed' platforms like is happening in Linux distributions with adoption of Rust

    Rust's target tier support policies aren't based on "corporate needs". They're based, primarily, on having people willing to do the work to support the target on an ongoing basis, and provide the logistics needed to make sure it works.

    The main difference, I would say, is that many projects essentially provide the equivalent of Rust's "tier 3" ("the code is there, it might even work") without documenting it as such.

  • The big difference is that Algol 68 is set in stone. This is what allows a single dedicated person to write the initial code and for it to keep working essentially forever with only minor changes. The Rust frontend will inevitably become obsolete without active development.

    Algol 68 isn’t any more useful than obsolete Rust, however.

    • The core Algol 68 language is indeed set in stone.

      But we are carefully adding many GNU extensions to the language, as was explicitly allowed by the Revised Report:

        [RR page 52]
        "[...] a superlanguage of ALGOL 68 might be defined by additions to
         the syntax, semantics or standard-prelude, so as to improve
         efficiency or to permit the solution of problems not readily
         amenable to ALGOL 68."
      

      The resulting language, which we call GNU Algol 68, is a strict super-language of Algol 68.

      You can find the extensions currently implemented by GCC listed at https://algol68-lang.org/

      1 reply →

  • It's funny, I have a different view. Corporates often need LT maintenance and support for weird old systems. The majority of global programming community often chases shiny new trends in their personal tinkering.

    However I think there's the retro-computing, and other hobby niches that align with your hacker view. And certainly there's a bunch of corp enthusiasm for standardizing shiny things.

    • I think you both are partially right. In fact, the friction I see are where the industry relies on the open-source community for maintenance but then pushes through certain changes they think they need, even if this alienates part of the community.

  • I don’t know that that is fair.

    A number of years ago I worked on a POWER9 GPU cluster. This was quite painful - Python had started moving to use wheels and so most projects had started to build these automatically in CI pipelines but pretty much none of these even supported ARM let alone POWER9 architecture. So you were on your own for pretty much anything that wasn’t Numpy. The reason for this of course is just that there was little demand and as a result even fewer people willing to support it.

    • Not just little demand, also expensive and uncommon hardware. If the maintainers don't have the hardware to test on they can't guarantee support for that hardware. Not having hardware available often happens because there's little demand for it, but the difficulty of maintaining software for rare hardware further reduces the demand for that hardware.

    • At least it's been fine for four years of research software on a POWER9 cluster I support (with nodes like the Summit system's).

  • You nailed it. I am in the process in my spare time to maintain old Win32 apps, that corporates and always-the-latest-and-greatest crowd has abandoned.

    Most people don't care about our history, only what is shiny.

    It is sad!

  • Rust is by no means allowed in the core yet, only as drivers. So far, there are only a few drivers. Currently, only the Nova driver, Google's Binder IPC and the (out of tree) Apple drivers are of practical relevance.

As a fan of Algol 68, I'm pretty excited for this.

For people who aren't familiar with the language, pretty much all modern languages are descended from Algol 60 or Algol 68. C descends from Algol 60, so pretty much every popular modern language derives from Algol in some way [1].

[1] https://ballingt.com/assets/prog_lang_poster.png

  • Yes, massively influential, but was it ever used or popular?, I always think of it as sort of the poster child for the danger of "design by committee".

    Sure it's ideas spawned many of today's languages, But wasn't that because at the time nobody could afford to actually implement the spec. So we ended up with a ton of "algols buts" (like algol but can actually be implemented and runs on real hardware).

  • I would argue C comes from Algol68 (structs, unions, pointers, a full type system etc, no call by name) rather than Algol60

    • C had 3 major sources, B (derived from BCPL, which had been derived from CPL, which had been derived from ALGOL 60), IBM PL/I and ALGOL 68.

      Structs come from PL/I, not from ALGOL 68, together with the postfix operators "." and "->". The term "pointer" also comes from PL/I, the corresponding term in ALGOL 68 was "reference". The prefix operator "*" is a mistake peculiar to C, acknowledged later by the C language designers, it should have been a postfix operator, like in Euler and Pascal.

      Examples of things that come from ALGOL 68 are unions (unfortunately C unions lack most useful features of the ALGOL 68 unions. which are implicitly tagged unions) and the combined operation-assignment operators, e.g. "+=" or "*=".

      The Bourne shell scripting language, inherited by ksh, bash, zsh etc., also has many features taken from ALGOL 68.

      The explicit "malloc" and "free" also come from PL/I. ALGOL 68 is normally implemented with a garbage collector.

      19 replies →

    • That is indeed correct. Kernighan in his original book on C cited Algol 68 as a major influence.

  • > I'm pretty excited for this

    Aside from historical interest, why are you excited for it?

    • Personally, I think the whole C tangent was a misstep and would love to see Algo 68 turn into Algo 26 or 27. I sort of like C and C++ and many other languages which came, but they have issues. I think Algo 68 could develop into something better than C++, it has some of the pieces already in place.

      Admittedly, every language I really enjoy and get along with is one of those languages that produced little compared to the likes of C (APL, Tcl/Tk, Forth), and as a hobbyist I have no real stake in the game.

      18 replies →

    • I've actually been toying with writing an Algol 68 compiler myself for a while.

      While I doubt I'll do any major development in it, I'll definitely have a play with it, just to revisit old memories and remind myself of its many innovations.

  • If PL/I was like a C++ of the time, Algol-68 was probably comparable to a Scala of the time. A number of mind-boggling ideas (for the time), complexity, an array of kitchen sinks.

    • It certainly has quite a reputation, but I suspect it has more to do with dense formalism that was quite unlike everything else. The language itself is actually surprisingly nice for its time, very orthogonal and composable.

I find this great, finally an easy way to play with ALGOL 68, beyond the few systems that made use of it, like the UK Navy project at the time.

Ironically, Algol 68 and Modula-2 are getting more contributions than Go, on GCC frontends, which seems stuck in version 1.18, in a situation similar to gcj.

Either way, today is for Algol's celebration.

  • This makes me worry for the GCC implementation of Rust. People do not seem to use or upkeep the GCC versions of languages who primary Open Source implementations are elsewhere.

    • There is the advantage that GCC will be only way for Rust to be available in some targets where LLVM isn't an option.

      Regarding Go, gccgo was a way to have a better compiler backend for those that care about optimizations that reference Go compiler isn't capable of, due to the difference in history, philosophy, whatever.

      Apparently that effort isn't seen as worthwile by the community.

They can just fork off the Golang frontend and it would be the same, maybe patch the runtime a bit.

  • Being an old dog, as I mention elsewhere, I see a pattern with gcj.

    GCC has some rules to add, and keep frontends on the main compiler, instead of additional branches, e.g. GNU Pascal never got added.

    So if there is no value with maintenance effort, the GCC steering will eventually discuss this.

  • Does gcc even support go?

    • Until a few years ago, gccgo was well maintained and trailed the main Go compiler by 1 or 2 releases, depending on how the release schedules aligned. Having a second compiler was considered an important feature. Currently, the latest supported Go version is 1.18, but without Generics support. I don't know if it's a coincidence, but porting Generics to gccgo may have been a hurdle that broke the cadence.

      5 replies →

Where might one look to find examples of such code? I've never found algol outside of wikipedia

Will it compile Knuth’s test? https://en.wikipedia.org/wiki/Man_or_boy_test

  • That test is short enough to just paste it in here:

        begin
          real procedure A(k, x1, x2, x3, x4, x5);
          value k; integer k;
          real x1, x2, x3, x4, x5;
          begin
            real procedure B;
            begin k := k - 1;
                  B := A := A(k, B, x1, x2, x3, x4)
            end;
            if k ≤ 0 then A := x4 + x5 else B
          end;
          outreal(1, A(10, 1, -1, -1, 1, 0))
        end
    

    The whole "return by assigning to the function name" is one of my least favorite features of Pascal, which I suppose got it from Algol 60. Where I'm confused though is, what is the initial value of B in the call to A(k, B, x1, x2, x3, x4)? I'm guessing the pass-by-name semantics are coming into play, but I still can't figure out how to untie this knot.

    • Yeah that's one of the things the test was designed to catch: at that point, B is a reference, to the B that is being defined. Here's a C++ translation from https://oeis.org/A132343 that uses identity functions to make the types consistent:

          #include <functional>
          #include <iostream>
          using cf = std::function<int()>;
          int A(int k, cf x1, cf x2, cf x3, cf x4, cf x5)
          {
              int Aval;
              cf B = [&]()
              {
                  int Bval;
                  --k;
                  Bval = Aval = A(k, B, x1, x2, x3, x4);
                  return Bval;
              };
              if (k <= 0) Aval = x4() + x5(); else B();
              return Aval;
          }
          cf I(int n) { return [=](){ return n; }; }
          int main()
          {
              for (int n=0; n<10; ++n)
                  std::cout << A(n, I(1), I(-1), I(-1), I(1), I(0)) << ", ";
              std::cout << std::endl;
          }
      

      So in the expression `A(k, B, x1, x2, x3, x4)`, the `B` there is not called, it simply refers to the local variable `B` (inside the function `A`), that was captured by the lambda (by reference): the same B variable that is currently being assigned.

      1 reply →

  • No, because Knuth’s test was for Algol 60 and Algol 68 is a very different programming language.

ALGO 68 (dc) was the go to language for Burrough's [6-8]x00 variants.

These were fairly popular for awhile and supported advanced features like multiprocessing. The demand for exercising the full range of capabilities was kind of niche but an "amateur", like myself, could make a few bucks if you knew ALGOL.

I used to have the grey manual for the Burrough's variant - I'll have to poke around to see if it's in the attic somewhere.

Not relevant to GCC, but one use for an old A68 compiler was apparently to be adapted for the old NA Software Fortran 90 compiler, I was told by a former colleague. I'd have expected Ada to be a closer fit, and I don't know how well the decision worked out.

This is great news for GCC! I love how this decision supports older languages like Algol 68, keeping them alive in the FOSS world. It shows the hacker community's dedication to preserving diverse tools.

  • It is awesome.

    That said, it really stands out to me that the two latest GCC languages are Cobol and Algol68 while LLVM gets Swift and Zig.

    And Rust and Julia come from LLVM as well of course.

Wow that is cool. Pass by name. I always wanted to try it.

  • Algol60 had call by name, Algol68 doesn't really, it does have "proceduring" which creates a function to call when you pass an expression to a parameter that's a function pointer that has no parameters, you can use that to sort of do something like call by name but the expense is more obvious