15
\$\begingroup\$

(This might be a duplicate of another question but all of its answers were vague nonanswers, and I can't find it again, so here goes...)

I like python3 and I'm quite good at it; it's rather verbose so when I make long scripts I have a tool script I import that contains lots of shortenings and predefinitions. As long as I don't answer existing questions with it, and as long as I make it freely available (on git?), can I do this and only have the from g import* counted towards my score? or would I be implored to include the bytes of library just cause I wrote it?

It almost feels boring but to say it is, is to call Golfscript and Pyth boring and uninteresting, with which I disagree.

\$\endgroup\$
12
  • 2
    \$\begingroup\$ Note that Pyth, while written in Python, is rather far from a shorthand for Python. It has evolved quite a bit from where it started. \$\endgroup\$
    – Alex A.
    Oct 21, 2015 at 23:17
  • \$\begingroup\$ @AlexA. agreed on the evolution bit, and not to sound thick but since it compiles to python and is very pythonic isn't it kind of just a (developed) shorthand for python? \$\endgroup\$
    – cat
    Oct 21, 2015 at 23:22
  • 4
    \$\begingroup\$ I'd actually like to write a golfing library for Java, specifically to reduce calls to java.lang.Math and java.math.*. I'd like to see this implemented. \$\endgroup\$ Oct 21, 2015 at 23:27
  • 2
    \$\begingroup\$ @Calvin'sHobbies I think what he's asking is to make a specific importable set of methods, not a language. \$\endgroup\$ Oct 21, 2015 at 23:28
  • \$\begingroup\$ @Calvin'sHobbies I've got a whole multipurpose scripting language in the works that should be fun to golf in, but I'm asking about creating g.py which turns print() into p() and input() into q(), which I then import with from g import*: is this OK and how are bytes counted? \$\endgroup\$
    – cat
    Oct 21, 2015 at 23:30
  • 1
    \$\begingroup\$ @VTCAKAVSMoACE But if the methods are to be used in a code-golf answer (and not have the bytes be counted) it needs to count as a different language. \$\endgroup\$ Oct 21, 2015 at 23:32
  • 1
    \$\begingroup\$ @Calvin'sHobbies So would we say "Java with the Golfing Library 'G', x bytes"? \$\endgroup\$ Oct 21, 2015 at 23:33
  • 2
    \$\begingroup\$ @VTCAKAVSMoACE Sure. Though you could think of a more imaginative name. (e.g. Guava) \$\endgroup\$ Oct 21, 2015 at 23:35
  • \$\begingroup\$ @VTCAKAVSMoACE none of the answers actually disagree, how can you infer that just from votes? meta.codegolf.stackexchange.com/a/5427/46231 \$\endgroup\$
    – cat
    Oct 21, 2015 at 23:35
  • 1
    \$\begingroup\$ @sysreq It appears to be the most popular idea is what I was trying to say. \$\endgroup\$ Oct 21, 2015 at 23:36
  • 2
    \$\begingroup\$ You could save some characters by using import g and having g.py shove stuff into builtins \$\endgroup\$
    – gnibbler
    Oct 22, 2015 at 6:45
  • 1
    \$\begingroup\$ I've been working on a similar thing with JavaScript, using lots of unusual constructs: (i+5).a prints the input plus five. \$\endgroup\$
    – Ypnypn
    Oct 22, 2015 at 21:55

4 Answers 4

23
\$\begingroup\$

Yes, and it does not necessarily have to be a separate language.

There's no problem with using your own library as long as it doesn't violate the standard loopholes. In answers where you use it, you should put "Python 3 + <name> library" in the header.

If you go for the library route, you do need to count the import in any answers with it.

\$\endgroup\$
5
  • 3
    \$\begingroup\$ This makes the most sense: why treat a library different from a language? \$\endgroup\$
    – Ypnypn
    Oct 22, 2015 at 21:53
  • 2
    \$\begingroup\$ A estabilished example is "<some shell language> + coreutils", coreutils isn't included in the byte count. \$\endgroup\$
    – Kroltan
    Nov 2, 2015 at 23:28
  • \$\begingroup\$ Why include the import statement? It's trivial to compile foo-with-bar-language to foo-language + bar-lib - are we required to publish such a compiler in order to be eligible for this deduction? \$\endgroup\$ Jul 8, 2017 at 0:27
  • \$\begingroup\$ @JanDvorak Yes (that would be a quite Meta-Golfscripty thing to allow). \$\endgroup\$
    – feersum
    Jul 8, 2017 at 2:27
  • \$\begingroup\$ @feersum Hm... is there an established naming scheme for these languages? \$\endgroup\$ Jul 8, 2017 at 6:55
11
\$\begingroup\$

Yes. But:

According to what I see from the comments and previous relevant questions, the consensus is that you may, however, you must do the following things:

- Define it as not a clean copy.

  • This means declaring it as "<Original Language> + <Library Name (with link)>"

- Provide a link to the library.

  • This is common sense.

- Explain thouroughly

  • Also common sense - if you show up with a library no one has ever seen, nobody's going to know what it actually does.

- The Library cannot be updated after the question exists!

  • This is a general loophole, and must be abided to.
\$\endgroup\$
8
  • \$\begingroup\$ Wait, so I have to call it Gython rather than Python with my G library? \$\endgroup\$
    – cat
    Oct 21, 2015 at 23:48
  • 2
    \$\begingroup\$ I would agree with calling it the latter - you just can't say that it's normal Python with a normal import. \$\endgroup\$ Oct 21, 2015 at 23:48
  • \$\begingroup\$ Additionally, in the case of Java, Oracle don't much like people messing with their stuff. Does this only apply to languages with permissive licences? \$\endgroup\$
    – cat
    Oct 21, 2015 at 23:49
  • 2
    \$\begingroup\$ If you can't find it on an unaltered version of whatever your language your writing the library for, it must be identified as said language with a custom library. It's just not the same language anymore. \$\endgroup\$ Oct 21, 2015 at 23:50
  • \$\begingroup\$ And just for final Clojure: the bytes counted are from g import* or the length of g.py? \$\endgroup\$
    – cat
    Oct 21, 2015 at 23:58
  • 1
    \$\begingroup\$ I'd say the former, but I don't have the full right to say that. I'd suggest an opinion from a moderator for that. \$\endgroup\$ Oct 22, 2015 at 0:05
  • 7
    \$\begingroup\$ RE "The library cannot be updated after the question exists". I disagree. The library cannot be updated to easily solve the question, but new versions of the library can always be created (in which case one might need to specify which version of the library is being used) \$\endgroup\$
    – Justin
    Oct 22, 2015 at 4:12
  • 3
    \$\begingroup\$ I agree with @Justin. It seems silly to freeze development of a golfing library once it gets used for the first time. The solution of specifying "Original Language + Library Name + Version (with link)" as the "language" of the post, with the "Version" being one that existed prior to the creation of the question, seems like a good one. (...and it just now occurs to me that I haven't even posted on this site so why should anyone listen to me? But the argument seems solid, anyway.) \$\endgroup\$
    – David Z
    Oct 26, 2015 at 7:51
5
\$\begingroup\$

Yes, but make a language not a library

Writing a library might be acceptable but we definitely allow the creation of custom languages.

To achieve your goal you could make up a language called "Mython" (or whatever you want to call it) and write this compiler for it:

p = print
q = input
def runMython(code):
    exec(code)

So if you wanted to run the Mython code

x = "dog"
p(q() + x)

You could just do

runMython("""
x = "dog"
p(q() + x)
""")

This is better than a library because you don't even need the import.

As always, languages are (usually) only valid in challenges that were posted after the language was invented.

\$\endgroup\$
4
  • \$\begingroup\$ Hmm. Perhaps I'll just get to work on an interpreter for the actual, non-pathetic language I'm actually designing from actual scratch. \$\endgroup\$
    – cat
    Oct 22, 2015 at 0:02
  • 3
    \$\begingroup\$ This is better. The Library route would be good, but using this would both reduce byte count and de-clutter answer headers. +1 \$\endgroup\$ Oct 22, 2015 at 0:16
  • 4
    \$\begingroup\$ -1. This works for Python, but making a Mjava compiler would be a huge pain involving complex file manipulations. \$\endgroup\$
    – Ypnypn
    Oct 22, 2015 at 21:52
  • \$\begingroup\$ -1. Didn't golf the Mython interpreter. :P \$\endgroup\$
    – mbomb007
    Oct 30, 2015 at 15:03
1
\$\begingroup\$

Yes, but make it runnable on its own

You don't necessarily need a compiler, as long as you can run mython myscript.my (or whatever your language is called) from the command line.

One way of achieving this would be to make a small shell script that somehow ran Python with the right flags and parameters so that your library is loaded at startup. I don't know for Python, but this option exists for other languages such as Ruby and Perl. I know because I have very similar plans to yours :)

\$\endgroup\$

You must log in to answer this question.

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