
Any resources for designing the syntax for a programming language? - _c83b
Hello,<p>I have found many articles and E-books on creating a compiler &#x2F; 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)?<p>Thanks,<p>Ndrewxie
======
rurban
The usually best introduction for this is “Compiler Construction using Flex
and Bison” Anthony A. Aaby 2004
[http://foja.dcs.fmph.uniba.sk/kompilatory/docs/compiler.pdf](http://foja.dcs.fmph.uniba.sk/kompilatory/docs/compiler.pdf)

~~~
yesenadam
Oh yeah. I read the original question as 'I know about lex/yacc' or their
modern equivalents flex/bison.. but I guess not. You can do a lot just with
lex/flex, e.g. it's fine for small languages. Probably play around with that
before attempting something insanely ambitious.

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.

------
derekp7
Take a look at the blog "lambda-the-ultimate.org", there is a thread on the
sidebar called "getting started". There's links in there to several good
resources (Types and Programming Languages; Structure and Interpretation of
Computer Programs; Concepts, Types, and Models; Essentials of Programming
Languages; etc).

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.

------
DonaldFisk
Tony Hoare's Hints on Programming Languages Design are still worth a read:
[http://web.eecs.umich.edu/~bchandra/courses/papers/Hoare_Hin...](http://web.eecs.umich.edu/~bchandra/courses/papers/Hoare_Hints.pdf)

------
yesenadam
Great question. On second thoughts, is there much to say except "Combine the
parts you like from existing languages and the new things you want"? And, read
stuff about how existing languages were designed.

~~~
ndrewxie
I googled about the origins of many common languages, but most of them were
just based off of another language. I tried finding out how those languages
were made, but it just goes on...

~~~
PeterisP
Well, that's still the right direction that you should pursue.

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.

~~~
ndrewxie
OK, I'll follow the chain to the end :)

------
enhray
When I started dabbling in programming languages design, Parsing Techniques -
A Practical Guide was invaluable for me. I cannot recommend this book enough.
First edition is available for free from one of co-authors site [0].

[0]
[https://dickgrune.com/Books/PTAPG_1st_Edition/](https://dickgrune.com/Books/PTAPG_1st_Edition/)

Edit: minor clarification.

------
whoareu
hi @ndrewxie. who are u and what is ur underlying purpose ? what's ur
background ?

~~~
ndrewxie
I'm a C/C++ developer for 15 years. I'm planning to do this mainly for
learning purposes, and to create my newest project (actually an umbrella
project containing 5 different projects).

------
whoareu
hi

~~~
ndrewxie
Please don't spam.

