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

2
\$\begingroup\$

><>, 8 bytes

f4*:2+oo

Try it online!

Prints the string >< repeatedly.

\$\endgroup\$
2
\$\begingroup\$

FerNANDo, 79 bytes

3 3
1
2 2
0 3 0 0 0 2 2 1
0 3 2 0 1 3 1 2
0 3 2 2 0 1 2 0
0 3 1 0 3 3 3 1
1 1
1

Try it online!

Based on primo's technique for "Hello, World!". The idea is to loop twice through four printing commands, while using the variables 0, 1, 2, 3 for all possible combinations of the values 0/1:

variable                0  1  2  3
value on 1st iteration  0  0  1  1
value on 2nd iteration  0  1  0  1

With these, we can then encode arbitrary pairs of characters to be printed, which allows us to print four characters in each iteration. I used this CJam script to compute the printing commands (change the 4 to a different value if you want to print a different number of characters per iteration).

I also tried doing 3 iterations, like primo's answer (which would require printing a trailing linefeed), but that ends up being a few bytes longer. It might be possible to save bytes by using 4 iterations, since you need only a few of the possible byte combinations (0 2 4 7 9 12 15, specifically), but I need to take more time to figure out how to compute them efficiently.

\$\endgroup\$
2
\$\begingroup\$

PHP, 2 bytes (0 bytes of code plus 2 bytes for extra command line arguments)

-i

Outputs a ton of stuff, including:

PHP Version => 7.1.1
PHP API => 20160303
PHP Extension => 20160303
PHP Extension Build => API20160303,NTS
PHP License
\$\endgroup\$
2
  • \$\begingroup\$ -i doesn't run a program. Not sure if this is valid \$\endgroup\$
    – aross
    Commented Jan 30, 2017 at 9:38
  • 3
    \$\begingroup\$ <shrug> If actually running a program is a requirement then all the answers which rely on a compile error are not valid as well. :) \$\endgroup\$ Commented Jan 30, 2017 at 15:09
2
\$\begingroup\$

Bash (+ coreutils), 8 3 bytes

env

Try it online!

Output is

  .
  .
  .
SHELL=/bin/bash
  .
  .
  .
\$\endgroup\$
1
  • \$\begingroup\$ Note that on Unix this is your login shell, not the running shell. So bash may not be listed. \$\endgroup\$
    – Jakob
    Commented Mar 25, 2018 at 4:47
2
\$\begingroup\$

Perl 5.10+, 18 bytes

$ perl -E'/.\KIO/~~%::;say$`'
Perl

Requires Perl 5.10 or higher for say, \K, and the smartmatch operator ~~.

Per this meta answer, I'm not counting -E, although there are dissenting opinions.

How it works

The main symbol table %main:: (or %:: for short) always contains an entry for PerlIO:

$ perl -E'say $main::{"PerlIO::"}'
*main::PerlIO::

A symbol table is just a hash; you can search for keys that match a given regex using smartmatch:

$ perl -E'say "match" if /.\KIO/ ~~ %main::'
match

(There's also an entry for IO::, but it doesn't match this regex.)

\K causes the regex engine to "keep" everything matched up to that point and not add it to $&, so you end up with the text "IO" in $& and "Perl" in $`.


On newer versions of Perl, smartmatch will trigger a warning, but the output is still valid:

$ perl -E'/.\KIO/~~%::;say$`'
Smartmatch is experimental at -e line 1.
Perl

Shorter solution for Perl < 5.18

Perl 5.18.0 introduced hash randomization. Before that, functions like keys always returned hash keys and values in the same order from run to run.

On my installation of Perl 5.16.3 on Linux, the entry for PerlIO:: always appears before the entry for IO::, so I can shave off three bytes from the regex:

$ perl5.16.3 -E'/IO/~~%::;say$`'
Perl

I suspect this will work for other installations < 5.18 (I've only checked 5.16.3 and 5.8.8).

\$\endgroup\$
2
  • \$\begingroup\$ say%:: is good enough to meet the specs :) \$\endgroup\$
    – Zaid
    Commented Jan 29, 2017 at 20:45
  • \$\begingroup\$ @Zaid I see you were reading my comments on simbabque's answer :) But what a stupid rule that is...filtering out extra output makes the challenge much more fun. \$\endgroup\$ Commented Jan 30, 2017 at 15:19
2
\$\begingroup\$

Juggle, 34 bytes

Golfed: 3<5=a5<1|a"5<2|1|a"a|7""6<1|a"a|5"

Ungolfed:

3<5=a
5<1|a"
5<2|1|a"
a|7""
6<1|a"
a|5"

