BCPL - an even simpler compiler?

One can look at BCPL as the definition of a bootstrappable version of CPL. That doesn’t quite mean it can self-host, but I’d be surprised it if couldn’t. You’d need to have some determination though.

There are already two good references in this thread:

I suspect most people with a C compiler to hand would not then try to use BCPL instead. We’re seeing BCPL used in retrocomputing because it’s easier to implement. Back in the day, Acornsoft provided a BCPL and I think wrote applications using BCPL too. Over in the land of Apple there was P-machine Pascal. And then along came Turbo Pascal.

(We should note that both CPL and Pascal are attempts to improve on Algol.)

1 Like

Yes - the compiler is self hosting, once you have the cintcode VM running and that’s the thing written in C, so compile that (actually that plus the cintsys which is the front-end) and you have a working BCPL system that can compile it’s own compiler.

The source to cintsys and the cinterp is fairly standard C so ought to be easy to compile.

In my implementation I wrote the bytecode interpreter from scratch in native assembly (65c816). The BCPL compiler is itself written in BCPL, so there is a bit of a bootstrap paradox, so the binary compiler I use on my system is compiled on my desktop using the VM written in C, however that is capable of compiling the compiler should I desire.

You may find a version of cintsys pre-compiled for windows, although it’s not an environment I’m familiar with.

This system ought to be more than capable, although my system has 512KB of RAM. You may not be able to run the compiler directly in 256KB though - the current BCPL compiler is rather memory hungry though. I modified the compiler and compiled it on my desktop Linux to use much less memory though. (by trial and error, to work out just how much RAM it allocates to compile itself - I think I’ve gotten it down to about the 350KB mark, but to compile smaller programs you need much less).

You will need to write the arithmetic intrinsics though, so +, -, * and / (and mod/rem) as well as a MULDIV routine. The current BCPL system assumes a 32-bit (or 64-bit) virtual machine but it also needs non-aligned byte level addressing. (And non-aligned halfword, 16-bits) No need to write any floating point stuff to start with - you can compile and run integer only programs without support for it.

My system cheats somewhat in that the bulk of the filing system code is written in C on a separate MCU (ATmega) It supports ‘disks’ of up to 32MB in size.

Hope it works well and do let us know how it goes.

-Gordon

That is very interesting as it seems to say B was a derivative of Fortran.

And yet if you look at some B programs they are very much BCPL or early C in their appearance.

Which doesn’t mean it may not have been FORTRAN derived but old memories are funny things at times…

-Gordon

Yes, especially when you are expressing them as stories. It’s possible he substituted Fortran for BCPL as Fortran is better known. It’s also possible that he started with Fortran and in his removing and revising added a bunch of features he’d seen in BCPL or related languages.

The the C Session entry written by Dennis Ritchie in History of Programming Languages II seems to support that idea.

2 Likes

That’s my opinion, is that the Fortran line was intended to be a story, not a history, and Fortran played well. It has been a long time, I’m sure Fortran was certainly “in the air” at the time.

Note that Ritchie does say “after a rapidly scuttled attempt at FORTRAN”.

1 Like

There is at least one OS written in FORTRAN (to my knowledge) and that was PRIMOS which ran on the PRIME minicomputers starting round about 1972. This should be separate thread if anyone is interested though but my own personal thoughts after using these beasts is that they all should have been scuttled, however…

-Gordon

1 Like

The first version of the Norsk Data SINTRAN operating system (later referred to as “SINTRAN-I” is supposed to have been implemented in FORTRAN in 1968. The versions that followed were not.

1 Like

Are you teasing us? You know we’re interested!

2 Likes

Quite a few of the early Unix tools were written in Fortran. Or more, accurately, written in ratfor. This allowed the tools to run on other systems at Bell Labs, since most computers of the 1970s shipped with some form of Fortran compiler.

Pascal was tried and rejected as the language for Kernighan and Plauger’s Software Tools, as BWK explained in “Why Pascal is Not My Favorite Programming Language”.

3 Likes

The “UNIX: A History and a Memoir” by Kernighan also mentions Fortran quite many times.

2 Likes

In the 70’s FORTRAN was the PORTABLE languge. PLM for CP/M was written Fortran 66,
PAL programing software,are two that come to mind. 8008 and 4004 cpu’s cross assemblers
may have been. Timshareing was the answer but unix was not the place, PDP 10’s and IBM 370’s were.
Late 1970 and early 80’s PDP 11’s had major impact. Several programing languages came out for the 11,
that seem to have been lost in time. Scotland seems to have created lots of intersting software at the time,

1 Like

Just having fun with BCPL. I used it on a course at university then later professionally on an EFTPOS system for payment terminals in Melbourne. And now just having fun reviving my skills after forking the github repo…
I have been trying the lisp emulator too - that is also a buzz.

4 Likes

I was introduced to BCPL at university; the electronics department at Southampton were keen on it and it ran on their 6809 “sexorciser” (Motorola Exorciser clone) systems. A nice feature was that the definitive text, by Richards & Whitby-Strevens, only cost £4.95 (1983).

I seem to remember that I frequently heard the comment “BCPL is an ideal language in which to implement… BCPL”. I think it shares that distinction with Pascal.

Have not seen it mentioned here… BCPL was the main implementation language of the Xerox Alto. Much of the source code is available on github

1 Like