Language without syntax

This is probably a very strange question, and it definitely is. I'm not very good at how programming languages ​​are used using conventional methods, so I wonder if it is possible to develop a language without syntax? This means that any input will be valid and will perform a certain calculation, and the same input will always do the same. There will be no syntax error (errors of logic and runtime are allowed, the program can crash, do random calculations, etc.).

I thought about it because genetics is basically, in my opinion, like that.

Edit: I think there are some misunderstandings. The syntax simply means that all the input will be calculated, that the interpreter / compiled program will follow this specific set of instructions, no matter how random it may be.

It should also correspond to the fact that each input has 1 and only 1 output. The presence of a type such as a syntax error violates this rule.

Edit 2 Many people get Hung in terms of syntax. Forget the syntax, focus on the fact that the ANY input will produce UNIQUE output.

+4
source share
7 answers

View.

The syntax refers to the ordering of input, so if you have a language whose value is independent of order, so that a meaningful sentence can be built regardless of the input form, then yes, you can have a language without syntax. Such a language must be somehow distorted or simply determine the value for each possible separable element (token, symbol, etc.) of the Input. You can not depend on the order of such items, but you can depend on their quantity, so something.

In general, this would be rather esoteric, since operational semantics usually depend on the syntax, and for most people it does not immediately become obvious that this dependence is not absolutely necessary. There is no language without syntax:

  • Count the characters a .
  • Count the characters b .
  • Ignore everything else.
  • Generate an expression for two counters.

And here is Turing complete:

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

And again, how deep does the rabbit hole go? What is the main unit of your contribution? If these are bytes or characters, then you have a huge number of possible input tokens to work with. If, however, you acknowledge that there is a fundamental order for bits within a character, then you need to reduce the problem further and depend only on the number of 0 bits and the number of 1 bits, which, provided, is still more than enough information from which you can build meaningful the program. Take my Turing example and replace a and b with “clear bits” and “set bit” respectively.

Of course, it was also argued that Lisp has no syntax in some way, since its syntax is a direct representation of the abstract structure of the program, not to mention the entire program as data. In fact, this is not that Lisp and its derivatives are strictly syntactic, since they have a one-to-one correspondence between syntax and value. Just like an integer literal, a Lisp program is actually one large, large literal of code.

+8
source

If the same input is always “the same”, then there are rules that determine how to use the input. These rules are syntax. Without syntax, there is no structure. So no, not possible.

If you are wondering if it is possible to create a language that does not have syntax errors, then be sure ... All you have to do is get the compiler (or an interpreter or something else) to fix some fixed output for any input that does not have more useful structure. You can print 1, or 0, or "Thank you for your input." Of course, you can choose something more descriptive, such as a "syntax error."

I do not think that there is an exact parallel between computer code and genetic code. However, if you think that the process of translating DNA into proteins should be similar to compilation, then you should remember that only a very small percentage of human DNA actually encodes proteins. Most of our DNA is not encoded and is probably populated with a genetic version of syntax errors.

+3
source

I think the reverse Polish word will fulfill your definition. At least until you reach the end of the input stream, no error will be detected if you enter a random string of values ​​(all of the same type) and binary operators.

+3
source

You can create a program language in which you define an input character set (for example, [a-z0-9]), and each character string in this set is a valid program. For example, take this language (where? Represents any character).

 a? : add one to register ? if ? is a numeral, nop otherwise b? : subtract one to register ? is a numeral, nop otherwise p? : print register ? 

Any other character sequence is nop. If you have an extra character at the end of the line, this is nop.

It meets your requirements. It would not be difficult to do this by ending Turing ( j? Means going to the address stored in the register ?, s? Means saving the contents of register 0 to the address?).

However, I don’t know how different this is between the fact that the C compiler simply generates executable code that does nop in case of a syntax error.

+3
source

Language completely depends on how you interpret them. The syntax should be very complex, but it should be. Just as you did, it was in English, and it had the correct grammatical syntax, and that is why I understood it. If we can create a programming language that will define natural languages ​​and output their commands based on them, for example, “hey, why don't you make me a calculator”, and the computer will make a calculator for you. No syntax with syntax that is less strict. For example, if you speak German, I would not understand a word, it means that I could not find the syntax with which I had to interpret and react, instead I have some other reaction “what the hell does this guy say “or” does this guy speak German? so the interpretation is different. The syntax is less likely to mean the syntax that the system dynamically generates, studying the environment and circumstances. There must actually be a protocol between the two to convey how it should be interpreted, and this syntax

+2
source

Even the genetic code will fail when introduced with a code that it cannot calculate (mutation, missing limbs, etc.).

+1
source

No. At some point, the processor should know what to do with that random crap that you put on your hard drive, no matter how arbitrary it may be. Even if it varies from system to system, this is still syntax.

-1
source

All Articles