Remix.run Logo
PL/0(en.wikipedia.org)
44 points by tosh 3 days ago | 13 comments
dtoffe 2 minutes ago | parent | next [-]

To all interested in this little treasure, I transcribed the source code of the PL/0 compiler from the book "Algorithms + Data Structures = Programs", published by Nicklaus Wirth in 1976, and adapted it to run in Free Pascal.

You can find the sources here: https://github.com/dtoffe/adsp-pl0

Some interesting notes:

- The original compiler does not define nor implements "read" or "write" statements, as was the norm in later PL/0 implementations. - The source code in the book corresponds to the implementation in the CDC 6000 that Wirth had at hand back then. That machine used the CDC Display Code:

https://en.wikipedia.org/wiki/CDC_display_code

a 6 bit character code from before the ASCII times. Among its 64 characters, it includes single symbols for "<>", "<=" and ">=". In an attempt to change the code the least to make it run as original as possible, I changed those three character to #, { and }, as the symbols in the lexer are implemented using an array of char (only the assignment is treated as a special case).

- The interpreter printing out the values of every variable assignment, noted by another reader of this post, was a way of getting some information of the running program, since the compiler does not implement read or write statements.

- Following the compiler code, full of single letter variable names, was not the most exciting part.

timonoko an hour ago | parent | prev | next [-]

Duck me sideways. I must have read this book, because I wrote Pascal-like compiler for 8080, by the order of Finnish Army in 1977. All I remember that I invented tail-recursion all by myself.

https://photos.app.goo.gl/xeDuC7LDvo2ABMGo9

Me myself find this remarkable, because I could not get to the "Digital Science"-faculty because of bad scores and inappropriate hairdo.

cmrdporcupine 8 minutes ago | parent | prev | next [-]

The older I get the more I prefer Wirth syntax languages with keyworded blocks and := assignment operators, and regret how C block syntax and =/== took over.

I learned first on Pascal & Modula-2 and only picked up C later and while I appreciated its terse minimalism at the time and through the 90s, I actually don't at all now. I find it less readable.

weinzierl 2 hours ago | parent | prev | next [-]

"The publisher of Wirth's books (Addison-Wesley) has decided to phase out all his books, but Wirth has published revised editions of his book beginning in 2004."

That is sad, but the revised editions seem to be published online.

verbatim 3 hours ago | parent | prev | next [-]

Interesting. The article states "The compiler prints the value as a given variable changes." -- surely it means the program does, and not the compiler?

dtoffe 21 minutes ago | parent | next [-]

The compiler produces p-code to be interpreted by an interpreter, so it is the interpreter that prints the value.

compiler-guy an hour ago | parent | prev | next [-]

It might be more precisely stated something like "The language's semantics require that when a variable changes value, that change includes the side-effect of printing the new value."

monocasa 3 hours ago | parent | prev [-]

I take it to mean that the compiler inserts variable print code on variable modifications.

js8 3 hours ago | parent | prev | next [-]

Any relation to PL/I?

ginko 3 hours ago | parent | prev [-]

Why were forward slashes so popular in computing product names in the 70s and 80s?

PL/0, PS/2, CP/M, etc.

spogbiper 2 hours ago | parent | next [-]

I think it started with IBM: System/360 and /370, PS/2, OS/2, PL/I

And then Gary Kildall also seemed to like it with CP/M and PL/M, but those were after IBM had used it and I'd guess Gary was just copying IBM.

Between just those two influences you cover a huge portion of the mainframe and micro computer worlds during the 60s-80s

azhenley 2 hours ago | parent | prev | next [-]

It was a convention to denote a variation or version. Not sure how the trend started though.

theanonymousone 2 hours ago | parent | prev [-]

Maybe referencing the reputation of IBM System/360?