So, You Want To Write Your Own Programming Language?

bearophile bearophileHUGS at lycos.com
Wed Jan 22 02:38:39 PST 2014


Walter Bright:

> http://www.reddit.com/r/programming/comments/1vtm2l/so_you_want_to_write_your_own_language_dr_dobbs/

Thank you for the simple nice article.


>The poisoning approach. [...] This is the approach we've been 
>using in the D compiler, and are very pleased with the results.<

Yet, even in D most of the error messages after the first few 
ones are often not so useful to me. So perhaps I'd like a 
compiler switch to show only the first few error messages and 
then stop the compiler.


>Automated documentation generator. [...] Before Ddoc, the 
>documentation had only a random correlation with the code, and 
>too often, they had nothing to do with each other. After Ddoc, 
>the two were brought in sync.<

And now the situation is even better, we have documentation 
unittests and the function arguments are verified to be in sync 
with their ddoc comment. Probably there's some space for further 
improvements.


>One semantic technique that is obvious in hindsight (but took 
>Andrei Alexandrescu to point out to me) is called "lowering."<

In Haskell the GHC compiler goes one step further, it translates 
all the Haskell code into an intermediate code named Core, that 
is not the language of a virtual machine, it's still a functional 
language, but it's simpler, lot of the syntax differences between 
language constructs is reduced to a much reduced number of mostly 
functional stuff.


>My general rule is if the explanation for what the function does 
>is more lines than the implementation code, then the function is 
>likely trivia and should be booted out.<

In Haskell there's a standard module named Prelude, it's imported 
on default and defined lot of functions, etc of general use. Most 
functions in it are only few lines long (often 2-3 lines long, 
with some functions up to 10-13 lines long).


Bonus: the cute idea of a language for students:
http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c


(On Reddit I seem to see some comments, like structs not allowing 
constructors?)

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list