57
\$\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\$
15
  • 8
    \$\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\$ Commented Jan 24, 2017 at 23:47
  • 9
    \$\begingroup\$ Obligatory "Just having your code be blank but have a flag like --version isn't allowed"? \$\endgroup\$
    – Value Ink
    Commented Jan 25, 2017 at 0:00
  • 106
    \$\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
    Commented Jan 25, 2017 at 0:47
  • 20
    \$\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
    Commented Jan 26, 2017 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
    Commented Jan 26, 2017 at 18:30

169 Answers 169

1
2 3 4 5 6
88
\$\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 

Rust, 0 bytes


Error:

error[E0601]: `main` function not found in crate `code`
  |
  = note: consider adding a `main` function to `code.tio`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.

sed, 1 byte

A

Error:

sed: file /ATO/code line 1: unknown command: `A'

flat assembler, 0 byte

Error:

flat assembler  version 1.73.16  (16384 kilobytes memory, x64)
1 passes, 0 bytes.

GolfScript, 1 byte

\

Error:

/opt/golfscript/golfscript.rb:118:in `block in to_gs': undefined method `to_gs' for nil:NilClass (NoMethodError)
    from /opt/golfscript/golfscript.rb:118:in `each'
    from /opt/golfscript/golfscript.rb:118:in `inject'
    from /opt/golfscript/golfscript.rb:118:in `to_gs'
    from (eval):1:in `block in initialize'
    from /opt/golfscript/golfscript.rb:306:in `go'
    from (eval):1:in `block in initialize'
    from /opt/golfscript/golfscript.rb:306:in `go'
    from (eval):1:in `block in initialize'
    from /opt/golfscript/golfscript.rb:306:in `go'
    from /opt/golfscript/golfscript.rb:500:in `<main>'

Thunno, 0 bytes


Error (for Thunno v1.2.1):

Thunno, v1.2.1

Vyxal, 2 bytes

λx

Error:

Traceback (most recent call last):
  File "/usr/local/bin/vyxal", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/site-packages/vyxal/main.py", line 470, in cli
    execute_vyxal(file_name, flags, inputs)
  File "/usr/local/lib/python3.10/site-packages/vyxal/main.py", line 430, in execute_vyxal
    vy_print(output, ctx=ctx)
  File "/usr/local/lib/python3.10/site-packages/vyxal/elements.py", line 7253, in vy_print
    res = safe_apply(lhs, *args, ctx=ctx, arity_override=override)
  File "/usr/local/lib/python3.10/site-packages/vyxal/helpers.py", line 983, in safe_apply
    ret = function(
  File "<string>", line 10, in _lambda_36f6fb46b5889e1e4e91c1f138c09b37
  File "<string>", line 10, in _lambda_36f6fb46b5889e1e4e91c1f138c09b37
  File "<string>", line 10, in _lambda_36f6fb46b5889e1e4e91c1f138c09b37
  [Previous line repeated 982 more times]
  File "<string>", line 8, in _lambda_36f6fb46b5889e1e4e91c1f138c09b37
  File "/usr/local/lib/python3.10/site-packages/vyxal/LazyList.py", line 184, in __len__
    next(self)
  File "/usr/local/lib/python3.10/site-packages/vyxal/LazyList.py", line 198, in __next__
    item = vyxalify(next(self.raw_object))
  File "/usr/local/lib/python3.10/site-packages/vyxal/helpers.py", line 1488, in vyxalify
    return sympy.nsimplify(value, rational=True)
  File "/usr/local/lib/python3.10/site-packages/sympy/simplify/simplify.py", line 1436, in nsimplify
    return sympify(as_int(expr))
  File "/usr/local/lib/python3.10/site-packages/sympy/core/sympify.py", line 383, in sympify
    return conv(a)
  File "/usr/local/lib/python3.10/site-packages/sympy/core/cache.py", line 72, in wrapper
    retval = cfunc(*args, **kwargs)
RecursionError: maximum recursion depth exceeded in comparison
\$\endgroup\$
8
  • 22
    \$\begingroup\$ Isn't the empty string contained in the language's name? :D \$\endgroup\$
    – mbomb007
    Commented Jan 25, 2017 at 15:08
  • 27
    \$\begingroup\$ The C and R ones are clever. \$\endgroup\$
    – DLosc
    Commented Jan 26, 2017 at 7:10
  • 3
    \$\begingroup\$ @mbomb007 but it's not a character, therefore it's not a character included in the language's name. \$\endgroup\$ Commented Jan 27, 2017 at 4:26
  • 2
    \$\begingroup\$ C can be 0 bytes, since if theres nothing it will complain that theres no main \$\endgroup\$ Commented Feb 5, 2017 at 12:48
  • 26
    \$\begingroup\$ "Java bytecode, 0 bytes". First time I see Java triumphing above ALL of those other languages mentioned. :) \$\endgroup\$ Commented Jul 3, 2017 at 11:26
54
\$\begingroup\$

SmileBASIC, 11 bytes

sPsET.,1474

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

Screenshot

\$\endgroup\$
45
\$\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\$
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\$
4
  • 7
    \$\begingroup\$ Should you merge with this? \$\endgroup\$
    – wizzwizz4
    Commented Jan 25, 2017 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
    Commented Jan 25, 2017 at 19:47
  • 1
    \$\begingroup\$ yeah but Y tho? \$\endgroup\$
    – sagiksp
    Commented Jan 26, 2017 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
    Commented Jan 26, 2017 at 10:55
32
\$\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\$
9
  • 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
    Commented Jan 25, 2017 at 3:26
  • \$\begingroup\$ Why doesn't HTML count? \$\endgroup\$
    – OrangeDog
    Commented Jan 25, 2017 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
    Commented Jan 25, 2017 at 18:39
  • \$\begingroup\$ But html should be valid, reducing the score by 12 bytes. \$\endgroup\$
    – Christoph
    Commented Jan 27, 2017 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
    Commented Feb 15, 2017 at 15:31
29
\$\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\$
6
  • 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
    Commented Jan 25, 2017 at 14:36
  • 4
    \$\begingroup\$ Since when is "vim" a programming language? \$\endgroup\$ Commented Jan 27, 2017 at 3:26
  • 7
    \$\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
    Commented Jan 27, 2017 at 13:32
  • 4
    \$\begingroup\$ @Clearer, several significant languages are not Turing complete by default (e.g., Coq, Agda, and Isabelle) or have non-Turing complete modes of operation (e.g., Idris). It would be very sad if those were excluded! \$\endgroup\$
    – dfeuer
    Commented Aug 12, 2019 at 7:45
  • 8
    \$\begingroup\$ @dfeuer I've come to agree with you, since I made that comment more than 2 years ago. \$\endgroup\$
    – Clearer
    Commented Aug 13, 2019 at 6:57
21
\$\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\$
8
  • \$\begingroup\$ Not sure help counts, it only works in a REPL environment. \$\endgroup\$
    – xnor
    Commented Jan 25, 2017 at 1:09
  • \$\begingroup\$ It still prints out the Python. That's all that's required. \$\endgroup\$
    – user63571
    Commented Jan 25, 2017 at 1:16
  • 1
    \$\begingroup\$ Never mind, I was mistaken and it works as a program. Sorry about that. \$\endgroup\$
    – xnor
    Commented Jan 25, 2017 at 1:22
  • 1
    \$\begingroup\$ you have used the letter 'p' \$\endgroup\$
    – Matt
    Commented Jan 25, 2017 at 15:34
  • 3
    \$\begingroup\$ p is allowed but P isn't. Rule 1. \$\endgroup\$
    – user63571
    Commented Jan 25, 2017 at 17:54
19
\$\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\$
11
  • \$\begingroup\$ where is the name ? Or do you refer to the c characters in there ? \$\endgroup\$ Commented Jan 26, 2017 at 11:46
  • 3
    \$\begingroup\$ This should be marked as C (gcc), because other compilers have different messages. \$\endgroup\$
    – orlp
    Commented Jan 26, 2017 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\$ Commented Jan 27, 2017 at 3:24
  • 1
    \$\begingroup\$ @DepressedDaniel undefined reference to 'main' \$\endgroup\$ Commented Jan 27, 2017 at 5:59
  • \$\begingroup\$ @LorenPechtel Fair enough, missed that. \$\endgroup\$ Commented Jan 27, 2017 at 6:02
19
\$\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\$
1
  • 1
    \$\begingroup\$ Wait, is this language Turing complete? \$\endgroup\$ Commented Nov 18, 2019 at 15:08
17
\$\begingroup\$

C, 15 14 5 Bytes

Compiled C on a Linux machine with a German locale:

main;

It will try to call the variable main which is not allowed because main is stored in the bss section which has the NX bit set, therefore generates a SIGSEGV and prints Speicherzugriffsfehler (german for Segmentation fault) on stderr.

Stolen from https://stackoverflow.com/a/1770717/6082851


Old answer with 14 Bytes

Compiled C on a Linux machine with the C locale on AMD64, compiled with gcc:

main(a){a/=0;}

This will create a division by zero exception and print Floating point exception on stderr. Not sure about other implementation, architectures or compilers since it uses UB.


Old answer with 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\$
1
  • \$\begingroup\$ ............ :-D \$\endgroup\$
    – Alfe
    Commented Oct 14, 2019 at 13:12
14
\$\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\$
14
\$\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\$
13
\$\begingroup\$

Poetic, 229 bytes

why?w-h-y?always a war,many flaws,a sham,a fraud,a sad day
luxury a la shahs,a day a la Buddha?ah,many days usually always a burn
a husband hungry?uh-huh
awful suburbs,always a handful
sadly,a man runs harshly away
hardly unusual

Try it online!

Prints Poetic.

This was an interesting challenge. Not only did I have to write the shortest program that prints Poetic, but I challenged myself to create a somewhat coherent series of sentences without using p, o, e, t, i, or c (in keeping with the spirit of the language). That makes this program a "lipogram".

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

Python 2, 2 bytes, 1 character

è

output...:

output

\$\endgroup\$
5
  • \$\begingroup\$ Are you sure this is only 1 byte? \$\endgroup\$
    – Okx
    Commented Jul 27, 2017 at 22:38
  • 1
    \$\begingroup\$ Agreed. It's 2 bytes in UTF-8 \$\endgroup\$
    – mbomb007
    Commented Oct 20, 2017 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
    Commented Oct 20, 2017 at 17:57
  • 7
    \$\begingroup\$ This is 1 byte in Win1252, which the error message shows this is using. \$\endgroup\$
    – ATaco
    Commented Oct 21, 2017 at 5:04
  • \$\begingroup\$ This requires a file, and files need at least 1 byte of naming, which makes this 2 bytes \$\endgroup\$
    – Joao-3
    Commented Sep 23, 2023 at 14:51
13
\$\begingroup\$

Python, 27 53 49 48 45 31 bytes

-3 bytes from @wizzwizz4

exec'IM\x50ORT THIS'.swapcase()

Attempt This Online!

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\$
7
  • 1
    \$\begingroup\$ @Arnauld fixed! \$\endgroup\$
    – Value Ink
    Commented Jan 25, 2017 at 0:27
  • 1
    \$\begingroup\$ HELP() or HELP(HELP) is shorter. \$\endgroup\$ Commented Jan 25, 2017 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
    Commented Jan 25, 2017 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
    Commented Jan 27, 2017 at 9:20
  • \$\begingroup\$ @ValueInk Alright then. \$\endgroup\$ Commented Jan 27, 2017 at 14:00
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\$
3
  • \$\begingroup\$ Uses a v and an e \$\endgroup\$
    – user63571
    Commented Jan 25, 2017 at 0:31
  • \$\begingroup\$ Your language is Octave, so you can't use v and e. \$\endgroup\$ Commented Jan 25, 2017 at 0:31
  • 6
    \$\begingroup\$ Woops. Corrected by changing language to Matlab (which was my initial intent anyway) \$\endgroup\$
    – Luis Mendo
    Commented Jan 25, 2017 at 0:55
11
\$\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\$
6
  • \$\begingroup\$ Brilliant solution! \$\endgroup\$
    – Emigna
    Commented Jan 25, 2017 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\$ Commented Jan 25, 2017 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
    Commented Jan 25, 2017 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\$ Commented Jan 26, 2017 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
    Commented Jan 26, 2017 at 17:32
10
\$\begingroup\$

C, 1 byte

]

Output:

.code.tio.c:1: error: declaration expected

Try it online!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ What about empty? I get tcc: error: main not defined, which includes the letter c in it. Does that count? \$\endgroup\$ Commented Jul 27, 2020 at 2:58
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\$
4
  • 15
    \$\begingroup\$ This is output from compilation, rather than running the program. I don't know whether this is allowed by default. \$\endgroup\$
    – CAD97
    Commented Jan 25, 2017 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\$ Commented Jan 25, 2017 at 7:41
  • 13
    \$\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
    Commented Jan 25, 2017 at 9:59
  • 2
    \$\begingroup\$ Programs outputting to stderr should be edited into this answer. \$\endgroup\$
    – mbomb007
    Commented Jan 25, 2017 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\$

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\$
2
  • 1
    \$\begingroup\$ 2 Bytes: a.. Prints the alphabet, which obviously includes 'J'. Definetly not as cool though :/ \$\endgroup\$ Commented Mar 26, 2018 at 16:47
  • \$\begingroup\$ Gotta golf it. :-) That said, I am attached to my original answer. \$\endgroup\$
    – Dane
    Commented Mar 28, 2018 at 17:47
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\$
14
  • 1
    \$\begingroup\$ echo $0 should work \$\endgroup\$
    – r3mainer
    Commented Jan 25, 2017 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\$ Commented Jan 25, 2017 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
    Commented Jan 25, 2017 at 11:08
  • 2
    \$\begingroup\$ 'h' is illigal character for you, and you are using it in echo \$\endgroup\$
    – user902383
    Commented Jan 25, 2017 at 11:38
  • 2
    \$\begingroup\$ $'ec\x68o' $0 cures that detail. \$\endgroup\$
    – manatwork
    Commented Jan 25, 2017 at 12:02
7
\$\begingroup\$

brainfuck, 105 Bytes

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

Try it online here

\$\endgroup\$
6
  • 7
    \$\begingroup\$ Well, not a problem in BrainFuck ;) \$\endgroup\$
    – devRicher
    Commented Jan 25, 2017 at 7:24
  • \$\begingroup\$ @devRicher not at all ;) \$\endgroup\$ Commented Jan 25, 2017 at 7:29
  • \$\begingroup\$ @mbomb007 I see. \$\endgroup\$ Commented Jan 25, 2017 at 20:31
  • \$\begingroup\$ @mbomb007 updated \$\endgroup\$ Commented Jan 25, 2017 at 20:52
  • \$\begingroup\$ Is there any reason for the excessive --- in your markdown? \$\endgroup\$
    – FlipTack
    Commented Jan 25, 2017 at 20:54
7
\$\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\$
3
  • \$\begingroup\$ or 0 REM produces the same error \$\endgroup\$ Commented Aug 13, 2019 at 15:52
  • 1
    \$\begingroup\$ @ShaunBebbers Does that even pass syntax checking? \$\endgroup\$
    – Neil
    Commented Aug 13, 2019 at 19:13
  • \$\begingroup\$ yes it does on a real Spectrum. \$\endgroup\$ Commented Aug 13, 2019 at 20:36
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\$
8
  • \$\begingroup\$ Is this actually your answer, or did a bug messed up your answer? \$\endgroup\$
    – auhmaan
    Commented Jan 25, 2017 at 14:18
  • \$\begingroup\$ @auhmaan Sorry, fixed. I initially tested on LINQPad, and forgot it has a few default namespace imports. \$\endgroup\$
    – Bob
    Commented Jan 25, 2017 at 14:40
  • \$\begingroup\$ I was referring to the \u0043 and alikes \$\endgroup\$
    – auhmaan
    Commented Jan 25, 2017 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
    Commented Jan 25, 2017 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\$ Commented Jan 26, 2017 at 16:29
6
\$\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\$
6
\$\begingroup\$

Excel, 35

Closing parens already discounted.

Simple enough:

  • A1 - =RIGHT(0=1) - E from FALSE
  • Output - =A1&ROMAN(90)&A1&ROMAN(50) - EXCEL

ROMAN(90) = XC, ROMAN(50) = L

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Or is it 0 because of the splash screen when you start up Excel? \$\endgroup\$ Commented Jul 25, 2020 at 5:38
5
\$\begingroup\$

R, 11 bytes

cat("\x52")

Try it online!

\$\endgroup\$
9
  • \$\begingroup\$ version$l 9 bytes \$\endgroup\$
    – djhurio
    Commented Jan 25, 2017 at 13:37
  • 2
    \$\begingroup\$ Probably version is enough (7 bytes) \$\endgroup\$
    – djhurio
    Commented Jan 25, 2017 at 13:39
  • 1
    \$\begingroup\$ Or just 'r'. 3 bytes. \$\endgroup\$ Commented Jan 25, 2017 at 18:25
  • \$\begingroup\$ @KonradRudolph You can't use... wait; the specs are case sensitive in checking but not output... Clever. \$\endgroup\$
    – wizzwizz4
    Commented Jan 25, 2017 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\$ Commented Jan 25, 2017 at 18:50
1
2 3 4 5 6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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