45
\$\begingroup\$

Challenge:

In the programming language of your choice, take no input and output your programming language's name.

Fair enough, right?

Restrictions:

  • You can't use any character that is included in your programming language's name in your code. E.g., if I use Batch, I must not use the chars 'B' 'a' t' 'c' 'h' in my code. Note that this is case sensitive. I can still use the char 'b' because it's different from 'B'.
  • You can have "junk output" before or after the name of the language
  • Version number doesn't count as part of the name of the language. E.g., I can use the number 3 in the code in my answer if it's in Python 3
  • The output of the programming language name is not case sensitive.
  • Brute-forcing all possible letter combinations and hoping you get your language name is forbidden.

Example outputs: (let's say my programming language is called Language) (✔ if valid, else ✖)

  • Language
  • Body language is a type of non-verbal communication in which physical behavior, as opposed to words, is used to express or convey information. Such behavior includes facial expressions, body posture, gestures, eye movement, touch and the use of space.
  • Language 2.0 - © 1078 AD some company
  • foobar

This is thus shortest code wins.

\$\endgroup\$
  • 7
    \$\begingroup\$ The rule about case sensitive restrictions is very ambiguous. Which is the correct orthography: BASIC Basic or basic? I'm pretty sure I can find examples for all three. \$\endgroup\$ – Level River St Jan 24 '17 at 23:47
  • 7
    \$\begingroup\$ Obligatory "Just having your code be blank but have a flag like --version isn't allowed"? \$\endgroup\$ – Value Ink Jan 25 '17 at 0:00
  • 88
    \$\begingroup\$ Have case-insensitive output while banning the language name case-sensitively allows boring solutions that just output the language name case-swapped. \$\endgroup\$ – xnor Jan 25 '17 at 0:47
  • 12
    \$\begingroup\$ You made a mistake by allowing users to output junk data. All they have to do is use a language where the compiler include the name whenever there's an error. It's cool but not the challenge I was hoping for \$\endgroup\$ – Lynob Jan 26 '17 at 8:23
  • 3
    \$\begingroup\$ This question really needs to be specified that "Code" must be run. Most languages will show their name in the usage dump if you don't give any code--for instance "Java" or "Groovy" at the command line with no code will display the correct name, however if you pass code (even "empty" code) as in (groovy -e "") you will get an empty response. Same for compile problems, the compiler usage or error output does not mean you wrote a program. \$\endgroup\$ – Bill K Jan 26 '17 at 18:30

129 Answers 129

68
\$\begingroup\$

Outputs to STDERR

Outputting to STDERR is now at +33/-21 as an allowed default, which is positive but contested. This is a CW answer to collect answers that just invoke an error in a language where error messages includes the language name.

Haskell, 1 byte

1

Error:

Parse error: naked expression at top level
Perhaps you intended to use TemplateHaskell

Lua, 1 byte

1

Error:

lua: .code.tio:1: syntax error near <eof>

(file name is unimportant)

Batch, 1 byte

~

Error:

'~' is not recognized as an internal or external command,
operable program or batch file.

tinylisp, 5 bytes

(c()1

Error:

Error: cannot cons to Int in tinylisp

R, 1 byte

)

Error:

Error: unexpected ')' in ")"

Java bytecode, 0 bytes

Error:

Exception in thread "main" java.lang.ClassFormatError: Truncated class file

Groovy, 1 byte

a

Note that a can be replaced with any other character

Error:

groovy.lang.MissingPropertyException: No such property: a ...

MATLAB, 1 byte

\

Error:

Error: Unexpected MATLAB operator.

PHP, 3 bytes

<?=

Error:

PHP Parse error:  syntax error, unexpected end of file in /home/runner/.code.tio on line 1

CJam, 1 byte

/

Error:

/
^
RuntimeException: The stack is empty
Java exception:
java.lang.RuntimeException: The stack is empty
    at net.aditsu.cjam.CJam.pop(CJam.java:75)
    at net.aditsu.cjam.Op2.run(Op2.java:10)
    at net.aditsu.cjam.Block.run(Block.java:304)
    at net.aditsu.cjam.CJam.runCode(CJam.java:210)
    at net.aditsu.cjam.CJam.main(CJam.java:240)

Twig, 2 bytes

Twig is a template language written in PHP. It's possible that this is a polyglot.

{{
{%
{#

Error:

PHP Fatal error:  Uncaught exception 'Twig_Error_Syntax' with message [...] in [...][...]:n:
Stack trace:
#0 [...]

The message varies depending on which program you choose.

S.I.L.O.S, 2 bytes

x+

Try it online! Trivially invokes undocumented behavior. Silos is the name of the language.

Python, 6 bytes

pYTHON

As the character restriction is case insensitive, and the output doesn't have to be in the correct case, this is a valid answer. The error message it produces is something like this:

Traceback (most recent call last):
  File ".code.tio", line 1, in <module>
    pYTHON
NameError: name 'pYTHON' is not defined

Try it online! (outputs to 'debug' tab)

JavaScript, 10 bytes

jAVAsCRIPT

This produces the following error message or similar in all environments:

ReferenceError: jAVAsCRIPT is not defined

QBIC, 6 bytes

?b(12)

In 6 bytes, we can put QBIC encountered error: 9 on the screen, signifying an out-of-bounds error.

ForceLang, 2 bytes

()

Error produced:

Exception in thread "main" lang.exceptions.IllegalInvocationException: null is not a function.
    at lang.ForceLang.parse(ForceLang.java:99)
    at lang.ForceLang.main(ForceLang.java:129)

Pip, 5 bytes

1~`[`

(Note: this works in the current version as of this writing, 0.17.09.01. No guarantees the interpreter won't change to handle this error differently in the future.)

Tries to regex match with a syntactically invalid pattern. The error produced will look something like this:

Traceback (most recent call last):
  File "/opt/pip/pip.py", line 221, in <module>
    pip(interactive=False)
  File "/opt/pip/pip.py", line 206, in pip
    state.executeProgram(tree, args)
  File "/opt/pip/execution.py", line 56, in executeProgram
    returnVal = self.functionCall(mainFunction, cmdLineArgs)
  File "/opt/pip/execution.py", line 368, in functionCall
    returnVal = self.getRval(returnExpr)
  File "/opt/pip/execution.py", line 235, in getRval
    expr = self.evaluate(expr)
  File "/opt/pip/execution.py", line 213, in evaluate
    result = opFunction(*args)
  File "/opt/pip/execution.py", line 1134, in FIRSTMATCH
    matchObj = regex.asRegex().search(str(string))
  File "/opt/pip/ptypes.py", line 175, in asRegex
    self._compiled = re.compile(pyRegex)
  File "/usr/lib64/python3.6/re.py", line 233, in compile
    return _compile(pattern, flags)
  File "/usr/lib64/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib64/python3.6/sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib64/python3.6/sre_parse.py", line 765, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib64/python3.6/sre_parse.py", line 523, in _parse
    source.tell() - here)
sre_constants.error: unterminated character set at position 8

Stax, 2 bytes

0u

Error:

Stax runtime error: rational divide by zero

zh also works.

ink, 1 byte

~

~ at the start of a line marks that the line is a statement to be executed, rather than text to be printed. As of whichever version of inklecate TIO is using, if there's nothing after the ~, the interpreter crashes with the following error:

System.NullReferenceException: Object reference not set to an instance of an object
  at Ink.InkParser.LogicLine () [0x000b1] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.OneOf (Ink.StringParser+ParseRule[] array) [0x0000a] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser.StatementAtLevel (Ink.InkParser+StatementLevel level) [0x00009] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser+<>c__DisplayClass134_0.<StatementsAtLevel>b__0 () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.Interleave[T] (Ink.StringParser+ParseRule ruleA, Ink.StringParser+ParseRule ruleB, Ink.StringParser+ParseRule untilTerminator, System.Boolean flatten) [0x00040] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser.StatementsAtLevel (Ink.InkParser+StatementLevel level) [0x0004f] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser.Parse () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.Compiler.Compile () [0x00033] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.CommandLineTool..ctor (System.String[] args) [0x001a3] in <d64e27e7788347b2a5377c9e19bbdcab>:0 
  at Ink.CommandLineTool.Main (System.String[] args) [0x00000] in <d64e27e7788347b2a5377c9e19bbdcab>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Ink.InkParser.LogicLine () [0x000b1] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.OneOf (Ink.StringParser+ParseRule[] array) [0x0000a] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser.StatementAtLevel (Ink.InkParser+StatementLevel level) [0x00009] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser+<>c__DisplayClass134_0.<StatementsAtLevel>b__0 () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.StringParser.Interleave[T] (Ink.StringParser+ParseRule ruleA, Ink.StringParser+ParseRule ruleB, Ink.StringParser+ParseRule untilTerminator, System.Boolean flatten) [0x00040] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser.StatementsAtLevel (Ink.InkParser+StatementLevel level) [0x0004f] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.InkParser.Parse () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.Compiler.Compile () [0x00033] in <b1e5e74f4ee842fc961297862cf23e07>:0 
  at Ink.CommandLineTool..ctor (System.String[] args) [0x001a3] in <d64e27e7788347b2a5377c9e19bbdcab>:0 
  at Ink.CommandLineTool.Main (System.String[] args) [0x00000] in <d64e27e7788347b2a5377c9e19bbdcab>:0 
\$\endgroup\$
  • 19
    \$\begingroup\$ Isn't the empty string contained in the language's name? :D \$\endgroup\$ – mbomb007 Jan 25 '17 at 15:08
  • 21
    \$\begingroup\$ The C and R ones are clever. \$\endgroup\$ – DLosc Jan 26 '17 at 7:10
  • 2
    \$\begingroup\$ @mbomb007 but it's not a character, therefore it's not a character included in the language's name. \$\endgroup\$ – user253751 Jan 27 '17 at 4:26
  • 1
    \$\begingroup\$ Does the S.I.L.O.S one count? It doesn't output the periods. \$\endgroup\$ – Business Cat Feb 6 '17 at 17:16
  • 11
    \$\begingroup\$ "Java bytecode, 0 bytes". First time I see Java triumphing above ALL of those other languages mentioned. :) \$\endgroup\$ – Kevin Cruijssen Jul 3 '17 at 11:26
49
\$\begingroup\$

SmileBASIC, 11 bytes

sPsET.,1474

Equivalent to SPSET 0,1474. Sets sprite 0 to definition 1474, which is the SmileBASIC logo.

Screenshot

\$\endgroup\$
44
\$\begingroup\$

MATL, 1 byte

Y

Output is through STDERR, which is allowed by default.

The output from the offline compiler is

Error using matl_parse (line 339)
MATL error while parsing: Y not recognized at position 1
Error in matl (line 234)
    S = matl_parse(s, useTags); 

Or try it online! (expand "debug" section).

\$\endgroup\$
  • 7
    \$\begingroup\$ Should you merge with this? \$\endgroup\$ – wizzwizz4 Jan 25 '17 at 18:31
  • \$\begingroup\$ @wizzwizz4 I'm not sure. I asked in chat and got these two replies, so it's not really clear \$\endgroup\$ – Luis Mendo Jan 25 '17 at 19:47
  • 1
    \$\begingroup\$ yeah but Y tho? \$\endgroup\$ – sagiksp Jan 26 '17 at 9:34
  • \$\begingroup\$ @sagiksp Anything that throws an error will do, such as X or Z. This is because X, Y or Z are prefixes of two-char function names, so a Y by itself is invalid \$\endgroup\$ – Luis Mendo Jan 26 '17 at 10:55
38
\$\begingroup\$

R, 1 byte:

T

T is an alias for the constant TRUE. So the output for the above is:

[1] TRUE

Since junk is allowed around the name, the “R” in there is the language name.

(As noted in a comment elsewhere, pretty much any single letter and many glyphs will work equally well because they trigger the message “Error: …”, which contains “r”.)

\$\endgroup\$
31
\$\begingroup\$

HTML, 24 20 bytes

&#72;&#84;&#77;&#76;


HTML, 16 bytes

As pointed out by @Bob, modern browsers will recognize HTML entities without semicolons, though it's technically invalid HTML. Of course, it's perfectly valid for code golf.

&#72&#84&#77&#76


HTML, 4 bytes

And of course, the uninteresting answer.

html


Also, see my CSS answer.

\$\endgroup\$
  • 3
    \$\begingroup\$ You can save four characters by using decimal instead: &#72;&#84;&#77;&#76;. You can save an additional four characters by dropping the semicolons, at the cost of being technically invalid HTML (but still working in modern browsers). \$\endgroup\$ – Bob Jan 25 '17 at 3:26
  • \$\begingroup\$ Why doesn't HTML count? \$\endgroup\$ – Stop Harming Monica Jan 25 '17 at 13:51
  • 1
    \$\begingroup\$ @OrangeDog "You can't use any character that is included in your programming language's name in your code" \$\endgroup\$ – darrylyeo Jan 25 '17 at 18:39
  • \$\begingroup\$ But html should be valid, reducing the score by 12 bytes. \$\endgroup\$ – Christoph Jan 27 '17 at 11:09
  • 3
    \$\begingroup\$ @Clearer This is code golf! As long as it works in at least one environment, who cares whether W3C thinks it's valid? \$\endgroup\$ – darrylyeo Feb 15 '17 at 15:31
26
\$\begingroup\$

Vim, 0 bytes



When you start Vim, the editor displays a splash screen which looks like this:

Vim splash screen

You can see it says Vim here:

Vim splash screen with vim highlighted

Previous answer:

Vim, 1 byte

<Ctrl-C>

In Vim 8, pressing will display Type :quit<Enter> to exit Vim at the last line. I'm not completely sure if this counts.

\$\endgroup\$
  • 1
    \$\begingroup\$ It should count. Ctrl-C actually has its own ASCII code (code 3, also called ETX or "end of text"), so this is a pure-ASCII program (if not purely printable ASCII). You can use that to prove that the program's one byte long, and displaying text on screen counts. \$\endgroup\$ – user62131 Jan 25 '17 at 14:36
  • 4
    \$\begingroup\$ Since when is "vim" a programming language? \$\endgroup\$ – DepressedDaniel Jan 27 '17 at 3:26
  • 4
    \$\begingroup\$ @DepressedDaniel vim is actually a scripting language if you take a deeper look into the internals. All those fancy keystrokes are instructions => you're programming when you're controlling your editor. \$\endgroup\$ – bash0r Jan 27 '17 at 13:32
  • 1
    \$\begingroup\$ @DepressedDaniel is it turing complete? If it's not, I don't think it should count. \$\endgroup\$ – Clearer Feb 14 '17 at 1:45
  • 3
    \$\begingroup\$ @dfeuer I've come to agree with you, since I made that comment more than 2 years ago. \$\endgroup\$ – Clearer Aug 13 at 6:57
20
\$\begingroup\$

Python, 15 bytes

Python 2 (15)

exec"\150elp()"

It concatenates the strings uses the octal 150 which is h and "elp()" and runs the result. This prints the help() command which says "Welcome to Python 3.5's help utility!", meeting the requirements.

Python 3 (17)

exec("\150elp()")

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Not sure help counts, it only works in a REPL environment. \$\endgroup\$ – xnor Jan 25 '17 at 1:09
  • \$\begingroup\$ It still prints out the Python. That's all that's required. \$\endgroup\$ – user63571 Jan 25 '17 at 1:16
  • 1
    \$\begingroup\$ Never mind, I was mistaken and it works as a program. Sorry about that. \$\endgroup\$ – xnor Jan 25 '17 at 1:22
  • 1
    \$\begingroup\$ you have used the letter 'p' \$\endgroup\$ – Matt Jan 25 '17 at 15:34
  • 3
    \$\begingroup\$ p is allowed but P isn't. Rule 1. \$\endgroup\$ – user63571 Jan 25 '17 at 17:54
18
\$\begingroup\$

C, 0 bytes.

/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status

Try it online!

\$\endgroup\$
  • \$\begingroup\$ where is the name ? Or do you refer to the c characters in there ? \$\endgroup\$ – HopefullyHelpful Jan 26 '17 at 11:46
  • 3
    \$\begingroup\$ This should be marked as C (gcc), because other compilers have different messages. \$\endgroup\$ – orlp Jan 26 '17 at 12:47
  • \$\begingroup\$ Meh, your c's come from extremely implementation-dependent sources. Would have been nicer if you at least provoked a message that contains c in some boilerplate output. \$\endgroup\$ – DepressedDaniel Jan 27 '17 at 3:24
  • 1
    \$\begingroup\$ @DepressedDaniel undefined reference to 'main' \$\endgroup\$ – Loren Pechtel Jan 27 '17 at 5:59
  • \$\begingroup\$ @LorenPechtel Fair enough, missed that. \$\endgroup\$ – DepressedDaniel Jan 27 '17 at 6:02
17
\$\begingroup\$

Huh?, 0 bytes



(no, there's nothing in that code block)

The language is named for its output, so...

In the implementation I checked, the interpreter takes the length mod 8 of each line of a given file, and switches depending on the result. For zero, it prints Huh?. Since it strips trailing newlines, you could also do a 1 byte (\n) version.

Note that it's not outputting to stderr or caseswapping or any other trickery. It's just that Huh?'s very confused interpreter finally came in handy.

\$\endgroup\$
  • \$\begingroup\$ Wait, is this language Turing complete? \$\endgroup\$ – Hello Goodbye Nov 18 at 15:08
13
\$\begingroup\$

V, 2 bytes

¬U

Try it online!

The obvious answer is:

év~

Try it online!

Which is "Insert the letter 'v', and toggle case". However, since you allow for junk output before/after the language name, this works too.

The ¬ command takes two characters for input, and inserts every ASCII character between them. If we don't supply the second character, it automatically defaults to ÿ (ASCII 0xff), so this program inserts every character in the latin1 encoding between U and ÿ.

\$\endgroup\$
13
\$\begingroup\$

brainfuck, 54 bytes

+[[-<]-[->]<-]<.<<<<.>>>>-.<<-.<.>>.<<<+++.>>>---.<++.

Outputs brainfuck, assuming an 8-bit tape open on the left. Try it online!

As always, partial credits go to @primo's Hello, World! answer.

Alternatives with different casing

Brainfuck (62 bytes):

+[<-[-<]-[->]<<]<---.<<<<<<--.>>>-.<+.<.>---.<<+++.>>---.<---.

BrainFuck (68 bytes):

-[[-<]->+[->]<-]<<.<<<<<--.>>+.<-.+++++.>>>------.<<<<+++.>>++.<---.
\$\endgroup\$
12
\$\begingroup\$

MATLAB, 3 bytes

ver

Output is as follows. Irrelevant info has been replaced by [...]). Some parts of the output may change depending on version, installed toolboxes etc.

-----------------------------------------------------------------------------------------
MATLAB Version: 8.6.0.267246 (R2015b)
MATLAB License Number: [...]
Operating System: [...]
Java Version: Java 1.7.0_60-b19 with [...]
-----------------------------------------------------------------------------------------
MATLAB                                                Version 8.6         (R2015b)
Communications System Toolbox                         Version 6.1         (R2015b)
Curve Fitting Toolbox                                 Version 3.5.2       (R2015b)
[...]
Wavelet Toolbox                                       Version 4.15        (R2015b)
\$\endgroup\$
  • \$\begingroup\$ Uses a v and an e \$\endgroup\$ – user63571 Jan 25 '17 at 0:31
  • \$\begingroup\$ Your language is Octave, so you can't use v and e. \$\endgroup\$ – JungHwan Min Jan 25 '17 at 0:31
  • 6
    \$\begingroup\$ Woops. Corrected by changing language to Matlab (which was my initial intent anyway) \$\endgroup\$ – Luis Mendo Jan 25 '17 at 0:55
12
\$\begingroup\$

Python, 27 53 49 48 45 bytes

-3 bytes from @wizzwizz4

exec eval('"IMpORT THIS".LOWER()'.swapcase())

Prints the following text, which has "Python" on the first line.

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
\$\endgroup\$
  • 1
    \$\begingroup\$ @Arnauld fixed! \$\endgroup\$ – Value Ink Jan 25 '17 at 0:27
  • 1
    \$\begingroup\$ HELP() or HELP(HELP) is shorter. \$\endgroup\$ – Gurupad Mamadapur Jan 25 '17 at 8:14
  • \$\begingroup\$ It doesn't matter if you swap the case of the import string, because you're making it lower-case anyway. -3 bytes. \$\endgroup\$ – wizzwizz4 Jan 25 '17 at 18:39
  • \$\begingroup\$ @GurupadMamadapur the Python 3 answer already covered it and better (pretty sure my code would be the exact same), so I'm not in the mood to use it too. Guess I'm sticking to import this. \$\endgroup\$ – Value Ink Jan 27 '17 at 9:20
  • \$\begingroup\$ @ValueInk Alright then. \$\endgroup\$ – Gurupad Mamadapur Jan 27 '17 at 14:00
12
\$\begingroup\$

Python 2 (1 byte)

è

output...:

output

\$\endgroup\$
  • \$\begingroup\$ Are you sure this is only 1 byte? \$\endgroup\$ – Okx Jul 27 '17 at 22:38
  • 1
    \$\begingroup\$ Agreed. It's 2 bytes in UTF-8 \$\endgroup\$ – mbomb007 Oct 20 '17 at 13:48
  • \$\begingroup\$ The key is "non-ASCII" -- try 0xa0 (nbsp) or basically any other high byte you like and you'll get the same error! \$\endgroup\$ – John P Oct 20 '17 at 17:57
  • 3
    \$\begingroup\$ This is 1 byte in Win1252, which the error message shows this is using. \$\endgroup\$ – ATaco Oct 21 '17 at 5:04
10
\$\begingroup\$

><>, 12 10 bytes

"2,:o:2-o|

This will continually print ><> until the interpreter runs out of space.

Try it online!

12 byte version below for those who like a clean output. Recommended by Aaron (no error, 1 output)

":3+:o$1+oo;
\$\endgroup\$
  • \$\begingroup\$ Brilliant solution! \$\endgroup\$ – Emigna Jan 25 '17 at 14:14
  • \$\begingroup\$ @Emigna - Thanks, the final version was after a bunch of failed golfs but I quite like it because with the error it prints ><> and fish :D \$\endgroup\$ – Teal pelican Jan 25 '17 at 15:32
  • \$\begingroup\$ Nice one ! Here's a 14 bytes version which only prints once and doesn't errors out : "-o-o-o;_!\ _! \$\endgroup\$ – Aaron Jan 25 '17 at 16:37
  • \$\begingroup\$ @Aaron if you check the edit the first version did that at 12. I do like how clean yours looks though :) \$\endgroup\$ – Teal pelican Jan 26 '17 at 17:28
  • \$\begingroup\$ I like your 12 bytes version (the 10 bytes too :)), I think you should have left it included to your answer as an aside ("for those who like a clean output,[...]") ! \$\endgroup\$ – Aaron Jan 26 '17 at 17:32
9
\$\begingroup\$

JAVA, 1 byte

1

The output to stderr is:

Main.java:1: error: class, interface, or enum expected
1
^
1 error
Error: Could not find or load main class Main
Command exited with non-zero status 1
    Command being timed: "/srv/wrappers/java-openjdk"
    User time (seconds): 1.40
    System time (seconds): 0.80
    Percent of CPU this job got: 40%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:05.40
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 44564
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 205
    Minor (reclaiming a frame) page faults: 11301
    Voluntary context switches: 2666
    Involuntary context switches: 1677
    Swaps: 0
    File system inputs: 78312
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 1 
\$\endgroup\$
  • 15
    \$\begingroup\$ This is output from compilation, rather than running the program. I don't know whether this is allowed by default. \$\endgroup\$ – CAD97 Jan 25 '17 at 6:16
  • 2
    \$\begingroup\$ Also, if you chose a different file extension, it wouldn’t output "java" would it? (Not sure if that’s possible with java) \$\endgroup\$ – Jonas Schäfer Jan 25 '17 at 7:41
  • 11
    \$\begingroup\$ if you change from java to java bytecode you could reduce by one character. trying to run empty class file will throw java.lang.ClassFormatError \$\endgroup\$ – user902383 Jan 25 '17 at 9:59
  • 2
    \$\begingroup\$ Programs outputting to stderr should be edited into this answer. \$\endgroup\$ – mbomb007 Jan 25 '17 at 14:47
8
\$\begingroup\$

CSS, 25 bytes

:after{content:'\43\53\53

Note that extra markup is added to Stack Overflow snippets, causing "CSS" to be displayed more than once. Open an .html file with contents

<style>:after{content:'\43\53\53

to see the result as intended.

\$\endgroup\$
8
\$\begingroup\$

C, 15 Bytes

Compiled C on a Linux machine with a German locale:

main(){main();}

It will run to a stack overflow and print Speicherzugriffsfehler (german for Segmentation fault) on stderr.

\$\endgroup\$
  • \$\begingroup\$ ............ :-D \$\endgroup\$ – Alfe Oct 14 at 13:12
7
\$\begingroup\$

bash CLI, 9

printf $0

If you want an actual script and not just a command at the interactive command line, then you can do this:

bash, 13

printf $SHELL

Outputs /bin/bash

\$\endgroup\$
  • 1
    \$\begingroup\$ echo $0 should work \$\endgroup\$ – squeamish ossifrage Jan 25 '17 at 1:41
  • \$\begingroup\$ @squeamishossifrage That works at the shell command line, but in a script it will output the name of the script. \$\endgroup\$ – Digital Trauma Jan 25 '17 at 7:08
  • 1
    \$\begingroup\$ x $0 works, assuming there's no executable called x on the path. In which case substitute any other letter, digit, or non-special character. \$\endgroup\$ – nigel222 Jan 25 '17 at 11:08
  • 2
    \$\begingroup\$ 'h' is illigal character for you, and you are using it in echo \$\endgroup\$ – user902383 Jan 25 '17 at 11:38
  • 2
    \$\begingroup\$ $'ec\x68o' $0 cures that detail. \$\endgroup\$ – manatwork Jan 25 '17 at 12:02
6
\$\begingroup\$

dc, 6

25699P

Outputs dc.

Try it online.

\$\endgroup\$
6
\$\begingroup\$

Pip, 8 bytes

'IWR C80

Takes the character I and WRaps it in Chr(80), resulting in PIP. Try it online!

Using the I feels a bit like cheating, so here are two 9-byte solutions that don't use any of PpIi:

z@8WRz@15
(z8+^707)

Both output pip. I'm particularly pleased with the second one:

    ^707   Split 707 into a list of characters        [7;0;7]
  8+       Add 8 to each one                          [15;8;15]
(z      )  Use list to index into lowercase alphabet  ["p";"i";"p"]
           By default, lists are printed without a separator

For proper capitalization, we need a 10-byte solution:

'IWR C80Vx

How this one works is left as an exercise for the reader. ;^)

\$\endgroup\$
6
\$\begingroup\$

C#, 60 67 bytes

class P{static void Main(){System.\u0043onsole.Write("\x43\x23");}}
\$\endgroup\$
  • \$\begingroup\$ Is this actually your answer, or did a bug messed up your answer? \$\endgroup\$ – auhmaan Jan 25 '17 at 14:18
  • \$\begingroup\$ @auhmaan Sorry, fixed. I initially tested on LINQPad, and forgot it has a few default namespace imports. \$\endgroup\$ – Bob Jan 25 '17 at 14:40
  • \$\begingroup\$ I was referring to the \u0043 and alikes \$\endgroup\$ – auhmaan Jan 25 '17 at 16:16
  • 1
    \$\begingroup\$ @auhmaan That's intentional because I need Console but can't use C as per question rules. In C# you can use Unicode escape sequences in identifiers. \$\endgroup\$ – Bob Jan 25 '17 at 16:36
  • 3
    \$\begingroup\$ I'm sure you can use an anonymous method for this, I can't see a restriction requiring a full program, so you could do _=>System.\u0043onsole.Write("\x43\x23"); \$\endgroup\$ – TheLethalCoder Jan 26 '17 at 16:29
6
\$\begingroup\$

brainfuck, 105 Bytes

--[----->+<]>----.[--->+<]>----.+++[->+++<]>++.++++++++.+++++.--------.-[--->+<]>--.+[->+++<]>+.++++++++.

Try it online here

\$\endgroup\$
  • 7
    \$\begingroup\$ Well, not a problem in BrainFuck ;) \$\endgroup\$ – devRicher Jan 25 '17 at 7:24
  • \$\begingroup\$ @devRicher not at all ;) \$\endgroup\$ – TrojanByAccident Jan 25 '17 at 7:29
  • \$\begingroup\$ @mbomb007 I see. \$\endgroup\$ – TrojanByAccident Jan 25 '17 at 20:31
  • \$\begingroup\$ @mbomb007 updated \$\endgroup\$ – TrojanByAccident Jan 25 '17 at 20:52
  • \$\begingroup\$ Is there any reason for the excessive --- in your markdown? \$\endgroup\$ – FlipTack Jan 25 '17 at 20:54
5
\$\begingroup\$

R, 11 bytes

cat("\x52")

Try it online!

\$\endgroup\$
  • \$\begingroup\$ version$l 9 bytes \$\endgroup\$ – djhurio Jan 25 '17 at 13:37
  • 2
    \$\begingroup\$ Probably version is enough (7 bytes) \$\endgroup\$ – djhurio Jan 25 '17 at 13:39
  • 1
    \$\begingroup\$ Or just 'r'. 3 bytes. \$\endgroup\$ – Konrad Rudolph Jan 25 '17 at 18:25
  • \$\begingroup\$ @KonradRudolph You can't use... wait; the specs are case sensitive in checking but not output... Clever. \$\endgroup\$ – wizzwizz4 Jan 25 '17 at 18:42
  • \$\begingroup\$ @wizzwizz4 Yeah … but I’ve since posted a solution that only needs one character, and even gets the case right. \$\endgroup\$ – Konrad Rudolph Jan 25 '17 at 18:50
5
\$\begingroup\$

Forth, 5 bytes

WORDS

Try it online

Prints a list of every word in the language. Forth happens to be in the list (first word on line 125), though I don't know what it does.

\$\endgroup\$
5
\$\begingroup\$

Hexagony, 19 bytes

Basically a direct linear flow wrapped inside the hexagon.

h;E;N;Y;X;A;;@/OG;/

Try this 19 byte un-interesting solution online!

More interesting 28 bytes:

I]f.@]z;.(;[.$>]z(]b]\(]p]h<

