2
\$\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
    \$\begingroup\$ Possible duplicate of When is code that requires a REPL acceptable? \$\endgroup\$ – Mego Aug 15 '16 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\$ – Mego Aug 15 '16 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 Aug 15 '16 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\$ – Rohan Jhunjhunwala Aug 16 '16 at 19:03

You must log in to answer this question.

Browse other questions tagged .