Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntaxless programming language [closed]

This is probably a very strange question, and it definitely is. I'm not too familiar on how programming languages are made with conventional methods, so I'm wondering, is it possible to design a syntaxless programming language? This means that any input will be valid and perform a certain calculation , and the same input will always do the same thing. There will be no syntax error (logic and runtime errors are allowed, the program can crash, do random calculations etc).

I thought of this because genetics are basically, to my understanding, like that.

Edit: I think there are some misunderstandings. Syntaxless simply means that all input will compute, that the interpreter/compiled program will follow that specific set of instructions, however random it maybe.

Also it has to match the fact that every input has 1 and only 1 output. Having something such as the syntax error violates that rule.

Edit 2 Many people are getting Hung up on the syntax part. Forget about the syntax, focus on the fact that ANY input will produce an UNIQUE output.

like image 318
Pwnna Avatar asked Dec 01 '22 02:12

Pwnna


2 Answers

Kind of.

Syntax refers to the ordering of input, so if you have a language whose meaning does not depend on order, such that a meaningful "sentence" can be constructed regardless of the form of the input, then yes, you can have a syntaxless language. Such a language would have to be somehow case-inflected, or simply define a meaning for every possible separable item (token, character, etc.) of input. You couldn't depend on the order of such items, but you could depend on their number, so that's something.

In all, it'd be pretty esoteric, since operational semantics typically depend on syntax, and it's not immediately obvious to most people that that dependence isn't strictly necessary. Here's a non–Turing-complete syntaxless language:

  • Count the a characters.
  • Count the b characters.
  • Ignore everything else.
  • Produce the quotient of the two counts.

And here's a Turing-complete one:

  • Count the a characters.
  • Count the b characters.
  • Ignore everything else.
  • Take the binary representation of the count of a characters.
  • Prefix that with a number of zeros equal to the count of b characters.
  • Evaluate the result as a Jot program.

Then again, how deep does the rabbit-hole go? What is the fundamental unit of your input? If it's bytes, or characters, then you've got a vast array of possible input tokens to work with. If however you admit that there's a fundamental ordering to the bits within a character, then you have to reduce the problem further, and depend solely on the number of 0 bits and the number of 1 bits, which, granted, is still more than enough information from which to construct a meaningful program. Take my Turing-complete example and substitute a and b with "clear bits" and "set bits" respectively.

Of course, it's also been argued that Lisp is syntaxless in a way, since its syntax is a direct representation of the abstract structure of the program, not to mention the whole program-as-data thing. Really it's not that Lisp and its derivatives are strictly syntaxless so much as they have one-to-one correspondence between syntax and meaning. Just like an integer literal, a Lisp program is effectively just one great big code literal.

like image 167
Jon Purdy Avatar answered Dec 05 '22 04:12

Jon Purdy


I'm thinking that reverse Polish would meet your definition. At least until you get to the end of the input stream no error would be detected if you entered a random string of values (all of the same type) and binary operators.

like image 26
Hot Licks Avatar answered Dec 05 '22 05:12

Hot Licks