Explanation:

Juggle is always read left to right and will never back track. The only arithmetic available is bitwise operations, so I create a base of 3 left-shifted by 5 digits, resulting in a base value of 96. Juggle is also limited to integer literals of 0-9. The rest of it is just pretty much bit math with a as a base, since all the characters start with 11 in the most significant digits. The " outputs that integer as a character with no new line.

Proof of the output, Juggle's on the linked Github.

\$\endgroup\$
2
\$\begingroup\$

Forth (gforth), 4 bytes

COLD

This word prints the following text (version number may vary):

Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
\$\endgroup\$
2
\$\begingroup\$

chicken (not scheme), 1 byte

The language name might also be chicken chicken, see here

a

outputs:

Error on line 1: expected 'chicken'
\$\endgroup\$
1
  • \$\begingroup\$ Downvoter please explain. This seems perfectly valid to me \$\endgroup\$
    – aross
    Commented Jan 30, 2017 at 9:46
2
\$\begingroup\$

Bash, 9 bytes

--verSion

Will output the following:

GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

which has the word in it.

\$\endgroup\$
3
  • \$\begingroup\$ Perhaps I'm missing something, but I only see the word bash in the command itself and not the output. I don't think that counts. \$\endgroup\$ Commented Jan 25, 2017 at 15:46
  • \$\begingroup\$ I'm pretty sure this is valid if you call it a REPL answer. When I run x from the REPL, I get the following output: DJ@DJ-PC:~$ x; bash: x: command not found; DJ@DJ-PC:~$; (Note that the semicolons are newlines) (Also note that I tested it on git-bash) \$\endgroup\$
    – DJMcMayhem
    Commented Feb 15, 2017 at 17:26
  • \$\begingroup\$ changed it completely now, the new version is reproducible \$\endgroup\$
    – Penguin9
    Commented Feb 21, 2017 at 9:54
2
\$\begingroup\$

T-SQL - 58 Bytes

print left(char(84)+char(45)+substring(@@version,11,3),5)

Making use of the casing difference on the highlighted chars.

\$\endgroup\$
2
\$\begingroup\$

Python 2, 44 bytes

exec('pRINt'.upper().swapcase()+' "pYTHON"')

Try it online!

It works by taking a weirdly capitalized string and making it normal, then executing it. I originally solved this by using this method to import sys, but then I realized I could just use it with print.

\$\endgroup\$
1
  • \$\begingroup\$ 38 bytes \$\endgroup\$
    – Jo King
    Commented Mar 25, 2018 at 1:20
2
\$\begingroup\$

Ly, 10 bytes

(76)(89)&o

Pretty easy with Ly, due to the short name and little use of letters.

Outputs:

LY

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ I thought the y was lower case so I cam up with '&2*o'z1-o which is the same length (so no improvement on your answer). In fact I found lots (and lots) of different ways to generate the codepoint for L and y in 4 characters, leading to lots of 10 character options. :) \$\endgroup\$
    – cnamejj
    Commented Jun 11, 2021 at 21:07
  • \$\begingroup\$ This one is fun IMO since it uses two different approaches and it's 8 chars :) 76Jo'z,o \$\endgroup\$
    – cnamejj
    Commented Nov 4, 2021 at 8:10
2
\$\begingroup\$

Julia, 28 bytes

show("\x6A\x75\x6C\x69\x61")

As it turned out, the hardest part wasn't encoding the string (easy enough with escapes and an ASCII table), but finding a function in the standard library to show it. Most of them have one of the letters of ['a', 'i', 'j', 'l', 'u'] in them.

\$\endgroup\$
2
\$\begingroup\$

><>, 9 bytes

"-o_!\ _!

Try it online!

Same byte count, much cleaner output. Now it only outputs ><> and nothing else by subtracting the difference between pairs of no-ops. I was very lucky that > + ! is _ which is a no-op when traveling horizontally.

><>, 9 bytes

"2*4-o! !

Try it online!

How It Works:

Initially the " pushes the source code in reverse. 2*4-o multiplies the value of the final ! by 2 and subtracts 4 to make it correspond to >. The ! skips over the " so no more code is pushed to the stack, and it repeats the operation over the rest of the source code, resulting in an output of ><>ÚVdP`

\$\endgroup\$
2
\$\begingroup\$

MathGolf, 10 bytes

ÿ∙╤Æⁿ½]$╦y

Try it online!

Explanation

ÿ∙╤Æⁿ        Push "∙╤Æⁿ"
     ½       uninterleave, pushing "∙Æ" and "╤ⁿ" to the stack
      ]      wrap stack in array
       $     push ord(a) for each element in the array
        ╦    fetch dictionary words ("Math" and "Golf")
         y   join array without separator to string or number

With dictionary popping using strings, which should be coming in the next version, this will be 1 byte shorter (remove $).

The boring solution (1 byte)

'

From TIO:

Traceback (most recent call last):
  File "/opt/mathgolf/math_golf.py", line 750, in <module>
    result = evaluate(code_list[:], stdin, Stack([]))
  File "/opt/mathgolf/math_golf.py", line 115, in evaluate
    stack.append(code.pop().char)
IndexError: pop from empty list

This is implementation dependent, but if you're planning on using MathGolf, you'll probably pull the git repository, which is named mathgolf, meaning that unless the directory is renamed, the error will persist.

\$\endgroup\$
2
  • \$\begingroup\$ More boring 10 bytes alternative (using MathGolf's strength of implicitly joining and printing the stack) which would be 2 bytes shorter once we can remove the $s. :) \$\endgroup\$ Commented Aug 12, 2019 at 9:42
  • \$\begingroup\$ @KevinCruijssen Haha, of course... didn't even think to test the simpler method. Nice catch. I still have to check how dictionary fetching using strings should work when mapped to lists, but once I have verified that there should be a new version coming to TIO. \$\endgroup\$
    – maxb
    Commented Aug 12, 2019 at 9:47
2
\$\begingroup\$

05AB1E, 7 bytes

•₄)í•hÁ

Try it online.

Explanation:

•₄)í•    # Push compressed integer 5943776
     h   # Convert it to hexadecimal: "5AB1E0"
      Á  # Rotate it once towards the right: "05AB1E"
         # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •₄)í• is 5943776.

\$\endgroup\$
2
\$\begingroup\$

Unix shells (bash, sh, zsh, etc) to STDERR, 1 byte

The shells bash, ksh, sh, zsh all output their name to STDERR when you give them an unknown command, e.g.

1

Examples:

λ bash<<<1
bash: line 1: 1: command not found

λ zsh<<<1
zsh: command not found: 1

λ ksh<<<1
ksh: line 1: 1: not found

λ sh<<<1
sh: line 1: 1: command not found

λ fish<<<1
fish: Unknown command 1

If the challenge requires output to STDOUT, add 5 bytes 2>&1 to redirect it:

λ bash<<<1 2>&1
bash: line 1: 1: command not found

If the challenge had specified "use a valid program"... zsh, 18 bytes

<<<$'\x7a\x73\x68'
  • try it online

  • not like this! echo "\x7a\x73\x68", as Gamma pointed out

\$\endgroup\$
3
  • \$\begingroup\$ NB: csh and tcsh don't do this STDERR trick.. \$\endgroup\$
    – roblogic
    Commented Aug 12, 2019 at 4:58
  • 1
    \$\begingroup\$ You can't use echo, "h" is in zsh. <<<$'\x7a\x73\x68' works for -1 byte though. \$\endgroup\$ Commented Aug 13, 2019 at 3:27
  • 1
    \$\begingroup\$ The challenge popped up again on active, so hi again. zsh and bash can use $'\x73'et for stdout. \$\endgroup\$ Commented Oct 2, 2019 at 18:29
2
\$\begingroup\$

Go, 0 bytes

Try it online!

Output: package main: code.go:1:1: expected 'package', found 'EOF'

\$\endgroup\$
2
\$\begingroup\$

Linux, Unix Shell (sh/bash...) (6 bytes)

find /
\$\endgroup\$
2
\$\begingroup\$

Pxem, (See below)

Depends on invokation

pxemi.7z, 0 bytes (on invokation).

Compile the source code in C++ and run the interpreter with no arguments, like this: /path/to/pxemi. The following line is output to stderr: usage: pxemi pxemFileName.

RPxem, 0 bytes (on invokation)

Just like nk.'s pxemi, run with no arguments: Usage: rpxem path-to-pxem-file.pxe can be seen.

Programs

Pxem, 6 bytes of filename only, case-insensitive, boring.

  • Filename: pXEM.p.
  • Content: none.

Pxem, 18 bytes of filename only, case-sensitive output, depends on ASCII-compatible filesystem.

  • Filename: @-.+23.+7A.+%+.+.p
  • Content: None
How it works

On every ??.+ each character is generated with sum of two characters' ASCII code from backwards.

\$\endgroup\$
1
  • \$\begingroup\$ Pxem is interesting. \$\endgroup\$
    – PkmnQ
    Commented Mar 19, 2021 at 10:09
2
\$\begingroup\$

Pyth, 1 byte

.

Try it here!

On the online interpreter, prints the following to stderr:

Traceback (most recent call last):
  File "pyth.py", line 737, in <module>
    py_code_line = general_parse(pyth_code, safe_mode_on)
  File "pyth.py", line 46, in general_parse
parsed, tokens = parse(tokens, safe_mode)
  File "pyth.py", line 74, in parse
    raise PythParseError(active_token, rest_tokens)
extra_parse.PythParseError: . is not implemented, 1 from the end.

The exact error message differs depending on the environment Pyth is running in, but it always includes PythParseError.

\$\endgroup\$
2
\$\begingroup\$

Red, 9 bytes

prin 'rED

Due to the rules, this is valid, but it's boring, so let's not do that, ok?


Non-trivial, 35 bytes

prin#"Q"+ 1 prin#"f"- 1 prin#"c"+ 1

This takes Q, f, and c as character codes, adds or subtracts 1, then prints them without newlines. Q + 1 = R, f - 1 = e, c + 1 = d. Unfortunately, this doesn't work on TIO, but you can try it locally.

\$\endgroup\$
2
\$\begingroup\$

Pyth, 5 Bytes

"pYTH

Simple prints the string pYTH to stdout.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is 5 bytes, " p Y T H \$\endgroup\$ Commented Nov 13, 2020 at 3:46
2
\$\begingroup\$

K (ngn/k), 5 bytes

`c$75

Try it online!

There seems to be no rules for inplementation-specific programming languages, so I will assume the name of the implementation doesn't need to be included.

\$\endgroup\$
1
  • \$\begingroup\$ This is likely quite unstable, but another 5-byter is 1?"A" \$\endgroup\$
    – coltim
    Commented Feb 17, 2023 at 15:45
2
\$\begingroup\$

APPLESOFT BASIC, 87 bytes / 62 tokenized bytes

0x$="":goto1to==^atint>notabscolor=fntoint-spc(pr#
1pokepeek(131)+peek(132)*256,19:?x$

Enter the program in lower-case. The output printed:

 ":+1APPLESOFT BASIC
\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 29 45 bytes

There's probably a better way.

let f =

_=>'\x4A\x61\x76\x61\x53\x63\x72\x69\x70\x74'

console.log(f())

\$\endgroup\$
6
  • \$\begingroup\$ @ETHproductions This turns out to be more complicated than I expected. Here is a fixed (but weak) version. \$\endgroup\$
    – Arnauld
    Commented Jan 25, 2017 at 0:27
  • \$\begingroup\$ Huh, none of the hex values contain a letter, except for J. Perhaps that could be useful in some way (though I highly doubt it...) \$\endgroup\$ Commented Jan 25, 2017 at 0:30
  • \$\begingroup\$ Abuse case-insensitive requirements for output to print jAVAsCRIPT? \$\endgroup\$
    – Value Ink
    Commented Jan 25, 2017 at 0:48
  • \$\begingroup\$ @ValueInk I supposed I could do that but I actually wish this rule didn't exist. It kinda ruins the game. \$\endgroup\$
    – Arnauld
    Commented Jan 25, 2017 at 1:03
  • 2
    \$\begingroup\$ How about just _=>'\x45\x53'+(5+1)? It is technically ECMAScript6 \$\endgroup\$
    – Flambino
    Commented Jan 25, 2017 at 1:20
1
\$\begingroup\$

CJam, 8 6 bytes

"cjAM"

Try it online!

Old version

"BI`l":)

Try it online!

"BI`l"    e# Push this string
:)        e# Add 1 to the code point of each char. Implicitly display
\$\endgroup\$
1
\$\begingroup\$

QC 16 bytes

&000051430A0D00#

&0000 Write hex to memory at address 00 until 000 is reached
51430A0D00 QC with a new line and the terminator at the end
# Print contents of memory until first 00 is reached
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 11 bytes

¾4>'§ÅX69çJ

Try it online!

Explanation

¾              # push counter (initially 0)
 4>            # push 4+1
   '§Å         # push the word "ab"
      X        # push variable X (initially 1)
       69ç     # push char value of 69: "E"
          J    # join as string
\$\endgroup\$
1
  • \$\begingroup\$ •äƵí•hR works for 7. \$\endgroup\$
    – Makonede
    Commented Mar 19, 2021 at 15:50
1
\$\begingroup\$

Chicken, 1 byte

g

This could be pretty much any character and it would be the same.

Outputs Error on line 1: expected 'chicken'.

Try it here.

\$\endgroup\$

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.