News for hackers. Stuff that matters.
Re:T3X – a minimal procedural language by nils-m-holm on Friday May 05, 2017 @05:15PM (#14276895)
Thanks! Decades of experience! :)
Re:T3X – a minimal procedural language by i336_ on Saturday May 06, 2017 @01:15AM (#14278799)
What might you recommend to someone who wants to to learn more about these subjects?

For example, http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm... is extremely interesting, but a lot of it is over my head.

I guess at the end of the day there's no real alternative to "just dive into the source code for a while" with these sorts of things - hence the importance of having "decades of experience" under your belt - but I'm curious if there's anywhere in particular that you might recommend as a startpoint.

Re:T3X – a minimal procedural language by nils-m-holm on Saturday May 06, 2017 @02:58AM (#14279095)
Yes, examples of minimal ELF files are good starting points for getting the back end part up and running. I'm not sure that reading real-life code will get you very far, because it often deals with lots of edge cases and attempts to be efficient and generate clever code. However, there are compilers that have been made as educational tools or with simplicity as a major design goal. I would stick to those in the beginning. See my home page (http://t3x.org) for lots of examples!

Then, books. I'll make a list some day, I promise! ;) From the top of my head: Wirth's "Compiler Construction", Richard's "BCPL, the Language and its Compiler", and - shameless plug - "Practical Compiler Construction" by myself. I have also read the Dragon Book back then - it's good, but too heavy on theory for a beginner.

Re:T3X – a minimal procedural language by i336_ on Sunday May 07, 2017 @05:39AM (#14284645)
> Yes, examples of minimal ELF files are good starting points for getting the back end part up and running.

Mmm, one of several components.

> I'm not sure that reading real-life code will get you very far, because it often deals with lots of edge cases and attempts to be efficient and generate clever code.

Very good point. It takes a bit more time and effort to build a proper mental map, but there's really no worthwhile alternative.

> However, there are compilers that have been made as educational tools or with simplicity as a major design goal. I would stick to those in the beginning.

I agree! These help a lot, and make study almost (if not very) fun :)

> See my home page (http://t3x.org) for lots of examples!

Will do, thanks!

> Then, books. I'll make a list some day, I promise! ;) From the top of my head: Wirth's "Compiler Construction", Richard's "BCPL, the Language and its Compiler", and - shameless plug - "Practical Compiler Construction" by myself. I have also read the Dragon Book back then - it's good, but too heavy on theory for a beginner.

Interesting. I actually stumbled on a copy of the Dragon Book while at an op-shop some time ago. I didn't actually know what I was grabbing at the time, just that it looked like a really good idea to prioritize getting it. I'm very happy to have it, and hope to be able to make sense of it at some point :)

Looks like Wirth's Compiler Construction can be found at http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf

BCPL, the Language and its Compiler and Practical Compiler Construction don't seem to have free options; that's fine, I've added these (and your other books!) to my (burgeoning) wishlist :P

Re:T3X – a minimal procedural language by JdeBP on Saturday May 06, 2017 @06:04AM (#14279566)
There is also Practical Compiling With Pascal-S by Rees and Robinson (ISBN 9780201184877), which took the same approach as you do, 30 years ago.
Re:T3X – a minimal procedural language by nils-m-holm on Saturday May 06, 2017 @09:13AM (#14280085)
Interesting, thanks! Ordered a copy.
Re:T3X – a minimal procedural language by bluetomcat on Saturday May 06, 2017 @03:29AM (#14279165)
Another really cool and intricate aspect of your compiler is that scanning/parsing/generation are all done in a single pass. I'm not too convinced whether there is a practical benefit to that, but it certainly contributes to the small size of the compiler and reduces the memory footprint, since it eliminates the need for keeping the list of tokens or the parse tree in memory, effectively only using the stack as storage?
Re:T3X – a minimal procedural language by nils-m-holm on Saturday May 06, 2017 @09:11AM (#14280077)
The biggest benefit is simplicity, the greatest drawback is lack of extensibility (optimizer, etc).

Memory footprint is not really optimal, because T3X9 keeps both the entire source code and the entire executable in memory all the time. I wanted fast compilation, though. For small footprint, I would have made it a two-pass compiler.

An early T3X compiler ran in tiny on DOS (64KB for code and data).