# Is a language with an extension a valid golfing language?

In a current challenge, Falsify brief truths, @Lynn proposed an edit to my Haskell answer that requires the NoMonomorphismRestriction language extension.

As this extension is not part of the Haskell2010 language, it seems to me that one might consider Haskell2010 + NoMonomorphismRestriction to be its own language.

### Pros

• Language extensions could encourage creative solutions.
• Extensions don't usually save more than a couple bytes, as far as I know.
• Activating language extensions take more bytes than they're worth, currently. (-XNoMonomorphismRestriction is 27 bytes, while the proposed solution is 37 bytes).
• Some people (including myself) enjoy learning programming techniques from code golf, that can be applied to non-golf coding. This would open up more opportunities for that.
• Problems like: "Yes, for this challenge I'm using extension number 689865434678 to Pyth, which makes the blank program the solution to this challenge" are covered by the MetaGolf loophole and the Using a made-up language loophole.

### Cons

• I'm not sure what precisely constitutes a language extension

What do you think?

• So then any -M switch would be free for Perl? That'd be... amazing. May 29, 2016 at 5:56
• @msh210 There is a huge difference between language extensions and modules. Modules contain actual code and give you additional functions for free, while extensions modify how the language behave and what is or isn't allowed. For example, I'd say that "use strict" should be free, but "use Acme::Foo" should not. May 7, 2017 at 8:18

Using a third-party library/module/extension/whatever has always been allowed by default. It should be noted in the answer that it is not the "vanilla" language (something like Language + Library/Libraries is the most common way). However, any code needed to access the functionality of the library (such as Python's import, C/C++'s #include and -l, Perl's use or -M, Node.js's require, etc.) must be included in the submission code. For example, if you're using Python + NumPy, you don't get import numpy as np for free. What you do get for free is the assumption that a certain third-party library (or set of third-party libraries) is present on the machine, and can be used via the normal mechanisms of the language.

On a related note, you can also mix languages this way, such as through pipes in Bash-like shells.

• What if you're writing a browser-JS solution with, for example, jQuery? There is no require or equivalent for the browser May 29, 2016 at 16:56
• @Upgoat I'd consider jQuery its own separate language for these purposes, so you get the loading for free (since it would normally be done on the HTML side with a script tag).
– user45941
May 29, 2016 at 19:28
• I'm not sure how your answer applies to the specific case I mentioned. The NoMonorphismRestriction extension to Haskell only affects the type checker, so it's not adding functions or anything, but you do need a flag, pragma, or .cabal setting to activate it (for GHC). May 30, 2016 at 0:10
• @MichaelKlein In that case, you'd need to include the flag, pragma, or config setting in your byte count, as per usual.
– user45941
May 30, 2016 at 0:19
• @Mego But then it can never be used. I can't imagine that it would ever be worth 27 bytes so an entire class of valid and interesting answers become impossible. Maybe I could upload a script that runs GHC with this flag and call it a new language, but that seems ridiculous. Unless you're advocating a "slippery slope" approach, this doesn't make sense to me. May 30, 2016 at 0:25
• @MichaelKlein There's no rule saying you can't make a new "language" that is just Haskell with that option enabled.
– user45941
May 30, 2016 at 0:30
• @Mego I know, it just seems ridiculous that doing that would be the solution. Extensions like this don't add any functions or hide bytes, they usually make it more challenging to write code. May 30, 2016 at 0:39
• What about, for example, vim-plugins? This doesn't require any code (in the vim program) to include other than having the files present on the machine and in the right folders. Does this mean that any vim-plugin that was published before the challenge is fair-game and doesn't add to the byte count? Jun 10, 2016 at 22:14
• @DrGreenEggsandIronMan I'd say yes, so long as you included the plugin(s) in the header. It would be different than a vanilla vim submission.
– user45941
Jun 10, 2016 at 22:16

I would say that using a language extension that only modifies the syntax and/or semantics of the language should be free and count as a separate language, as long as it doesn't give you new functions you can call.

I believe that all Haskell extensions would fall under this category (correct me if I'm wrong), as well as use strict and friends in perl, and most flags for the C/C++ compiler. In the case of vim, I think introducing a new normal mode command should count as a function and not a language extension.

There are probably many problematic edge cases I'm missing, but the basic idea is that an extension doesn't give you functionality for free, but changes how code looks and how the language behaves.