Try it online!

This uses the small h, which is allowed. Uses the IP1 (Initial is 0) as a "function" which does "Decrement and print as char".

Expanded view

   I ] f .
  @ ] z ; .
 ( ; [ . $ >
] z ( ] b ] \
 ( ] p ] h <
  . . . . .
   . . . .

Saves I in the memory, go to the next instruction pointer with ], then IP1 runs from NE corner in SE direction and hits ..> which directs to E, wrapped to the bottom 5 no-ops . and then to ( (decrement), ; (print as char) and then [ which returns to IP0.

IP0 starts reading from where it stopped to f, go through the no-op . and to the middle ] which runs the "function" again: IP1 starts from where it stopped and hits no-op . then $ which skips the > and runs through the bottom again... to print e.

The program keeps doing things like that. Found out that I could've just printed n by calling the function again after printing o. Mm.. can't think of ways to shorten this further though I replace 1 byte by no-op with this discovery.

Leave me a comment if you want to see diagrams in this explanation!

\$\endgroup\$
5
\$\begingroup\$

J, 2 bytes

   a.


┌┬┐├┼┤└┴┘│─ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~��������������������������������������������������������������������������������������������������������������������������������

a. returns the alphabet of the J language — a built-in list of all bytes.

My original: 4 bytes

   %:_1
0j1

This just seems pretty cool to me. The square root (%:) of negative 1 (_1) is i (0j1).

\$\endgroup\$
  • 1
    \$\begingroup\$ 2 Bytes: a.. Prints the alphabet, which obviously includes 'J'. Definetly not as cool though :/ \$\endgroup\$ – Bolce Bussiere Mar 26 '18 at 16:47
  • \$\begingroup\$ Gotta golf it. :-) That said, I am attached to my original answer. \$\endgroup\$ – Dane Mar 28 '18 at 17:47
