Hacker News new | ask | show | jobs
by wincent 1573 days ago
> I get annoyed because I have to work around C's warts to do what I want, and that is only happening because I think in my language

You "just" have to get to the point where your compiler is written in your own language. This may take a while. Go got there in V1.5:

https://go.dev/doc/go1.5

1 comments

It's funny/interesting that an 1kloc implementation of minimal self hosting Go exist, or C/pascal/oberon compilers ; perfect hindsight view etc. You theoretically could (well if nobody does, no you can't) create a nice language and its implementation quickly.
Wirth was even more drastic in what concerns writing bootstraped compilers.

I don't recall in what paper from him I have read this, so take the story with a grain of salt, also open to corrections.

He actually wrote the initial version of the compiler directly in Pascal.

How did he perform such thing, one would ask.

By writing it on paper using a Pascal subset good enough as stage 0, and then manually compiling the source code into corresponding Assembly instructions that he would then actually type into the cards.

So when he finally got the compiler done, it was already bootstrapped from the get go.

Additionally, P-Code originally wasn't designed to be an interpreter, rather to repeat the above process in an easier way across computer systems.

He was initially surprised that others took it to write Pascal interpreters instead of a bootstrapping tool.

I've never been megalomaniac enough to think I could design a new language. But I did once write a Pascal source-level debugger; I think the compiler was Intel Pascal (long time ago). It taught me a lot about how the compiler worked, and how the language worked.

I've used to suffer quite badly from Impostor Syndrome, and that project did a lot to alleviate my symptoms.

I never shared the project with anyone else; it was never completely finished.

Nice story, thanks for sharing.

My hard drive is full of unfinished projects, started to learn about programming language, or try out new design approaches, quickly abandoned after the initial goal was achieved.

Regarding imposter syndrome, two guidelines that have helped me in such situations, are "only repent for paths not taken", "failure is better that not knowing at all".

Obviously those quotes aren't from me.

> It's funny/interesting that an 1kloc implementation of minimal self hosting Go exist

Does it? That's not the technique Go introduced, they started by rebuilding Go from earlier versions written in C - but in fact the bootstrapping process may change soon, see https://github.com/golang/go/issues/44505

Sure, go itself didnt build it from scratch - rewriting your implementation each time you change your language might grow tiresome fast, but I was referring that toy/minimal implementations exist : https://benhoyt.com/writings/mugo/