10
\$\begingroup\$

In challenges that require loading remote data - e.g. "What's my PPCG ID?" - some JavaScript (or other languages that may be run in the browser) answers may rely on being run at a certain domain (example answer), or may include extra code to safe-guard against being run at a certain domain (example robber).

Should answers be allowed to restrict which domains they can be run at? Should they be required to be runnable on all domains?

\$\endgroup\$
2
  • \$\begingroup\$ We usually define a language by it's interpreter/compiler. In that case requiring a certain browser is fair play as not all support all the same features. Requiring to run on a certain domain is more at the execution level and so I'd say no. However, I'm not experienced enough to judge this properly. \$\endgroup\$ Commented Aug 8, 2017 at 12:53
  • \$\begingroup\$ Sometimes this is a requirement due to CORS \$\endgroup\$
    – Downgoat
    Commented Aug 20, 2017 at 3:50

3 Answers 3

12
\$\begingroup\$

Yes, as long as it isn't used to store data

We allow specific platform and environment requirements, as long as:

  1. It is specified in the post
  2. They aren't being used to store bytes (on or similar challenges where byte-count matters)

Requiring a particular domain is simply requiring a particular environment

\$\endgroup\$
6
  • \$\begingroup\$ The environment usually matters for the languages implementation/compilation i.e. different C compilers and browser specific behaviour. I think requiring a domain is more at the code execution level than the environment level. \$\endgroup\$ Commented Aug 8, 2017 at 14:54
  • \$\begingroup\$ I think it boils down to the same as how we treat file names as @StepHen mentions in their answer. \$\endgroup\$ Commented Aug 8, 2017 at 14:55
  • 2
    \$\begingroup\$ @TheLethalCoder File paths aren't under different guidelines. If there was a challenge to "delete all files", assuming that you are in the / filepath is an environment requirement that is perfectly accceptable. \$\endgroup\$ Commented Aug 8, 2017 at 14:59
  • \$\begingroup\$ I suppose when you think of it that way it makes more sense... \$\endgroup\$ Commented Aug 8, 2017 at 15:00
  • 1
    \$\begingroup\$ I think it would help to address what storing data specifically consists of - for instance, does this answer: codegolf.stackexchange.com/a/138094/20080 use the domain to store data? I think it does. \$\endgroup\$
    – isaacg
    Commented Aug 12, 2017 at 21:16
  • \$\begingroup\$ @isaacg I'm not sure what I think of that issue, and I don't feel comfortable editing my answer. Something to consider, though: Let's say there was a challenge to read the hosts file: Would you allow the answer to assume that it was in the /etc directory? \$\endgroup\$ Commented Aug 13, 2017 at 12:56
11
\$\begingroup\$

For Code-Golf - domain would be extra bytes

This is mostly directed at , which I believe is not what you are asking about. However, if a answer requires a certain domain, it should be included in the byte count. This is exactly how we treat file names, for example.

\$\endgroup\$
7
  • \$\begingroup\$ Was my thoughts as well just couldn't quite pin down why for an answer though. I forgot about requiring file names into the byte count so this is the correct answer. \$\endgroup\$ Commented Aug 8, 2017 at 13:00
  • \$\begingroup\$ Would answers that require the domain to not be a certain value (for whatever reason) be invalid? \$\endgroup\$
    – Birjolaxew
    Commented Aug 8, 2017 at 13:04
  • \$\begingroup\$ @Birjolaxew no. this just means that if your answer only works on a certain domain, you must include that domain in your byte count. If it works on any domain, just like if it works with any filename, you do not need to include it in the byte count. When using the filename to store data, add them as extra bytes to your solution similarly to any non-standard parameter. - from standard loopholes. \$\endgroup\$
    – Stephen
    Commented Aug 8, 2017 at 13:07
  • \$\begingroup\$ @StepHen But what if the answer works with all domains (or filenames) except one (e.g. the answer relies on cross-origin functionality, similar to the linked robber)? Would the answer be invalid unless code is included to ensure all domains work? \$\endgroup\$
    – Birjolaxew
    Commented Aug 8, 2017 at 13:09
  • \$\begingroup\$ @Birjolaxew oh, sorry, I misunderstood what you said the first time. I'm not sure. \$\endgroup\$
    – Stephen
    Commented Aug 8, 2017 at 13:10
  • 7
    \$\begingroup\$ Working on only a couple domains (or even 1) is perfectly fine as long as they aren't using the domain to store data. We allow any environment, no matter how specific, but draw the line when it is used to store data. \$\endgroup\$ Commented Aug 8, 2017 at 13:12
  • \$\begingroup\$ @NathanMerrill you may be correct - you probably should post an opposing answer, as that is not what my answer currently says. \$\endgroup\$
    – Stephen
    Commented Aug 8, 2017 at 13:15
4
\$\begingroup\$

No

In my opinion, this constitutes outsourcing the real answer, which is a standard loophole. This is because it outsources the fetching of data from the website to the browser that ran the code.

I'd like to address the two "yes" arguments that were presented by Nathan Merril:

  1. It is specified in the post
  2. They aren't being used to store bytes (on or similar challenges where byte-count matters)
  1. This doesn't make much sense to me. If a question explicitly allows something, it can be allowed, but this Meta post is tagged as , which indicates that we are looking from a general consensus in absence of any specification by the OP.

  2. The definition of "storing bytes" is a little bit sketchy here. Even if the environment is not being used to store program code, it could still be storing data, and it is indirectly saving bytes by removing the need for a GET request or similar to fetch the data from the website. The standard loopholes are there to tell us what bytes are acceptable to save.

I'll finish with the ever-so-popular advice on PPCG: golf your code, not your IO format. Allowing code run at a specific domain feels too much like golfing the IO format to me.

\$\endgroup\$
2
  • \$\begingroup\$ If the was a challenge "delete all files", does that mean that users couldn't assume that the cwd is at /? \$\endgroup\$ Commented Oct 11, 2017 at 12:15
  • \$\begingroup\$ @NathanMerrill I think the OP could allow that, but it shouldn't be a default. And besides, that is outside the scope of this question. \$\endgroup\$ Commented Oct 11, 2017 at 15:22

You must log in to answer this question.

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