5
\$\begingroup\$

BASIC (ZX Spectrum), 4 2 bytes

crossed out 4 is still regular 4

Saved 2 bytes thanks to @ShaunBebbers.

Note: In the ZX Spectrum character set, these bytes display as

0 PRINT

When you enter this in, the Spectrum starts by parsing an optional number followed by a line of code. Normally the line number is 1..9999 which causes the code to be added to the stored program. However if no line number is supplied then the code is executed immediately instead. Unfortunately a bug in the Spectrum means that it mistakes a line number of zero for no line number at all, but it still tries to execute the zero as part of the line of code, which is illegal, thus causing the error.

The previous 4-byte version generates a true error rather than relying on an interpreter bug:

õ°""

Note: In the ZX Spectrum character set, these bytes display as

PRINT VAL ""

which outputs

C Nonsense in BASIC, 0:1

because the empty string is not a valid numeric expression. (I could of course have used any statement that takes a single integer.) If this answer is unacceptable, then for 6 bytes you can write a program consisting of a single line with one of the keywords that accepts no arguments, then use POKE to replace it with an illegal keyword, then attempt to RUN the program.

\$\endgroup\$
  • \$\begingroup\$ or 0 REM produces the same error \$\endgroup\$ – Shaun Bebbers Aug 13 at 15:52
  • 1
    \$\begingroup\$ @ShaunBebbers Does that even pass syntax checking? \$\endgroup\$ – Neil Aug 13 at 19:13
  • \$\begingroup\$ yes it does on a real Spectrum. \$\endgroup\$ – Shaun Bebbers Aug 13 at 20:36
