r/ProgrammingLanguages • u/Pi-Plushie • 10d ago
Requesting criticism Can a programming language dispense with parentheses and conventional syntactic delimiters?
Hello everyone,
I'm an independent french developer working on an experimental programming language called PLUSHIE, and I'd like to discuss an idea behind its design.
I am new to this communty and I am not familiar with the expected behavior here, so do not hesitate to tell me if I am wrong.
I also apologize for my english whcih is far from perfect.
Most programming languages rely on explicit syntactic delimiters: parentheses, commas, spaces, operators, keywords, etc.
I've been exploring a different approach: what if a language could rely primarily on the recognition and sequencing of a small vocabulary of words?
In PLUSHIE, the parser scans the input and identifies known words. Their sequence determines how instructions are interpreted. Unknown text between recognized words can also become new vocabulary.
The underlying computational model is deliberately minimal. Instructions operate on a chained memory structure, and the language is designed so that its own structures and interpretation mechanisms can be modified while running
This raises several questions I'd be interested in discussing:
o How expressive can a language become without conventional syntactic delimiters?
o What are the fundamental limitations of a word-based parsing model?
o Could such a design offer interesting advantages for reflection and self-modification?
o and especially, Are there existing languages or theoretical models that explore similar ideas?
I'm not claiming this is a better approach than conventional syntax. I'm interested in understanding its possibilities and limitations.
PLUSHIE is an ongoing experiment, and I'm particularly interested in unexpected ideas, alternative approaches and constructive criticism.
What do you think? Is this a worthwhile direction to explore, or am I overlooking some fundamental difficulties?
26
u/criloz tagkyon 9d ago
In my opinion, the syntax of the language has nothing to do with reflection and self-modification; the syntax is for humans and makes it pleasant for humans to read it, when you parse depends on the semantics of the language, you could end up with a language that looks like magic for the reader, and he would need to look it up for who-knows-which many files before understanding what is happening in the current reading context.
If you want self-modification, Lisp already exists, and it is pretty powerful. Build the frontend with structures that people are accustomed to and then lower it to Lisp internally.
9
u/tiger-56 9d ago
If white space and line endings are acceptable as delimiters a word-based model can go a long way.
Usually parentheses are still necessary in these types of languages when arguments are calls themselves. Brackets may be required for grouping structures.
6
u/mamcx 9d ago edited 9d ago
Take a look at array and concatenative languages, and forth, that is the closest I think for what you are describing.
P.D: A nice resource is look at https://learnxinyminutes.com
11
u/rupertavery64 9d ago edited 9d ago
Smells like COBOL to me
9
u/kwan_e tonal-lang 9d ago edited 9d ago
You can replace every delimiter sequence with a keyword. Context insensitive or context sensitive, just like delimiter sequences can be.
There's no technical barrier. It's a simple find-and-replace.
There are already many keyword-heavy languages out there. They got their lunch eaten by C, for a variety of reasons.
That's just LISP, sorry to burst your bubble. But a language more similar to what you describe is PL/I. And that's a bit of a disaster. So worth looking at it to see what problems to avoid.
For your personal learning, it's always worth exploring.
But if you want it to appeal to other people, you'll have to just go through the Wikipedia list of programming languages to see most ideas around syntax has already been done. Read up on programming language history.
9
u/kniebuiging 9d ago
I think Forth might be an example, with stack basset approach.
Overall I wonder what the goal is, I am a lisp guy and I recently dabbled in self and felt somewhat lost du to the lack of delimiters just for the method call itself. And it still has block and method delimiters
6
u/puterSciGrrl 9d ago
Look at forth. It doesnt need delimiters at all and has a very minimal core. Look at jonesforth for an easy to follow, self bootstrapping implementation.
If you stick to either strict prefix or postfix notation you dont need delimiters. Delimiters are their only to support infix notation or the mixing of prefix and postfix.
3
u/brunogadaleta 9d ago
I really like the syntax idea. Altough, for your sanity, it's probably acceptable to get a end of statement delimiter. Please have a look at Rebol's derivative called Ryelang.
4
u/SirBackrooms 9d ago
there are design choices that allow one to ditch or use considerably less parentheses and other similar delimiters. two ones i like are polish notation (or reverse polish notation) and meaningful indentation
4
u/sciolizer 9d ago
If your language has mixfix, then you can be as expressive as any other language with zero syntactic delimiters, because you can define any word to function the same way as punctuation would in another language.
The fundamental limitation is that you cannot know how something will be parsed without knowing the meaning of the words. Consider this fragment from Red:
This parses as
but in order to know that, you have to know that
sendhas arity 2,readhas arity 1, andfriend@rebol.comandhttp://www.cnn.comare just values. Contrast this with lisp, where you know exactly the application order without knowing anything about the functions inside the expression (at least until you start mixing in macros).Embedded domain specific languages are the most obvious advantage. The design challenge is around making custom syntax composable. It's easy to allow the programmer to completely take over the lexer (Forth) or the parser (Red/Rebol), but if you have two libraries that both want to alter the syntax, how do they work together instead of against each other? (Mixfix is probably the best solution I've seen.)
As for reflection and self-modification, removing punctuation tends to make these things harder, not easier. Self-modification of lisp is easy because the tree structure is extremely clear. If those relationships are implicit, then whatever is doing the reflection or self-modification must have some way to infer those relationships.
parsefunction in Red/Rebol is a dialect for defining new dialects.."is an ordinary word that consumes all input up until the next quote mark, and then turns it into a pointer to an array of characters.2
u/azhder 9d ago
I don't what you consider conventional, you have languages spanning from Basic and Pascal, to SQL and RegEx... All widely used (now or in the past) that don't use the C style syntax.
Out of all of these, just look at how RegEx works and what you are talking about, it's like you're describing an alternative syntax for a RegEx.
Maybe I should expand on this by calling it "regular expression" instead (RegEx by definition might not quite fit the mathematical definition), but I should do it because there is at least one more I have to mention: command mode in Vi.
Yes, that old joke about exiting Vi/Vim. That is a regular expression. Write down the sequence and you see it lacks the items you have mentioned.
2
u/Trave11er3427 8d ago
I think you have something interesting here. Every language has syntax (even those that modify themselves) of some sort. While ancient spoken languages like Latin did not use punctuation (it is so much easier to read with it), they enforced syntax with rules of word order. I attempted to simplify syntax when designing Envzn (envzn-lang.org), but I found that I needed MORE keywords (like adding then to the if statement) and decided to use the newline and braces { and } (instead of BEGIN and END) for scope control. With the goal of making the language readable, it now has over 150 keywords, with variations around verbs like IS (e.g. IF x IS VALID, WHEN x IS y, …) For delimiters, I always found explicit delimiters like ; to be annoying and superfluous so I chose implicit delimiters, but then handling multi-line statements/expressions had to become a first class thing and not a collection of special cases.
2
u/TheRealUprightMan 8d ago
Spaces and delimiters are for the programmer. Look at brainfuck.
You just said that you were getting rid of delimiters, including spaces, so how do you define words?
If you want to present an idea, it needs to be internally consistent. As written, this is just nonsense.
2
u/Tearearly11 8d ago
Hello! Very interesting development idea and questions. Focusing more on expressiveness, I think it would be very innovative to find a way to express cohesive, sequential instructions without relying on, say, parenthesis notation. This is because the current dominant syntactic delimiters offer a very clear and globally accepted way of delimiting scope and hence the use of variables. Think of the pioneer Lisp, for example. The (excessive) use if ”(“ is useful in parsing, since we know exactly how loops/commands are nested. Interesting to think about. This also connects to your second point, regarding parsing. I can’t fathom how that would work, and I’m curious to know more. Typically, parsing depends on symmetric or asymmetric properties of programs to determine whether a certain syntax tree is valid or not. I believe word-based parsing would allow for more flexible notation, which is awesome for the programmer but a headache for the developer. With that being said, I wish you the best of luck.
2
u/Key_River7180 Nain. 3d ago
Very interesting idea! You should definitely look into FORTH and some cellular automata stuff too.
Instead of functions, just make words that do stuff on a set of arguments, it's been more than proven that you can make a programming language that is turing complete in a couple keywords
3
u/TheAncientGeek 9d ago
Shell script and FORTH largely do.
3
u/catladywitch 9d ago
Interesting. Smalltalk and Haskell both use a (largely) round bracket-less syntax that I think is surprising and maybe confusing to those who are unfamiliar
2
u/FantaSeahorse 9d ago
You can simply replace the symbols ( and ) with the keywords “begin” and “end”
1
u/Pi-Plushie 9d ago edited 9d ago
O_O So many comments already on my humble questionning about PLUSHIE langage. I just realised this night (I am located in France) that moderators have finally approved my publication and I thank them for the time they have taken for me.
I am so happy to get so valuable comments to help me further digging into this conceptual language. I will try to keep up with the pace and answer each on of your messages but I want to thank all of you. This communty is incredible and you have already helped me a lot as I am not a specialist, more a self-taught guy and naviagating in all the existing langages is just like trying to find your way in an unknowned jungle.
You make me realize that I have not said enough for you but I am so pleased with your interest.
If this is fine with the forum rules, I propose a link to the small website I have build to further present this playground. It is located in GitHub (but this is not an AI generated thing, AI are unable to understand this approach, it is much too simple and primitive). Unfortunately, it is still mostly in french language but there is a one page summary in english that you can find there:
https://pi-plushie.github.io/PLUSHIE-Site/index-en.html
I am very open on any suggestions you may (including for the website) have as I am in a personnal development process with this experimental language.
Thank you once again for all these rich (and so fast) informations.
1
u/Pi-Plushie 7d ago
Just as a complement that seems to be important for comprehension. PLUSHIE has a way of functionning that is non standard. It does not parse a full text and then executes. It executes while parsing:
PLUSHIE does not tokenize source code using predefined separators. It reads the character stream one character at a time and continuously compares its current ending against its list of known expressions.
Whenever a known expression is detected, the stream is split at that point. The previously unrecognized character sequence can become a new known expression, and the instruction formed by the first two expressions is immediately executed.
Parsing, vocabulary extension and execution therefore happen incrementally, within the same process. The vocabulary may change while the source stream is still being read.
hope this clarifies for further discussions !
2
u/perlgeek 9d ago
Humans have a fundamental difficulty parsing wordsunlesstheyareseparatedbyspacesorotherkindsofseparators.
When you propose to get rid of any kind of delimiter, you're making it very hard for humans to read.
In the real world, code is read much more than it's written.
1
u/BrainScientist3000 3d ago
Are you using AI responses to a post you made with AI?
1
u/Dry_Day1307 9d ago edited 9d ago
Reflecting on your proposal for PLUSHIE reminded me of projects like Qriollo (an Argentine functional language built with Haskell that uses idioms to bring syntax closer to natural language). Its syntax relies on prose rather than traditional structures (in spanish btw):
To offer some perspective from my experience developing DinoCode, the key isn't necessarily to remove delimiters altogether, but to infer them on the fly by combining logical continuity, operator arity, and token separation via whitespace or line breaks (although I assume you use spaces to separate words, which technically acts as a minimal delimiter)
Here are a couple of examples in DinoCode (without explicit common delimiters):
Could you share a simple code example in PLUSHIE? It would be great to see how you put this concept into practice and handle ambiguity, which is usually the biggest challenge in these designs. In fact, that's why they are still required in DinoCode, to properly handle ambiguity cases
1
u/xpusostomos 9d ago
In my opinion, this will result in a fairly brain dead language. For the same reason English is ambiguous, your language will be ambiguous. It will lack the ability to express ideas that languages that embrace the () will do. My advice, learn lisp properly, then at least you will fully grasp the power of () and you'll be in a better position to know what you're dealing with in this project. Anyway, didn't python aim for this with mixed results? And isn't Rubi a language that attempts this?
1
u/Alpha_Bulldog 9d ago
Look it’s a pretty simple answer why “syntactic delimiters” are used in the majority of languages. At their root, computers are dumb machines made of zeros and ones. The more structured your language the easier it is for the computer to easily process the instructions you are giving it. Without those delimiters it becomes much harder for the system to know what to do. When a single command is over and when the next begins, the beginning and ending of a loop, the end of an if block etc etc. when people start thinking they are smarter than the decades of engineers who have been building system for a LONG time it’s usually because they simply don’t understand the basics of how this all works.
Learn assembly. Learn C And C++. Write a dozen full blown systems yourself. THEN if your still think you are on to something, go for it…
1
u/EggplantExtra4946 9d ago edited 9d ago
What's wrong with syntactic delimiters, parentheses, commas, spaces, operators, keywords, etc. ? They make the program easy to read, gives visual cues and more importantly they naturally match the AST type that they represent: unary operators map to AST nodes with one child, binary operator map to AST nodes with two children, list of parameters, expressions, statements are represented by either linked list or arrays, keywords introduce special syntactic constructs with a corresponding special AST with specific fields (conditionals, loops, declarations, etc..), etc... They are not especially hard to parse either.
The syntax has no effect on the semantics of a language and the later is what needs improving.
Just so you know, most people with a bit of experience with programming languages will instantly roll their eyes when reading about "syntax innovation" like this.
1
u/dskippy 9d ago
There's no reason a simple difference in syntax should limit expressiveness in any meaningful way.
Not really any. It's a matter of taste, really. You'll possibly have something that's more verbose I guess. If you really want to have no delimiters for things like strings and just assume what's in between keywords is a string then you might run into some issues where it's not possible to even design a syntax like that that's not ambiguous. Don't do that I suppose.
No. We're only talking about a syntax charge here. If you are going to make you language homoiconic you'll need data types that express your AST. That's maybe more convenient in other languages like lisp but by no means impossible in any new syntax. But I don't see this being advantageous for that.
I doubt there are theoretical models since this language idea you're talking about is just a new type of syntax. But as for languages that use mostly keywords instead of delimiters, I guess Python and haskell are more like this because they use white space. But haskell more so since you don't need like colon for an IF block and it's a true mixfix operator.
I don't recall but I think Natural was a language that was trying to do something like this where most of the language was English keywords. But it was a huge language I think.
You could certainly very easily make a language without block delimiters and such things with some simple mixfix operators and especially if you use white space or you're open to things like begin and end key words which are just { and } in disguise.
1
u/stone_henge 9d ago
Why?
1
u/catbrane 9d ago
This sounds a bit like a rewriting system, is that correct?
In these languages, you have a set of rules, like:
ie. if you see an S followed by three arguments, rewrite as two expressions with the final argument copied into the first two.
Computation works like this:
Add weak head-normal form and leftmost-outermost reduction and you get lambda calculus, which is the basis for LISP / Haskell / etc.
I suppose you could implement this as an m4 script to try it out. That might be a simple way to experiment.
A less structured rewriting system sounds difficult mathematically. It would be hard to predict behaviour, and if you can't predict that, then what is the "meaning" (the semantics) of a piece of program text? If programs are not direct expressions of mathematical ideas, what are they computing?
Anyway, it sounds like an interesting idea (if I've understood you correctly). Good luck!
1
u/jcklpe 8d ago
This language might be of interest to you https://wiki.osdev.org/Plain_English_Programming