12
\$\begingroup\$

Languages differ greatly in the amount of functionality contained in the main namespace. Most of the PHP main functions, have counterparts in Perl core libraries. What should the policy be on character counts in such cases?

For example, my solution for the NxN spiral used the Perl library Math::Complex. Possible outcomes:

  • Allow command-line calls such as perl -MMath::Complex script.pl to include libraries.
  • Require use Math::Complex; in the code.
  • Do not allow libraries.

Of course, this is just another instance of the problem of trying to compare languages, but there is some value in defining an objective measure.

\$\endgroup\$
  • 1
    \$\begingroup\$ Duplicate of Use of built-in functions and libraries in Code Golfs, no? \$\endgroup\$ – dmckee Feb 10 '11 at 19:22
  • 1
    \$\begingroup\$ @dmckee: I did read that question before posting. This question regards more how the characters are counted. Although I suppose the best answer will still be "who cares" :) \$\endgroup\$ – user475 Feb 10 '11 at 19:31
  • \$\begingroup\$ Ah. In that case, did you see Should non-standard compiler flags be included in character counts?? Though I m not sure that it resolves the question. \$\endgroup\$ – dmckee Feb 10 '11 at 19:34
  • \$\begingroup\$ @dmckee: Thanks, I missed that one. Looks like it wasn't resolved, but I've favorited it. \$\endgroup\$ – user475 Feb 10 '11 at 19:39
13
\$\begingroup\$

I'd say use

use Math::Complex;

and be done with it. If PHP can solve something shorter than Perl because Perl requires a module, then so be it. I cringe every time I have to write [Math]::floor() or something like that because it's so verbose, but it still is a trait of the language.

And some languages are better for golfing certain problems than others. I guess there is no point in denying that.

\$\endgroup\$
  • \$\begingroup\$ Languages do indeed have different advantages, but then the question is: which command-line parameters would be allowed? \$\endgroup\$ – user475 Feb 10 '11 at 14:06
  • 6
    \$\begingroup\$ @Tim: The usual answer is: command-line arguments count towards the character count. \$\endgroup\$ – Chris Jester-Young Feb 10 '11 at 14:20
2
\$\begingroup\$

My opinion is that, unless the question says otherwise, any freely available library existing before the question was asked should be permissible. However, the requisite import statements should be counted towards the byte count. Additionally, a link to the library should be included in the description/explanation part of the answer.

\$\endgroup\$
  • 3
    \$\begingroup\$ You should include relevant imports in the count, no matter if it is a complete program or function. \$\endgroup\$ – Geobits Aug 4 '15 at 14:30

You must log in to answer this question.