4
\$\begingroup\$

C 24 20 Bytes (Clang 3.8.1)

Thanks to @squeamish ossifrage for helping me save 4 bytes.

main(){putchar(67);}
\$\endgroup\$
  • \$\begingroup\$ How about putchar(67);? \$\endgroup\$ – squeamish ossifrage Jan 25 '17 at 1:36
  • \$\begingroup\$ @squeamishossifrage yep, thanks \$\endgroup\$ – Wade Tyler Jan 25 '17 at 1:40
  • \$\begingroup\$ Just curious, but wouldn't printf('c') also be valid? You're not allowed to use uppercase "C", but you are lowercase, and the result is case-insensitive. \$\endgroup\$ – Jocie Jan 25 '17 at 9:51
  • 1
    \$\begingroup\$ @Jocie printf needs a char * so I need to use "" \$\endgroup\$ – Wade Tyler Jan 25 '17 at 12:30
  • 1
    \$\begingroup\$ if result is not case sensitive, then puts("c") saves a few bytes, and does not use uppercase C... Rules might need an edit then \$\endgroup\$ – Florian Castellane Jan 26 '17 at 15:16
4
\$\begingroup\$

Vim, 3 bytes

:h<CR>

Try it online!

This opens up the default help file and outputs:

*help.txt*  For Vim version 7.4.  Last change: 2016 Mar 31

                        VIM - main help file
                                                                         k
      Move around:  Use the cursor keys, or "h" to go left,        h   l
                    "j" to go down, "k" to go up, "l" to go right.   j
