Any resources for designing the syntax for a programming language?
Hello,
I have found many articles and E-books on creating a compiler / interpreter for a programming language, but virtually none on how to design the language itself. Could anyone please recommend me to a few free E-books or articles on how to design the syntax, constructs and standard library of a custom programming language (from ground up)?
Thanks,
Ndrewxie
24 comments
[ 4.1 ms ] story [ 64.1 ms ] threadThis actually sounds quite interesting. You're starting from a good language (Smalltalk) and adding a feature absent from it but widely regarded as desirable (strong static typing).
> and clean up its syntax a bit (it's already pretty clean, just a few things could be improved)
If you go for type inference instead of having types explicitly declared, you might be able to avoid both run-time type checks and changes to Smalltalk's syntax.
> essentially a faster Smalltalk.
Bryce Kampjes (http://www.kampjes.demon.co.uk/index.html) was working on compiling Smalltalk byte code into machine code to speed it up, but that didn't involve changes to the language, so I think run-time type checks would still have been necessary. Making static type checks would result in a further speed-up.
Good luck.
Thanks!
Report can be found at https://gist.github.com/ndrewxie/54d3299c998569c27e281d2320b...
There's a family tree of languages here: http://www.digibarn.com/collections/posters/tongues/tongues....
The buck stops somewhere, the history is not that long - if you trace all the ancestors and key influencers of a single language, that's generally 10 at most; and if you trace another language, half of them will overlap.
You can't really skip that step anyway, it's not like you can make an informed decision about a particular syntax feature if you haven't taken a serious look on how that feature works or doesn't work in a dozen languages; and the more obscure languages tend to be very useful in this regard because they explore a larger variety of features and their combinations. Getting a short overview of syntax of at least some 25 languages would be a reasonable prerequisite before designing another one, and that overview would still be the easy and straightforward part.
Grammars are something that separates the men from the boys as they say.
https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form
Also, I'm not sure how getting to the first-ever-designed language will help with anything, as you (OP) seem to be trying to do. Probably it's not being aware of lexical analysis (lex family) + parsing (yacc family) . There are some great books on those.
Also: Start off by not thinking about syntax at all -- in fact, take all syntax out of your language. Break it down to the key concepts you want, such as how data is manipulated, what makes the program flow, etc. To do this, make your first stab either in a prefix-style language (Lisp, Scheme), or postfix-style (Postscript, Fourth, Factor). By minimizing the syntax you can figure out what makes your language different. Then start adding syntax back in.
If you take the approach of picking syntax from various languages and putting them together, it is kind of like taking pieces of several songs that you like, and trying to make a really good song out of those. Doesn't work as well as writing a new song from the bones up.
[0] https://dickgrune.com/Books/PTAPG_1st_Edition/
Edit: minor clarification.