46
\$\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\$
  • 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\$ – 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
  • 90
    \$\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

136 Answers 136

2
\$\begingroup\$

UPL, 0 bytes



I tried to be funny by finding an unnamed programming language where an empty file produces no output, instead I found this. Trying to compile anything with the Unnamed Programming Language compiler results in:

This is going to be the UPL compiler...
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

KoopaScript, 0 bytes (non-competing?)

When opening the online interpreter, this is printed to STDout:

KS_Main_(version) installed
Loading script ksscripts/init.kss...
Command executed: "ldsr,ksscripts/init"
Executing command 0: set KoopaShell.input._visible %btrue...

because it loads an init script by default. The user doesn't input this, it's literally the interpreter. However, because a program is running, I don't feel that it counts.

Though, KoopaScript is shortened to KS by me for basically everything, so the 'KS' printed right at the start no matter whether the init script is loaded is technically the language name...

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Noncompeting isn't necessary. :) \$\endgroup\$ – moonheart08 Mar 27 '18 at 13:12
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`

| improve this answer | |
\$\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.

| improve this answer | |
\$\endgroup\$
  • \$\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\$ – Kevin Cruijssen Aug 12 '19 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 Aug 12 '19 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.

| improve this answer | |
\$\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

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ NB: csh and tcsh don't do this STDERR trick.. \$\endgroup\$ – roblogic Aug 12 '19 at 4:58
  • 1
    \$\begingroup\$ You can't use echo, "h" is in zsh. <<<$'\x7a\x73\x68' works for -1 byte though. \$\endgroup\$ – GammaFunction Aug 13 '19 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\$ – GammaFunction Oct 2 '19 at 18:29
2
\$\begingroup\$

Go, 0 bytes

Try it online!

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

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

C, 23 bytes (without Error)

This works on little-endian machine. 67 is 0x00000043 and the layout on memory is {0x43,0x00,0x00,0x00} (32bit, little-endian) . This memory block is a valid c string (zero-ending char array). Then, just pass the pointer of this memory block into puts.

main(i){i=67;puts(&i);}

As the restrictions:

  • putchar is not allowed (contains c). Then puts is used.
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

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

find /
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Whitespace, 94 bytes

   
  		 
  		  
   	 		
   			 
   
   				
   	  
   		
  				 

  
   		  	 	
	   	
  
 



Try it online!

ssslssttslssttsslssststtlssstttslssslsssttttlssstsslsssttlssttttsl
                push [0, -2, -4, 11, 14, 0, 15, 4, 3, -14]
lssl            label print
sssttsststl     push 101
tsss            add
tlss            print char
lsll            jmp print
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

05AB1E (legacy), 0 bytes

An amazing trick that I just learned from Kevin Cruijssen.

Try it online!

It outputs contents of info.txt, which of course contains the name 05AB1E.

| improve this answer | |
\$\endgroup\$
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
| improve this answer | |
\$\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
| improve this answer | |
\$\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
| improve this answer | |
\$\endgroup\$
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.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Excel 2010 VBA 113 bytes

I am assuming paragraph spacing is 1 byte. This won't work with earlier versions of Excel. For those who dont have/use Excel, column 14925 is VBA

n = 14925
Do While n > 0
c = ((n - 1) Mod 26)
s = Chr(c + 65) & s
n = (n - c) \ 26
Loop
Debug.Print s

Credit where credit is due.

\$\endgroup\$
  • \$\begingroup\$ Welcome to PPCG! For further reference, you don't need to CW-ify an answer if you didn't make it. Simply linking to the source works. Also, you should probably post the plain VBA answer separately. \$\endgroup\$ – Rɪᴋᴇʀ Jan 25 '17 at 16:13
  • \$\begingroup\$ @EasterlyIrk Ok, I didn't know if it was necessary or not to CW an answer but I wouldn't feel right if I didnt .. the plain VBA answer I will leave, I made that within the first minute of reading the question and found it uninteresting \$\endgroup\$ – Mr.Burns Jan 25 '17 at 16:18
1
\$\begingroup\$

Ruby, 18 16 7 6 bytes

Feels like cheating to be able to use different cases, but OK sure

The language can be case-insensitive??? Wow

-1 byte from @manatwork

p:rUBY
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ As all kind of garbage is accepted around the name: p:rUBY. \$\endgroup\$ – manatwork Jan 25 '17 at 14:54
1
\$\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.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

PowerShell, 2 bytes

gv

Sample output:

Name                           Value
----                           -----
$                              $gv
?                              True
^                              $gv
args                           {}
ChocolateyProfile              C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1
ChocolateyTabSettings          @{AllCommands=False}
ConfirmPreference              High
ConsoleFileName
DebugPreference                SilentlyContinue
Error                          {System.Management.Automation.ParseException: At line:1 char:11...
ErrorActionPreference          Continue
ErrorView                      NormalView
ExecutionContext               System.Management.Automation.EngineIntrinsics
false                          False
FormatEnumerationLimit         4
HOME                           C:\Users\username
Host                           System.Management.Automation.Internal.Host.InternalHost
input                          System.Collections.ArrayList+ArrayListEnumeratorSimple
MaximumAliasCount              4096
MaximumDriveCount              4096
MaximumErrorCount              256
MaximumFunctionCount           4096
MaximumHistoryCount            4096
MaximumVariableCount           4096
MyInvocation                   System.Management.Automation.InvocationInfo
NestedPromptLevel              0
null
OutputEncoding                 System.Text.ASCIIEncoding
PID                            7912
PROFILE                        \\thing\user$\user_folders\username\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
ProgressPreference             Continue
PSBoundParameters              {}
PSCommandPath                  \\thing\user$\user_folders\username\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PSCulture                      en-AU
PSDefaultParameterValues       {}
PSEmailServer
PSHOME                         C:\Windows\System32\WindowsPowerShell\v1.0
PSScriptRoot                   \\thing\user$\user_folders\username\My Documents\WindowsPowerShell
PSSessionApplicationName       wsman
PSSessionConfigurationName     http://schemas.microsoft.com/powershell/Microsoft.PowerShell
PSSessionOption                System.Management.Automation.Remoting.PSSessionOption
PSUICulture                    en-US
PSVersionTable                 {PSVersion, WSManStackVersion, SerializationVersion, CLRVersion...}
PWD                            C:\Windows\system32
ShellId                        Microsoft.PowerShell
StackTrace                        at CallSite.Target(Closure , CallSite , Object )...
true                           True
VerbosePreference              SilentlyContinue
WarningPreference              Continue
WhatIfPreference               False

This is shorthand for the cmdlet Get-Variable, which displays the name and value of all variables in scope. Among these are a few environment variables which are also regular variables, like $PSHOME and $PROFILE which contains paths for powershell to run in, and where to find the script to run for every new session.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

GNU M4, 5 bytes

dnl()

Output:

m4:stdin:1: Warning: excess arguments to builtin `dnl' ignored