Close this window:  Use ":q<Enter>".
   Get out of Vim:  Use ":qa!<Enter>" (careful, all changes are lost!).

Jump to a subject:  Position the cursor on a tag (e.g. |bars|) and hit CTRL-].
   With the mouse:  Double-click the left mouse button on a tag, e.g. |bars|.
        Jump back:  Type CTRL-T or CTRL-O.  Repeat to go further back.

Get specific help:  It is possible to go directly to whatever you want help
                    on, by giving an argument to the |:help| command.
                    Prepend something to specify the context:  *help-context*

                          WHAT          PREPEND    EXAMPLE  ~
                      Normal mode command          :help x
                      Visual mode command     v_       :help v_u
                      Insert mode command     i_       :help i_<Esc>
                      Command-line command    :    :help :quit
                      Command-line editing    c_       :help c_<Del>
                      Vim command argument    -    :help -r
                      Option              '    :help 'textwidth'
                      Regular expression      /    :help /[
                    See |help-summary| for more contexts and an explanation.

  Search for help:  Type ":help word", then hit CTRL-D to see matching
                    help entries for "word".
                    Or use ":helpgrep word". |:helpgrep|

VIM stands for Vi IMproved.  Most of VIM was made by Bram Moolenaar, but only
through the help of many others.  See |credits|.
------------------------------------------------------------------------------
                                                *doc-file-list* *Q_ct*
BASIC:
|quickref|  Overview of the most common commands you will use
|tutor|     30 minutes training course for beginners
|copying|   About copyrights
|iccf|      Helping poor children in Uganda
|sponsor|   Sponsor Vim development, become a registered Vim user
|www|       Vim on the World Wide Web
|bugs|      Where to send bug reports

USER MANUAL: These files explain how to accomplish an editing task.

|usr_toc.txt|   Table Of Contents

Getting Started ~
|usr_01.txt|  About the manuals
|usr_02.txt|  The first steps in Vim
|usr_03.txt|  Moving around
|usr_04.txt|  Making small changes
|usr_05.txt|  Set your settings
|usr_06.txt|  Using syntax highlighting
|usr_07.txt|  Editing more than one file
|usr_08.txt|  Splitting windows
|usr_09.txt|  Using the GUI
|usr_10.txt|  Making big changes
|usr_11.txt|  Recovering from a crash
|usr_12.txt|  Clever tricks

Editing Effectively ~
|usr_20.txt|  Typing command-line commands quickly
|usr_21.txt|  Go away and come back
|usr_22.txt|  Finding the file to edit
|usr_23.txt|  Editing other files
|usr_24.txt|  Inserting quickly
|usr_25.txt|  Editing formatted text
|usr_26.txt|  Repeating
|usr_27.txt|  Search commands and patterns
|usr_28.txt|  Folding
|usr_29.txt|  Moving through programs
|usr_30.txt|  Editing programs
|usr_31.txt|  Exploiting the GUI
|usr_32.txt|  The undo tree

Tuning Vim ~
|usr_40.txt|  Make new commands
|usr_41.txt|  Write a Vim script
|usr_42.txt|  Add new menus
|usr_43.txt|  Using filetypes
|usr_44.txt|  Your own syntax highlighted
|usr_45.txt|  Select your language


REFERENCE MANUAL: These files explain every detail of Vim.  *reference_toc*

General subjects ~
|intro.txt| general introduction to Vim; notation used in help files
|help.txt|  overview and quick reference (this file)
|helphelp.txt|  about using the help files
|index.txt| alphabetical index of all commands
|help-tags| all the tags you can jump to (index of tags)
|howto.txt| how to do the most common editing tasks
|tips.txt|  various tips on using Vim
|message.txt|   (error) messages and explanations
|quotes.txt|    remarks from users of Vim
|develop.txt|   development of Vim
|debug.txt| debugging Vim itself
|uganda.txt|    Vim distribution conditions and what to do with your money

Basic editing ~
|starting.txt|  starting Vim, Vim command arguments, initialisation
|editing.txt|   editing and writing files
|motion.txt|    commands for moving around
|scroll.txt|    scrolling the text in the window
|insert.txt|    Insert and Replace mode
|change.txt|    deleting and replacing text
|indent.txt|    automatic indenting for C and other languages
|undo.txt|  Undo and Redo
|repeat.txt|    repeating commands, Vim scripts and debugging
|visual.txt|    using the Visual mode (selecting a text area)
|various.txt|   various remaining commands
|recover.txt|   recovering from a crash

Advanced editing ~
|cmdline.txt|   Command-line editing
|options.txt|   description of all options
|pattern.txt|   regexp patterns and search commands
|map.txt|   key mapping and abbreviations
|tagsrch.txt|   tags and special searches
|quickfix.txt|  commands for a quick edit-compile-fix cycle
|windows.txt|   commands for using multiple windows and buffers
|tabpage.txt|   commands for using multiple tab pages
|syntax.txt|    syntax highlighting
|spell.txt| spell checking
|diff.txt|  working with two to four versions of the same file
|autocmd.txt|   automatically executing commands on an event
|filetype.txt|  settings done specifically for a type of file
|eval.txt|  expression evaluation, conditional commands
|fold.txt|  hide (fold) ranges of lines

Special issues ~
|print.txt| printing
|remote.txt|    using Vim as a server or client
|term.txt|  using different terminals and mice
|digraph.txt|   list of available digraphs
|mbyte.txt| multi-byte text support
|mlang.txt| non-English language support
|arabic.txt|    Arabic language support and editing
|farsi.txt| Farsi (Persian) editing
|hebrew.txt|    Hebrew language support and editing
|russian.txt|   Russian language support and editing
|ft_ada.txt|    Ada (the programming language) support
|ft_sql.txt|    about the SQL filetype plugin
|rileft.txt|    right-to-left editing mode

GUI ~
|gui.txt|   Graphical User Interface (GUI)
|gui_w32.txt|   Win32 GUI

Interfaces ~
|if_cscop.txt|  using Cscope with Vim
|if_pyth.txt|   Python interface
|if_ruby.txt|   Ruby interface
|debugger.txt|  Interface with a debugger
|sign.txt|  debugging signs

Versions ~
|vim_diff.txt|  Main differences between Nvim and Vim
|vi_diff.txt|   Main differences between Vim and Vi
                                                *sys-file-list*
Remarks about specific systems ~
|os_win32.txt|  MS-Windows
                                                *standard-plugin-list*
Standard plugins ~
|pi_gzip.txt|      Reading and writing compressed files
|pi_netrw.txt|     Reading and writing files over a network
|pi_paren.txt|     Highlight matching parens
|pi_tar.txt|       Tar file explorer
|pi_vimball.txt|   Create a self-installing Vim script
|pi_zip.txt|       Zip archive explorer

LOCAL ADDITIONS:                *local-additions*

------------------------------------------------------------------------------
*bars*      Bars example

Now that you've jumped here with CTRL-] or a double mouse click, you can use
CTRL-T, CTRL-O, g<RightMouse>, or <C-RightMouse> to go back to where you were.

Note that tags are within | characters, but when highlighting is enabled these
characters are hidden.  That makes it easier to read a command.

Anyway, you can use CTRL-] on any word, also when it is not within |, and Vim
will try to find help for it.  Especially for options in single quotes, e.g.
'hlsearch'.

------------------------------------------------------------------------------
 vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.