3
\$\begingroup\$

As I understand it, for our purposes a language is more or less defined by its implementation. That's one of the reasons why a program like Vim can also be "language". You just count keystrokes instead of bytes.

But consider the case of Haskell with its standard compiler + interpreter of ghc/ghci.

Let's say I have found a solution for a question that I could write in its own file as

import Data.ACME
g=filter(`elem`"+-*/")
f=((someAcmeFunction.g)+).g

The details are not important. I can compile this program in ghc or I can run it in ghci. The actions needed to load and execute the file are not counted towards the score. But in general practice - and I feel like that is supported by Unnamed Functions in Code Golf, it is also acceptable to present the solution as

import Data.ACME
g=filter(`elem`"+-*/")
((someAcmeFunction.g)+).g

Notice that I saved two bytes by not giving the last function a name. I can not run this solution in one part. The first two lines must be loaded from a file while the last one must be run interactively. It can not even be supplied as a parameter if it needs to get some input. Still - this seems to be accepted practice. Now let's take this a step further.

:m +Data.ACME
let g=filter(`elem`"+-*/")
((someAcmeFunction.g)+).g

This is what I would do in a fully interactive session. The interactive import saves some bytes keystrokes, but the interactive definition adds some back. Still, sometimes I might save a bit.

I could also combine both approaches differently

g=filter(`elem`"+-*/")
:m +Data.ACME
((someAcmeFunction.g)+).g

One line to be loaded, two to be run interactively.

All this doesn't feel right because I'm hiding some interactions. But if I have to load a file or select a codepage before running my program, that's interactions, too, and we accept those. Where does the "wrongness" start? It's not a new topic, but On "interactive" answers and other special conditions did not provide the answers I am looking for.

So I feel like the answer has to do with this: I'm only partially programming in Haskell! :m is not a Haskell command but a ghci one. I could as well start using :def to define my own commands or :! to run system commands. Yet this is only a natural extension of accepting plain function definitions as solutions.

So is the build environment a different "language"?

Update

A huge part of this question is answered in When is code that requires a REPL acceptable?, so thanks for making me aware of it. I leave this question open in the hope of finding a more defined separation than there.

The general consensus in comments to the other question seems to be that both the language and the REPL are indeed separate languages. At the same time, elements of the REPL are acceptable in a "pure-language"-answer if they are not "significant". I think I have demonstrated how blurry the area between both can be. At the same time, I have not seen many REPL-solutions "in the wild", so maybe there's an unspoken dislike of them - possibly because of that blurriness. (Or is it just that they require less creativity?)

So, what is "significant"? It's probably impossible to define clear rules like "66.7% of the code must be outside the REPL" - but maybe there are some softer guidelines one could follow?

Feel free to close this question as a dupe if you think such discussions are fruitless or should be left for the historians after we have had more time to form our culture. ;)

\$\endgroup\$
4
  • 4
    \$\begingroup\$ Possible duplicate of When is code that requires a REPL acceptable? \$\endgroup\$
    – user45941
    Commented Aug 15, 2016 at 3:11
  • \$\begingroup\$ Re: your update - if your code requires a REPL environment to run, it is REPL code (and must be marked as such). If it works without a REPL environment (e.g. loaded from a file, stream, or whatever, without needing more interaction than possibly an interactive STDIN prompt), then it's not REPL code. \$\endgroup\$
    – user45941
    Commented Aug 15, 2016 at 6:34
  • \$\begingroup\$ @Mego, while that does sound reasonable, both the "real world" and the linked question seem to differ. I mean I didn't make a survey, but I have a feeling if that where the consensus then quite a few "Haskell" answers out there would have at least the wrong title. On the other hand if your position turns out to be the "correct" one, I'd be happy to finally have a definitive reference to use when policing the area. \$\endgroup\$
    – MarLinn
    Commented Aug 15, 2016 at 6:49
  • \$\begingroup\$ I don't think a dupe hammer is warranted here. The question is asking for further clarification and a more definitive "line in the sand" \$\endgroup\$ Commented Aug 16, 2016 at 19:03

1 Answer 1

-1
\$\begingroup\$

Abstraction: To quote from ISO standards 7185 and 10206 (Pascal programming language):

Processor
A system or mechanism that accepts a program as input, prepares it for execution, and executes the process so defined with data to produce results.
NOTE — A processor may consist of an interpreter, a compiler and run‑time system, or another mechanism, together with an associated host computing machine and operating system, or another mechanism for achieving the same effect. A compiler in itself, for example, does not constitute a processor.

ISO standard 9899 (C programming language) has a more elaborate definition of, what it calls “Environment”, but the basic idea stays the same: There is one handover point.

[…] Notice that I saved two bytes by not giving the last function a name. I can not run this solution in one part. The first two lines must be loaded from a file while the last one must be run interactively. […]

No, you cannot do that. Splitting your source code into multiple files/inputs conveys information. This information must be scored.

Conclusion: On PPCG you are free to choose the point/time the transfer of responsibility occurs, the “language” is defined accordingly.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .