Introspective program
Most likely, you heard about the well-known task invented by Norbert Wiener.
The task is to write a program that, in the course of its work, displays its source code on the screen or in a file. For granted, you cannot use a file with a code or system information, such as the address of a memory cell, possibly containing this code.
Such a program is called introspective . There is also a theorem that states that it is possible to write such a program in any programming language.
PS The task for me is especially interesting in terms of web programming languages.
I realize that the topic is in the "Entertaining Tasks", however Habr does not allow to write there. Most likely due to lack of karma, although the system motivates the refusal by my absence from this blog, which is very strange. I got the same answer when I tried to publish the puzzle in "I'm smart"
The task is to write a program that, in the course of its work, displays its source code on the screen or in a file. For granted, you cannot use a file with a code or system information, such as the address of a memory cell, possibly containing this code.
Such a program is called introspective . There is also a theorem that states that it is possible to write such a program in any programming language.
PS The task for me is especially interesting in terms of web programming languages.
I realize that the topic is in the "Entertaining Tasks", however Habr does not allow to write there. Most likely due to lack of karma, although the system motivates the refusal by my absence from this blog, which is very strange. I got the same answer when I tried to publish the puzzle in "I'm smart"