When someone writes a new programming language, what do they write it IN?

前端 未结 13 980
再見小時候
再見小時候 2020-12-07 06:57

Please excuse my ignorance. I\'m dabbling in PHP and getting my feet wet browsing SO, and feel compelled to ask a question that I\'ve been wondering about for years:

13条回答
  •  一生所求
    2020-12-07 07:34

    Many languages were first written in another available language and then reimplemented in itself and bootstrapped that way (or just kept the implementation in the foreign language, like PHP and perl), but some languages, like the first assembler was hand compiled to machine code like the first C-compiler was hand compiled to assembly.

    I've been interested in bootstrapping ever since I read about it. To learn more I tried doing it myself by writing my own superset of BF, which i called EBF, in itself. the first version of EBF had 3 extra primitives and I hand compiled the first binary. I found a two step rhythm when doing so. I implemented a feature in the current language in one release and had a sweet release where I rewrote the code to utilize the implemented feature. The language was expressive enough to be used to make a LISP interpreter.

    I have the hand compiled version together with the source in the first release tag and the code is quite small. The last version is 12 times bigger in size and the code and allows for more compact code so hand compiling the current version would be hard to get right.

    Edmund Grimley Evans did something similar with his HEX language

    One of the interesting things about doing this yourself is that you understand why some things are as they are. My code was product if small incremental adjustments an it looks more like it has evolved rather than been designed from scratch. I keep that in mind when reading code today which I think looks a little off.

提交回复
热议问题