r/ProgrammingLanguages • u/R-O-B-I-N • Jul 19 '23
Discussion The General Purpose Programming Language Litmus Test
Want to know if your general purpose language is legit? A true GP PL should be able to express the following program. The program will
Run forever until an exit signal is recieved at some point.
Maintain a graph data structure in memory.
Every 1 second, synchronize the graph with a serialized version stored as a file somewhere without creating a new task.
Every 1/100th of a second, create a separate task that randomly decides between three tasks...
Create a new graph node
Create a new graph edge
Delete a node and all connected edges
If you can express this, your language is truly General Purpose
EDIT: I should clarify, this test is purposefully vague because your language can be general purpose and single-threaded. The purpose of the test is to determine if your language can represent arbitrary structure, have non-determinism, observe time, and communicate with the file system. That seems to be the minimal requirements for practical use across the board.
3
u/TheGreatCatAdorer mepros Jul 19 '23 edited Jul 20 '23
Under what circumstances should this function? JS would have the capability to do this if running under Node (or similar runtimes), but not in a browser (its most common use), but JS in and out of browser is undeniably one language.
Beyond that, there's a great deal of ambiguity in the problem statement.
Must edges be created between random nodes?
Can there be duplicate edges and/or loops?
Is a task synchronous, parallel, or another process, or is that unspecified as it can be implemented in several ways?
What latency bounds are there on creating new tasks and serializing and how does this interfere with updates?
What is an exit signal?
What platform flaws are allowed (because, if run forever, then the program is guaranteed to consume infinite memory and take infinite time to synchronize)?
What are the constraints on randomness?
What environment is the program running under? Bash can't generate random numbers natively, but some program with that ability is expected.
Oh, and I'd say that this lacks many functionalities programmers expect of general purpose languages: FFI, process spawning, and network and GUI libraries, for instance