5
\$\begingroup\$

JavaScript comes to mind as a language without a traditional outputting mechanism.

In this instance, document.write() is suggested, but its specific to the browser, not to the JavaScript/ECMAScript language (in addition to being verbose).

Obviously, this matters, since with CodeGolf, every character 'counts'.

So, how can these instances be handled fairly?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Related question: meta.codegolf.stackexchange.com/questions/13/… \$\endgroup\$
    – Nakilon
    Jan 28, 2011 at 1:56
  • 2
    \$\begingroup\$ Use alert for output and prompt for input ? \$\endgroup\$
    – HoLyVieR
    Jan 28, 2011 at 17:29
  • \$\begingroup\$ @HoLyVieR Clever idea, though those are also browser specific functions, and not native to the language. \$\endgroup\$
    – Yahel
    Jan 28, 2011 at 18:36
  • 3
    \$\begingroup\$ On spidermonkey (JS), I think there's print and readline. \$\endgroup\$
    – Nabb
    Feb 3, 2011 at 2:43
  • \$\begingroup\$ Well, Burlesque does not have a print statement. It has no access to any I/O (except stdin already lies on the stack). For golfing it is assumed, that the stack is printed to stdout at program termination. (That is, a Burlesque program CAN'T produce any output until it terminates.) \$\endgroup\$
    – mroman
    Sep 7, 2013 at 11:22

2 Answers 2

2
\$\begingroup\$

I think you should treat a challenge almost the same as a task or project your boss wants you to work on.

If the language you want to use to solve this task isn't appropriate, I suppose you won't ask your boss to adjust the project, to fit to your preferred programming language.
Instead, you'll choose an appropriate language, to solve the problem fast and elegant.

The other possibility, much easier on Codegolf.SE than explaining to your boss, would be to accept the challenge, deal with the pitfalls of your preferred language, and perhaps come up with a solution you never thougt about before, just to compensate some weird input/output mechanisms.

So, as long as the problem doesn't specify the language it wants to be solved in, it's your choice.

\$\endgroup\$
1
  • \$\begingroup\$ Indeed yes. In the 8086 emulator I switched back and forth between terminal output and graphical output. Not a golf per se, but I tried to be terse. If you can access a bitmapped alphabet with a short url, you cat blit letters to an image and show that (makes it sound easy hoping no one asks any questions :) \$\endgroup\$ Jan 29, 2013 at 9:11
1
\$\begingroup\$

Some CodeGolf questions are about completing a full program - usually with specified input and output formatting. For such challenges, I'd say that JavaScript, or, say, SQL, would be inappropriate langauges.

On the other hand, some CodeGolf questions are about creating a function that performs the operation, and the input and output are left to be what ever is "natural" in the given language. For these, JavaScript will be fine.

Now - If someone defined a CodeGolf that was to create an HTML document... I suppose creating via the DOM would be just peachy!

\$\endgroup\$
1
  • \$\begingroup\$ T-SQL has PRINT, at least ;-) \$\endgroup\$
    – Joey
    Jan 28, 2011 at 8:11

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