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 code-golf thus shortest code wins.
171 Answers 171
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+
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
-
22\$\begingroup\$ Isn't the empty string contained in the language's name? :D \$\endgroup\$mbomb007– mbomb0072017年01月25日 15:08:36 +00:00Commented Jan 25, 2017 at 15:08
-
27\$\begingroup\$ The C and R ones are clever. \$\endgroup\$DLosc– DLosc2017年01月26日 07:10:37 +00:00Commented 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\$Stack Exchange Broke The Law– Stack Exchange Broke The Law2017年01月27日 04:26:01 +00:00Commented Jan 27, 2017 at 4:26
-
3\$\begingroup\$ C can be 0 bytes, since if theres nothing it will complain that theres no main \$\endgroup\$Matthew Roh– Matthew Roh2017年02月05日 12:48:27 +00:00Commented 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\$Kevin Cruijssen– Kevin Cruijssen2017年07月03日 11:26:55 +00:00Commented Jul 3, 2017 at 11:26
SmileBASIC, 11 bytes
sPsET.,1474
Equivalent to SPSET 0,1474
. Sets sprite 0 to definition 1474, which is the SmileBASIC logo.
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".)
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).
-
7
-
\$\begingroup\$ @wizzwizz4 I'm not sure. I asked in chat and got these two replies, so it's not really clear \$\endgroup\$Luis Mendo– Luis Mendo2017年01月25日 19:47:32 +00:00Commented Jan 25, 2017 at 19:47
-
1\$\begingroup\$ yeah but Y tho? \$\endgroup\$sagiksp– sagiksp2017年01月26日 09:34:45 +00:00Commented Jan 26, 2017 at 9:34
-
\$\begingroup\$ @sagiksp Anything that throws an error will do, such as
X
orZ
. This is becauseX
,Y
orZ
are prefixes of two-char function names, so aY
by itself is invalid \$\endgroup\$Luis Mendo– Luis Mendo2017年01月26日 10:55:05 +00:00Commented Jan 26, 2017 at 10:55
HTML, (削除) 24 (削除ここまで) 20 bytes
HTML
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.
HTML
HTML, 4 bytes
And of course, the uninteresting answer.
html
Also, see my CSS answer.
-
3\$\begingroup\$ You can save four characters by using decimal instead:
HTML
. 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– Bob2017年01月25日 03:26:30 +00:00Commented Jan 25, 2017 at 3:26 -
\$\begingroup\$ Why doesn't
HTML
count? \$\endgroup\$OrangeDog– OrangeDog2017年01月25日 13:51:00 +00:00Commented 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– darrylyeo2017年01月25日 18:39:39 +00:00Commented Jan 25, 2017 at 18:39
-
\$\begingroup\$ But
html
should be valid, reducing the score by 12 bytes. \$\endgroup\$Christoph– Christoph2017年01月27日 11:09:50 +00:00Commented 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– darrylyeo2017年02月15日 15:31:58 +00:00Commented Feb 15, 2017 at 15:31
Vim, 0 bytes
When you start Vim, the editor displays a splash screen which looks like this:
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.
-
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– user621312017年01月25日 14:36:35 +00:00Commented Jan 25, 2017 at 14:36
-
4\$\begingroup\$ Since when is "vim" a programming language? \$\endgroup\$DepressedDaniel– DepressedDaniel2017年01月27日 03:26:49 +00:00Commented 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– bash0r2017年01月27日 13:32:28 +00:00Commented 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– dfeuer2019年08月12日 07:45:11 +00:00Commented 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– Clearer2019年08月13日 06:57:54 +00:00Commented Aug 13, 2019 at 6:57
Python, 15 bytes
Python 2 (15)
exec"150円elp()"
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("150円elp()")
-
\$\begingroup\$ Not sure
help
counts, it only works in a REPL environment. \$\endgroup\$xnor– xnor2017年01月25日 01:09:50 +00:00Commented Jan 25, 2017 at 1:09 -
\$\begingroup\$ It still prints out the Python. That's all that's required. \$\endgroup\$user63571– user635712017年01月25日 01:16:00 +00:00Commented Jan 25, 2017 at 1:16
-
1\$\begingroup\$ Never mind, I was mistaken and it works as a program. Sorry about that. \$\endgroup\$xnor– xnor2017年01月25日 01:22:55 +00:00Commented Jan 25, 2017 at 1:22
-
1\$\begingroup\$ you have used the letter 'p' \$\endgroup\$Matt– Matt2017年01月25日 15:34:00 +00:00Commented Jan 25, 2017 at 15:34
-
3\$\begingroup\$
p
is allowed butP
isn't. Rule 1. \$\endgroup\$user63571– user635712017年01月25日 17:54:40 +00:00Commented Jan 25, 2017 at 17:54
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
-
\$\begingroup\$ where is the name ? Or do you refer to the c characters in there ? \$\endgroup\$HopefullyHelpful– HopefullyHelpful2017年01月26日 11:46:52 +00:00Commented Jan 26, 2017 at 11:46
-
3\$\begingroup\$ This should be marked as C (gcc), because other compilers have different messages. \$\endgroup\$orlp– orlp2017年01月26日 12:47:58 +00:00Commented 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 containsc
in some boilerplate output. \$\endgroup\$DepressedDaniel– DepressedDaniel2017年01月27日 03:24:51 +00:00Commented Jan 27, 2017 at 3:24 -
1\$\begingroup\$ @DepressedDaniel undefined reference to 'main' \$\endgroup\$Loren Pechtel– Loren Pechtel2017年01月27日 05:59:50 +00:00Commented Jan 27, 2017 at 5:59
-
\$\begingroup\$ @LorenPechtel Fair enough, missed that. \$\endgroup\$DepressedDaniel– DepressedDaniel2017年01月27日 06:02:12 +00:00Commented Jan 27, 2017 at 6:02
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.
-
1\$\begingroup\$ Wait, is this language Turing complete? \$\endgroup\$Hello Goodbye– Hello Goodbye2019年11月18日 15:08:23 +00:00Commented Nov 18, 2019 at 15:08
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.
-
\$\begingroup\$ ............ :-D \$\endgroup\$Alfe– Alfe2019年10月14日 13:12:23 +00:00Commented Oct 14, 2019 at 13:12
V, 2 bytes
¬U
The obvious answer is:
év~
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 ÿ
.
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):
-[[-<]->+[->]<-]<<.<<<<<--.>>+.<-.+++++.>>>------.<<<<+++.>>++.<---.
Python, (削除) 27 (削除ここまで) (削除) 53 (削除ここまで) (削除) 49 (削除ここまで) (削除) 48 (削除ここまで) (削除) 45 (削除ここまで) 31 bytes
-3 bytes from @wizzwizz4
exec'IM\x50ORT THIS'.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!
-
1\$\begingroup\$ @Arnauld fixed! \$\endgroup\$Value Ink– Value Ink2017年01月25日 00:27:18 +00:00Commented Jan 25, 2017 at 0:27
-
1\$\begingroup\$
HELP()
orHELP(HELP)
is shorter. \$\endgroup\$Gurupad Mamadapur– Gurupad Mamadapur2017年01月25日 08:14:27 +00:00Commented 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– wizzwizz42017年01月25日 18:39:54 +00:00Commented 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– Value Ink2017年01月27日 09:20:40 +00:00Commented Jan 27, 2017 at 9:20 -
\$\begingroup\$ @ValueInk Alright then. \$\endgroup\$Gurupad Mamadapur– Gurupad Mamadapur2017年01月27日 14:00:38 +00:00Commented Jan 27, 2017 at 14:00
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
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".
-
\$\begingroup\$ Are you sure this is only 1 byte? \$\endgroup\$Okx– Okx2017年07月27日 22:38:23 +00:00Commented Jul 27, 2017 at 22:38
-
1\$\begingroup\$ Agreed. It's 2 bytes in UTF-8 \$\endgroup\$mbomb007– mbomb0072017年10月20日 13:48:53 +00:00Commented 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– John P2017年10月20日 17:57:45 +00:00Commented Oct 20, 2017 at 17:57 -
7\$\begingroup\$ This is 1 byte in Win1252, which the error message shows this is using. \$\endgroup\$ATaco– ATaco2017年10月21日 05:04:04 +00:00Commented 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– Joao-32023年09月23日 14:51:47 +00:00Commented Sep 23, 2023 at 14:51
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)
-
\$\begingroup\$ Uses a v and an e \$\endgroup\$user63571– user635712017年01月25日 00:31:35 +00:00Commented Jan 25, 2017 at 0:31
-
\$\begingroup\$ Your language is
Octave
, so you can't usev
ande
. \$\endgroup\$JungHwan Min– JungHwan Min2017年01月25日 00:31:41 +00:00Commented Jan 25, 2017 at 0:31 -
6\$\begingroup\$ Woops. Corrected by changing language to Matlab (which was my initial intent anyway) \$\endgroup\$Luis Mendo– Luis Mendo2017年01月25日 00:55:34 +00:00Commented Jan 25, 2017 at 0:55
><>, (削除) 12 (削除ここまで) 10 bytes
"2,:o:2-o|
This will continually print><> until the interpreter runs out of space.
12 byte version below for those who like a clean output. Recommended by Aaron (no error, 1 output)
":3+:o1ドル+oo;
-
\$\begingroup\$ Brilliant solution! \$\endgroup\$Emigna– Emigna2017年01月25日 14:14:42 +00:00Commented 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\$Teal pelican– Teal pelican2017年01月25日 15:32:52 +00:00Commented 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– Aaron2017年01月25日 16:37:29 +00:00Commented 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\$Teal pelican– Teal pelican2017年01月26日 17:28:17 +00:00Commented 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– Aaron2017年01月26日 17:32:08 +00:00Commented Jan 26, 2017 at 17:32
-
3\$\begingroup\$ What about empty? I get
tcc: error: main not defined
, which includes the letter c in it. Does that count? \$\endgroup\$General Grievance– General Grievance2020年07月27日 02:58:28 +00:00Commented Jul 27, 2020 at 2:58
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
-
15\$\begingroup\$ This is output from compilation, rather than running the program. I don't know whether this is allowed by default. \$\endgroup\$CAD97– CAD972017年01月25日 06:16:37 +00:00Commented 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\$Jonas Schäfer– Jonas Schäfer2017年01月25日 07:41:18 +00:00Commented 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– user9023832017年01月25日 09:59:12 +00:00Commented Jan 25, 2017 at 9:59
-
2\$\begingroup\$ Programs outputting to stderr should be edited into this answer. \$\endgroup\$mbomb007– mbomb0072017年01月25日 14:47:31 +00:00Commented Jan 25, 2017 at 14:47
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.
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
).
-
1\$\begingroup\$ 2 Bytes:
a.
. Prints the alphabet, which obviously includes 'J'. Definetly not as cool though :/ \$\endgroup\$Bolce Bussiere– Bolce Bussiere2018年03月26日 16:47:06 +00:00Commented Mar 26, 2018 at 16:47 -
\$\begingroup\$ Gotta golf it. :-) That said, I am attached to my original answer. \$\endgroup\$Dane– Dane2018年03月28日 17:47:45 +00:00Commented Mar 28, 2018 at 17:47
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
-
1\$\begingroup\$
echo 0ドル
should work \$\endgroup\$r3mainer– r3mainer2017年01月25日 01:41:28 +00:00Commented 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\$Digital Trauma– Digital Trauma2017年01月25日 07:08:19 +00:00Commented 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– nigel2222017年01月25日 11:08:27 +00:00Commented Jan 25, 2017 at 11:08 -
2\$\begingroup\$ 'h' is illigal character for you, and you are using it in echo \$\endgroup\$user902383– user9023832017年01月25日 11:38:06 +00:00Commented Jan 25, 2017 at 11:38
-
2\$\begingroup\$
$'ec\x68o' 0ドル
cures that detail. \$\endgroup\$manatwork– manatwork2017年01月25日 12:02:09 +00:00Commented Jan 25, 2017 at 12:02
brainfuck, 105 Bytes
--[----->+<]>----.[--->+<]>----.+++[->+++<]>++.++++++++.+++++.--------.-[--->+<]>--.+[->+++<]>+.++++++++.
Try it online here
-
7\$\begingroup\$ Well, not a problem in BrainFuck ;) \$\endgroup\$devRicher– devRicher2017年01月25日 07:24:41 +00:00Commented Jan 25, 2017 at 7:24
-
\$\begingroup\$ @devRicher not at all ;) \$\endgroup\$TrojanByAccident– TrojanByAccident2017年01月25日 07:29:49 +00:00Commented Jan 25, 2017 at 7:29
-
\$\begingroup\$ @mbomb007 I see. \$\endgroup\$TrojanByAccident– TrojanByAccident2017年01月25日 20:31:49 +00:00Commented Jan 25, 2017 at 20:31
-
\$\begingroup\$ @mbomb007 updated \$\endgroup\$TrojanByAccident– TrojanByAccident2017年01月25日 20:52:25 +00:00Commented Jan 25, 2017 at 20:52
-
\$\begingroup\$ Is there any reason for the excessive
---
in your markdown? \$\endgroup\$FlipTack– FlipTack2017年01月25日 20:54:24 +00:00Commented Jan 25, 2017 at 20:54
BASIC (ZX Spectrum), (削除) 4 (削除ここまで) 2 bytes
crossed out 4 is still regular 4
Saved 2 bytes thanks to @ShaunBebbers.
0õ
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.
-
\$\begingroup\$ or
0 REM
produces the same error \$\endgroup\$Shaun Bebbers– Shaun Bebbers2019年08月13日 15:52:39 +00:00Commented Aug 13, 2019 at 15:52 -
1\$\begingroup\$ @ShaunBebbers Does that even pass syntax checking? \$\endgroup\$Neil– Neil2019年08月13日 19:13:20 +00:00Commented Aug 13, 2019 at 19:13
-
\$\begingroup\$ yes it does on a real Spectrum. \$\endgroup\$Shaun Bebbers– Shaun Bebbers2019年08月13日 20:36:18 +00:00Commented Aug 13, 2019 at 20:36
Pip, 8 bytes
'IWR C80
Takes the character I
and WR
aps it in C
hr(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. ;^)
C#, (削除) 60 (削除ここまで) 67 bytes
class P{static void Main(){System.\u0043onsole.Write("\x43\x23");}}
-
\$\begingroup\$ Is this actually your answer, or did a bug messed up your answer? \$\endgroup\$auhmaan– auhmaan2017年01月25日 14:18:26 +00:00Commented Jan 25, 2017 at 14:18
-
-
\$\begingroup\$ I was referring to the
\u0043
and alikes \$\endgroup\$auhmaan– auhmaan2017年01月25日 16:16:09 +00:00Commented Jan 25, 2017 at 16:16 -
1\$\begingroup\$ @auhmaan That's intentional because I need
Console
but can't useC
as per question rules. In C# you can use Unicode escape sequences in identifiers. \$\endgroup\$Bob– Bob2017年01月25日 16:36:25 +00:00Commented 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\$TheLethalCoder– TheLethalCoder2017年01月26日 16:29:18 +00:00Commented Jan 26, 2017 at 16:29
Forth, 5 bytes
WORDS
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.
05AB1E (legacy), 0 bytes
An amazing trick that I just learned from Kevin Cruijssen.
It outputs contents of info.txt, which of course contains the name 05AB1E
.
Excel, 35
Closing parens already discounted.
Simple enough:
A1
-=RIGHT(0=1)
-E
fromFALSE
- Output -
=A1&ROMAN(90)&A1&ROMAN(50)
-EXCEL
ROMAN(90)
= XC
, ROMAN(50)
= L
-
2\$\begingroup\$ Or is it 0 because of the splash screen when you start up Excel? \$\endgroup\$General Grievance– General Grievance2020年07月25日 05:38:17 +00:00Commented Jul 25, 2020 at 5:38
Explore related questions
See similar questions with these tags.
--version
isn't allowed"? \$\endgroup\$