36 ms·
But—only in very metaphorical ways is a program a text file.
by throwaway91111 9y ago
But—only in very metaphorical ways is a program a text file.
- enriquto 9y agoHow is that metaphorical at all? In all current languages, you write programs precisely by writing text files.
- coldtea 9y agoFor one, in that a running program is not a text file -- it has been parsed into an AST, processed in various pipelines, and converted into several forms before it even hits a register...
- enriquto 9y agoOn the other hand, you can compile the same program with different optimization options, and even on different architectures, and we say that it is always the same program, but the binary objects may be wildly different. Thus, the program is the text file, not the binary object.
- MereInterest 9y agoI can add blank lines, change variable names, add comments, and yet through all these changes, it is the same program. By your logic, then, none of them can be the "real" program, just as none of the different binaries could be the "real" program. I think that it is better to think of all of these as representations of the same abstract program. The Sieve of Eratosthenes can be implemented in different languages, binary or assembler, high-level or low-level, English or code, but they are all representations of the same abstract program.
- fasquoika 9y agoStrictly speaking though, the text itself isn't a program, it's the input to a program (a compiler) that produces an actual program. On the other hand, this definition seems a little pedantic and you could even argue that the binary produced by the compiler isn't a program either, that a program consists entirely of its behavior.
- Koshkin 9y agoGenerally, this is not correct - compiling is not the only way to "translate" a program into an executable form: there are direct interpreters for many programming languages.
- fasquoika 9y agoI never said compiling was the only way, just that "translation" (as you put it) is in fact necessary.
- geoffpado 9y agoIn all current _serious_ languages, maybe, but also Piet exists: http://www.dangermouse.net/esoteric/piet.html http://www.dangermouse.net/esoteric/piet.html