7
\$\begingroup\$

Yes. COBOL. I assume that the full power of a compiler implementation may be used... but, COBOL has some historical disadvantages if used for code-golf, at least for compilers which do not support various relaxations (but which in turn don't have some other stuff, gain on the swings, lose on the roundabouts).

Specifically, I want to use IBM's Enterprise COBOL compiler V4.2.

A COBOL line occupies 72 bytes in a fixed layout. http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=%2Fcom.ibm.entcobol.doc_4.1%2FPGandLR%2Fref%2Frlfmt.htm

The first six bytes, the sequence-number area, cannot contain code. The compiler ignores these bytes (although a compiler may, optionally, check for ascending numerical sequence and issue a warning diagnostic message).

The seventh byte cannot contain code. It is called the indicator column. It can contain a comment indicator. It can contain a debug-line indicator. It can contain a "print a heading on the compiler listing now" indicator. It can contain a character used for the continuation of literals that do not fit between columns 12 and 72 (and which must be bounded by single- or double-quotes).

Area A is bytes 8-11. Area B is bytes 12-72. Some statements should only start in Area B, but the diagnostic messages can be ignored, so this is not a problem.

There is trailing physical space on a line up to and including byte 72.

Question 1.

Would it be clear that it would be OK not to count positions 1-6 and 73-80 of a COBOL source line?

Question 2.

Can the indicator column (byte seven) be ignored? I cannot contain code.

Question 3.

Can the trailing space be ignored.

/blatantgoading on

Of course, if anyone is scared of being beaten at code-golf by a COBOL program, they will vote this discussion down.

/blatantgoading off

I would expect to be able to beat JAVA where a reasonable golf-COBOL solution exists. Of course, I don't mind what languages I manage to beat (if any).

Here are a couple of example COBOL programs for those unfamiliar with the language. An ID DIVISION, PROGRAM-ID and PROCEDURE DIVISION are required, as are full-stops/periods after those, and at various other points.

Some may feel this is a sufficient disadvantage, without having to count 72 characters for each and every line.

COBOL has some handicaps for code-golf, anyway. I'd just like the seven leading bytes and trailing space not to be counted, if possible.

There are some COBOL examples already:

From Cereal, Generate a pronouncable word

This uses a Micro Focus compiler which does not require "the DIVISIONs" but does seem to require the seven leading characters for each line (the example can be drastically reduced in size).

From gnibbler on SO, https://stackoverflow.com/questions/2406780/code-golf-triforce/2414416#2414416

And now mine, one golfed, Happy Birthday to Me!, and two for popularity, Execute prints backwards, Bloatware contest: producing 100+ MiB executable

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Divide a into b giving c remainder r? :) \$\endgroup\$ Feb 18, 2014 at 21:16
  • \$\begingroup\$ @belisarius And IDENTIFICATION DIVISION and that sort of stuff. Yes. See, for code-golf Identification can be reduced to Id :-) \$\endgroup\$ Feb 18, 2014 at 21:23
  • 1
    \$\begingroup\$ I think whenever someone actually does the code in COBOL, that should be an instant win! \$\endgroup\$
    – SztupY
    Feb 19, 2014 at 23:58
  • \$\begingroup\$ @SztupY Well, I think there are a total of six COBOL answers already, four linked-to in the question. Can you arrange that then please? Can I take that as a vote for "yes" to all three questions? \$\endgroup\$ Feb 20, 2014 at 0:06
  • 1
    \$\begingroup\$ @belisarius Exactly why I hate COBOL, the only language I say that about! \$\endgroup\$
    – CJ Dennis
    May 16, 2015 at 9:56
  • 3
    \$\begingroup\$ @CJDennis If you can't stand the heat, get out of the ktichen. It's not obligatory to tell people you're a bad cook, but no-one's going to stop you. \$\endgroup\$ May 16, 2015 at 10:48

2 Answers 2

2
\$\begingroup\$

For triforce I passed -free -x to cobc.

I don't think I counted those command line parameters toward my answer, but the usual convention is to add them to the character count

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. I have a specific compiler in mind (IBM's Enterprise COBOL) which does not have -free. I've updated triforce, by the way. \$\endgroup\$ Feb 19, 2014 at 16:31
2
\$\begingroup\$

I submitted a golfing answer written is z/OS Assembler. I used f p'¬' to count only the actual characters of source (find non-blank) but also included the size of the executable in bytes - I think assembler will beat COBOL on that one :-)

You could, perhaps, resign yourself to the fact that you won't win and submit bytes of actual code (omitting the compulsory DIVISION statements etc) and number of character in the source as separate figures.

\$\endgroup\$
1

You must log in to answer this question.

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