GNU M4, 10 bytes, clean output

m`'incr(3)

Output:

m4

GNU M4, 40 bytes, clean output, correct case

translit(ulinzg,a-z,z-a)(%c,77)`'incr(3)

Output:

M4
| improve this answer | |
\$\endgroup\$
1
\$\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
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Hoon, 13 bytes

`@t`0w1.KrSZ8

Hoon has an atom encoding @uw, which is base-64. This simply casts an @uw literal back to a cord (@t), which is the value 'Hoon'

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

PHP, 1 byte

_

This leads to a parse error. Run like this:

php -r '_'
> PHP Parse error:  syntax error, unexpected end of file in Command line code on line 1

Version without resorting to STDERR (8 bytes)

Note: uses IBM-850 encoding

<?=~»À»;

Run like this:

echo '<?=~»À»;' | php 2>/dev/null
> PHP

This just uses the binary opposite of PHP, and negates it using the ~ operator.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

QBIC, 15 6 bytes

The way to do this without errors and with the proper capitalisation costs 15 bytes:

?ucase$(@qbic`)

Since QBIC is in all-caps, this code is allowed: it takes the string literal qbic and prints it in uppercase.

An error-output (which feels kinda cheaty to me) is shorter:

?b(12)

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

There's also this 6-byter that prints QBIC in lowercase:

?@qbic

That string literal doesn't need a closing backtick, it is auto-closed because of EOF.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

dc, 6 bytes

A0P99P

Prints the ASCII values 100 and 99, i.e. dc.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

C++, 84 44 bytes

#import<stdio.h>
main(){puts("\103\53\53");}

Thanks to @Clearer for saving a lot of bytes.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This isn't a valid C++ program. Try this instead: #include<cstdio> int main(){char c[]={67,43,43,0};printf(c);} It's shorter and correct C++. \$\endgroup\$ – Clearer Feb 14 '17 at 1:51
  • \$\begingroup\$ @Clearer Yes, that's what I would have done, but like I said, I wanted to completely avoid using the character c, upper or lower case. As this does compile on the MinGW compiler I'm using, and I don't think there is any undefined behaviour, it is valid at least on one implementation. (Which is enough for code golf) \$\endgroup\$ – Steadybox Feb 14 '17 at 14:46
  • \$\begingroup\$ It's not valid just because it compiles on a particular compiler. You're lacking the return type of your main function, which is the only thing that's a problem -- it is a valid C program though. You can shave off a byte by writing uint8_t l[] =..., instead of uint8_t l[4]=... \$\endgroup\$ – Clearer Feb 15 '17 at 12:24
  • \$\begingroup\$ #include<stdio.h> int main(){puts("\103\53\53");} only has the problem that it depends on being able to print ASCII compatible text. It's just 50 bytes long. If you allow c in the program, you can shave it to 49 and be equal to the Java 8 version but include a newline in the output :-) \$\endgroup\$ – Clearer Feb 15 '17 at 12:43
  • \$\begingroup\$ Thanks for the shorter version. I'm still omitting the return type of main, since that is allowed by certain compilers, and in code golf, languages are defined by their implementation: meta.codegolf.stackexchange.com/questions/7832/… \$\endgroup\$ – Steadybox Feb 20 '17 at 11:56
1
\$\begingroup\$

,,,, 6 5 bytes

44c3×

As short as ","3× and ",,,"!

Explanation

44c3×

44         push 44                        [44]
  c        convert 44 to ASCII character  [',']
   3×      repeat ',' 3 times             [',,,']
           implicit output                []
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

q/kdb+, 6 bytes

Solution:

.Q.x10

Example:

q).Q.x10
@["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"]0x40\:

Explanation:

.Q.x10 returns a function you could use for some base64 encoding, calling without parameters outputs the function body.

Bonus:

22 bytes gets us a purer answer. Here we cast ("c"$) integers (113 47 107 100 98 43) to ASCII chars:

q)"c"$43+70 4 64 57 55 0
"q/kdb+"
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Java 8, 49 41 bytes

Golfed:

n->System.out.println("\112\141\166\141")

Ungolfed, full program:

public class OutputProgrammingLanguageName {

  public static void main(String[] args) {
    f(n->System.out.println("\112\141\166\141"));
  }

  private static void f(java.util.function.IntConsumer f) {
    f.accept(0);
  }
}

This is a simple System.out.println() wrapped in a functional interface to save some bytes, using octal escapes to avoid any of the character literals in "Java". Note that on some JVM implementations, System.out.print() does not necessarily flush output. In that case, the program will try to print but nothing is output before the program ends. Using System.out.println() requires two additional bytes, but guarantees the program actually prints something.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ You can change println to print \$\endgroup\$ – FlipTack Jan 25 '17 at 18:15
  • 1
    \$\begingroup\$ @FlipTack I have had problems in previous challenges with flushing of stdout, where a program will print nothing and exit. I will take the two byte hit to the score for a guarantee that the program will actually output something. \$\endgroup\$ – user18932 Jan 25 '17 at 18:16
  • \$\begingroup\$ print seems to work fine for me, but nvm \$\endgroup\$ – FlipTack Jan 25 '17 at 18:33
  • \$\begingroup\$ Since you're just printing a String you can use octal escapes instead of unicode escapes. Saves 8 bytes. System.out.println("\112\141\166\141"); \$\endgroup\$ – Poke Jun 29 '17 at 21:03
1
\$\begingroup\$

Noether, 15 bytes

"n"UP"OETHER"_P

Try it here!

Explanation:

"n"      - Push the string "n"
U        - Convert the string on top of the stack to uppercase
P        - Print the top of the stack
"OETHER" - Push the string "OETHER"
_        - Convert the string on top of the stack to lowercase
P        - Print the top of the stack
| improve this answer | |
\$\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.