Hacker Newsnew | past | comments | ask | show | jobs | submit | dtoffe's commentslogin

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.


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


String theory ? (Impersonating Leonard, while ducking and receiving a hard look from Sheldon...)


It looks like you are forcing me to learn OCaml.....


If you want to overcome introversion and develop peoples' skills, it is not enough to "talk a lot and say nothing". You need to feel comfortable and confident, adapt to the speaking style of others, react to their communication cues, etc. Read a lot about body language, listen to how other people speak, and start trying to imitate some phrases and topics. Besides, learn a bit about different topics you would usually not speak about, you don't need to know a lot to be able to keep a small conversation about sports, cars, gardening or literature. And if you include those topics in your small chat, you will eventually learn more. Have small chats with the janitor, the store cashier, the taxi driver, etc. Smile and be kind, people will generally be kind to you as well. There are advanced courses on oratory, public speaking and the like, but you probably need to feel confident with the basics first.


I started searching for the same thing a couple of years ago after I saw the same Hejlsberg interview posted by sarosh. The only recommendation I was able to get was to read the Roslyn source code and the LSP reference. I could not get any reference regarding, for example, how would one build a parser that incrementally modifies the AST as you type. And regarding PLT, I would think those subjects have to do with the semantics of the language, and are orthogonal to the technology to build the compiler. But I'm not an expert, and could easily be wrong...


Thanks, that makes sense re PLT. One thing I have heard is that PLT can be viewed as a "programming languages" approach to math foundations, or at least the foundations of computation, and largely doesn't have to do with programming language implementation, but not everyone seems to share that view. And I recently saw a comment from someone who said they worked on compilers list abstract interpretation as something for budding (industrial) compiler workers to learn[1].

I have a math background so of course I'm drawn to this stuff, but I have trouble imagining it being immediately useful for implementers. Could it be that this stuff is more useful for language design than implementation?

[1] https://news.ycombinator.com/item?id=20915485


I don't know what "abstract interpretation" is, can't help you with that. If you are interested in the real life implementation of theoretical PLT concepts, I'm not sure if this might help, but there is this page: https://www.ponylang.io/blog/2017/05/an-early-history-of-pon... where the designer of the Pony Language tells the history of how he did a Ph.D. on sound stuff and then went to design Pony. You can probably start hunting papers from this trail. Personally, I'm nostalgic of the Wirthian languages, and started developing a PL/0 compiler with an LLVM backend, before some day, if hopefully I ever develop all the needed skills, put all the Wirthian languages in a cocktail shaker, add a dash of new PL concepts, and see how that tastes.


Native Spanish speaker from Argentina, just created an account to answer this. First, you should probably decide what regional variant to learn, and stick with it. There are subtle but noticeable differences in style, words and accent between, say, Mexican, Spanish and Argentine "Spanish". If you only want to practice reading, you could probably go for books of acknowledged writers (García Márquez, Vargas Llosa, Borges, etc). It depends very much on your preferences, you can search something related to your hobbies or your work. Hope this helps.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: