5
\$\begingroup\$

There has been discussion whether the #lang racket line should be included in code golf submissions.

So really the question is two-fold:

  • The technical aspect: Is it possible to run Racket code without the #lang racket line?
  • Poll: If it isn't possible to run Racket code without the #lang racket line, should this it be necessary in code golf submissions?

Edit

It turns out one can use #!racket instead of #lang racket as a shorter alternate form.

Edit 2

It turns out you do not strictly need the #lang racket when you do this: racket -e "$(< your-racket-file.rkt)" or possibly more likely racket -e "$(pbpaste)" or similar.

Edit 3

Even simpler -- racket -f your-racket-file.rkt works without #lang racket.

| |
\$\endgroup\$
18
\$\begingroup\$

No.

It's like a shebang, there's no need to count it. I see no reason to include a line that's meant for the shell/compiler. Its not like its real code, it doesn't add to your answer in any way.

Nobody counts shebangs in Bash scripts, since you don't need them to run, so why do that with Racket?

#!/usr/bin/env bash
rm -rf /

Now how many characters is this code? I'd say 8, because that's how long rm is. The shebang doesn't do anything to the code except tell the shell what language the code is. It's like a file extension, but in the file. Are we going to add five bytes for adding .java?

We can easily remove the shebang by using sh or by adding the file extension .sh, meaning we get:

rm -rf /

Wow... now it's only 8 bytes... wylat...

Now let's do that with Racket.

#lang racket
"Hello, World!"

#lang racket specifies the language. It is not needed to run Racket programs in files:

$ cat hello.racket
"Hello, World!"
$ racket -f hello.racket
Hello, World!

There's no need for it, so there's no need to count it.

| |
\$\endgroup\$
  • \$\begingroup\$ In Perl, shebangs have to be counted too. So no reason why Racket should be any different. :-) \$\endgroup\$ – Chris Jester-Young Jul 29 '15 at 0:36
  • \$\begingroup\$ @ChrisJester-Young But you don't need it. I see no reason to include a line that's meant for the shell/compiler. Its not like its real code. \$\endgroup\$ – phase Jul 29 '15 at 0:38
  • 1
    \$\begingroup\$ I'm on this boat, as it is possible to run Racket code without the #lang racket line. While it is hacky, it certainly works. See the Question edits for more info. \$\endgroup\$ – Winny Jul 29 '15 at 1:16
  • \$\begingroup\$ Check out the question again, found a method that looks legitimate. racket -f that-file.rkt \$\endgroup\$ – Winny Jul 29 '15 at 3:55
  • 6
    \$\begingroup\$ @Winny ;-; That's just running the file through the compiler(/interpreter?), like every language. If that's an option, why is this a question?!? You can use a shebang with Java, but most people just use javac. \$\endgroup\$ – phase Jul 29 '15 at 4:06
  • 1
    \$\begingroup\$ @phase Because there is some dissent between some members of the community over it. Winny thinks we don't need to count the line. I feel that we do. This question's purpose is to get some clarity on the topic with the community at large. \$\endgroup\$ – Chris Jester-Young Jul 29 '15 at 17:39
  • 1
    \$\begingroup\$ @phase I think your bash shebang should be #!/usr/bin/env bash, nice update btw! \$\endgroup\$ – Winny Jul 29 '15 at 18:45
  • 5
    \$\begingroup\$ When I voted no, I did it assuming that #lang racket (12 characters) will be free, but a variant like #lang typed/racket (18 characters) will still cost the difference (6 characters in this case). \$\endgroup\$ – manatwork Jul 30 '15 at 6:38
-1
\$\begingroup\$

Yes.

Count the #lang racket in the character count.

| |
\$\endgroup\$
  • 9
    \$\begingroup\$ Why? What's your rationale for your claim? \$\endgroup\$ – Anubian Noob Aug 4 '15 at 20:33

You must log in to answer this question.

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