r/ProgrammingLanguages • Nain. • 1h ago

Would a syntaxless programming language be possible?

So I had the idea of a syntaxless programming language where a function parses its form as it needs.

In this system, a parser is a function turning a description of the syntax to a kind of binding

parser: forms -> (given syntax) -> binding;

For example:

template ([a] is in between [min] and [max]) # binding
  := a >= min and a <= max; # lambda 

Idk just a cool idea. There are many problems with this (for starters, when do you know what parser to use?)

0 Upvotes

20 comments sorted by

View all comments

1

u/NomagnoIsNotDead 32m ago edited 22m ago

So, taking the replies to far, have my ramblings:

Lisp qualifies as having no syntax, in the sense that you *can't* use any syntax other than S-expressions, which are just trees (some implementations let you mess with the parsing FORTH-style but not universal).

FORTH qualifies as having no syntax, in the sense that you can have any syntax you please by manipulating the input stream, the basic 'syntax' is just concatenating word/function invocations, and you can override any function name. However, you sure as hell do have a 'default' syntax as well as a syntax during the bootstrapping process.

Smalltalk... well it has syntax so it doesn't qualify! But it's pretty minimal as well and often mentioned in the same breath as FORTH and Lisp.

The most radical definition of 'no syntax' could hence be: having no reserved tokens, AND having no clear structure that makes use these reserved tokens even during the bootstrapping process.

If we're getting esoteric, maybe some kind of language that infers the syntax at the start of the program, or that lets you configure the syntax at the start of the program? Or that uses no reserved tokens but uses the specific tokens you specify as part of its syntax?

A silly example that probably qualifies under the last definition but is otherwise uninteresting, with syntax 'function-name arg1 arg2 ... argN argN body function-name' , with the last argument repeated to terminate the argument list, and the function name repeated to terminate the body, making it freeform:

TRUE x y y
x
TRUE

MAIN ignored ignored
TRUE readInput readInput
MAIN

This silly example evidently doesn't support recursion or side effects, but you can add more builtin functions like readInput to assist in this, and changing the syntax on-the-go, I guess, but at which point are you re-inventing FORTH? (at a pretty early in that thought experiment). This'd probably have to be postfix to be useful since grouping is currently impossible unless you add parentheses, and you can argue that this has a clear syntax but it is simply extremely non-context-free.

Combinator calculi don't really have any syntax, but they also have no built-in way to perform abstraction, which hardly qualifies as a programming LANGUAGE.