HACKER Q&A
📣 pandeykartikey

What would be the syntax of an ideal programming language?


Hi, I am starting to write a programming language and currently deciding on syntax. So, I wanted to ask the HN community. What would they want in a programming language eg: GO like syntax for function and declarations or python like structuring with indentation.


  👤 sparkie Accepted Answer ✓
Syntax is kind of overrated, but familiarity can matter if you have a specific target audience. You will usually get some who are resistant to learning if the syntax is significantly different from what they're familiar with - but it is unlikely these are going to use a niche language anyway. PLT enthusiasts are generally more open minded about syntax choices, so you can choose what you think is appropriate.

Consider many of the top programming general purpose languages share some or most of their syntax (C, Java, etc), with Python being a bit of an outlier. This would suggest that familiar syntax matters for adoption.

Syntax choice is always going to be subjective and there is no "ideal". People often say Python is easier to read, but I don't buy it. It's easier to read for people who've had experience using Python, that's all (which happens to be a large number of people because it is a common choice of first language in academic courses). Just as I find S-expressions easy to read but non-lispers/non-schemers are often put off by the placement of parens.

In terms of implementing the parser, some syntax is simpler than others to parse. S-expressions are very trivial. C and C++ in particular have some ambiguities in parts of their syntax which need to be resolved through semantic analysis, but they cause trouble for writing tools for the language. Those problems can be avoided with careful design, however, there have been some attempts to re-syntax C++, such as SPECS[1], which never caught on. Existing tooling, code and integration with other parts of a system are more important than language syntax.

[1]:http://users.monash.edu/~damian/papers/HTML/ModestProposal.h...