Reversed language name

10

1

You should code a piece of code that looks like it outputs the language name but actually outputs the name reversed.

E.g. a Python program should look like it outputs Python but should actually output nohtyP.

The winner is the answer with the most upvotes in a week!

user69279

Posted 2017-06-12T14:27:15.250

Reputation:

Question was closed 2017-06-12T19:59:22.440

2

Flagged to close as underhanded questions are no longer welcome.

– scatter – 2017-06-12T14:31:36.427

7I'm voting to close this question as off-topic because underhand questions are no longer welcome in this site – caird coinheringaahing – 2017-06-12T14:35:46.720

13It is such a pity that [tag:underhanded] was made off-topic. The community loves them. – Adám – 2017-06-12T14:52:13.940

1Could've been interesting if it had said "The characters in the language-name cannot be hard-coded". – officialaimm – 2017-06-12T16:10:12.450

3@Adám: Looking at the quality of the answers to this challenge, I can see why we don't like challenges like this on the site any more. Most of the answers are terrible (not even obfuscated at all), and most of the rest are exploiting a loophole in the wording of the question. – None – 2017-06-12T22:01:18.530

@ais523 I suppose you mean allow, not like. Well, apart from the loophole (which the OP could address) upvotes (since this is a popularity contest) are supposed to promote the actually clever answers. – Adám – 2017-06-12T22:10:28.857

1May I suggest adding a rule that prohibits palindromically named languages from participating, or alternatively requires them to add some kind of identifier like a dialect name or a version number? – Adám – 2017-06-12T22:11:43.223

I also think you should forbade palindromic languages! @Adám – sergiol – 2017-06-15T23:43:52.593

From reopen review: this challenge is still off-topic, and although the offtopic subreason given isn't correct (it should be "this challenge is offtopic because it asks for underhanded code"), only a moderator can change the offtopic subreason. So voting to leave as closed. – None – 2017-06-17T08:15:20.970

Since this is closed: Keg, 4 bytes

– None – 2019-09-13T05:23:17.017

Answers

72

PHP, 3 bytes

PHP

Try it online!

It looks like it outputs the language name, but it's actually the letters in reversed order.

Stewie Griffin

Posted 2017-06-12T14:27:15.250

Reputation: 43 471

10I normally hate underhand questions but this one is brilliant – caird coinheringaahing – 2017-06-12T14:34:20.740

9Wait, it's reversed? How sure are you... – user41805 – 2017-06-12T14:40:40.100

10The challenge PHP was created for. – PyRulez – 2017-06-12T19:24:33.903

2Cannot believe this... I hate Palindromes! – Mr. Xcoder – 2017-06-12T19:37:27.263

9@KritixiLithos 100%. I pasted the output into a script where I compared it to 'PHP'[::-1] and it returned true. – Stewie Griffin – 2017-06-12T19:46:44.930

1OK, so this was funny because it exploited a loophole that OP (a newcomer to PPCG) probably didn't think of, but you shouldn't upvote answer that do not answer the challenge. The answer was supposed to be underhanded. This isn't. – Adám – 2017-06-12T22:16:56.620

I don't like that this seems to be considered the standard way to program with PHP. it is more like pure HTML markup. If I type PHP; inside the php cli, that is php -a, it doesn't print anything but says PHP Notice: Use of undefined constant PHP - assumed 'PHP' in php shell code on line 1. I think, this answer should be more like echo PHP;. – phil294 – 2017-06-13T12:14:55.017

22

R, 8 bytes

Took me a while to figure this one out, but I think I've solved it!

cat("R")

rturnbull

Posted 2017-06-12T14:27:15.250

Reputation: 3 689

20

Cubix

Because Cubix doesn't always need to be indecipherable

begin;
print "Cubix" > output;
end@?;

Try it online!

Watch it running

MickyT

Posted 2017-06-12T14:27:15.250

Reputation: 11 735

4This is great!! – Giuseppe – 2017-06-12T19:00:33.617

16

HTML, 11 Bytes

‮HTML

-4 Bytes hardcoding the unicode character in a html file

HTML, 12 Bytes

‮HTML

The browser do the rest in a html file

‮HTML

Jörg Hülsermann

Posted 2017-06-12T14:27:15.250

Reputation: 13 026

1

Might want to check the underhanded tag

– Skidsdev – 2017-06-12T14:45:34.110

@Mayube now better? – Jörg Hülsermann – 2017-06-12T14:59:18.750

2Yeah that's much better – Skidsdev – 2017-06-12T15:01:43.920

12

Braingolf, 20 bytes

"Braingolf"@@@@@@@@@

Try it online!

@ Prints a character as ASCII, however because "Braingolf" pushes the string in order, the last item on the stack is f, so the first @ prints f, and so on.

Because of this quirk, the first Hello, World! program in Braingolf was actually:

"!dlroW ,olleH"@@@@@@@@@@@@@

Sidenote: Braingolf backwards is Flogniarb, which might actually be a better language name than Braingolf!

Skidsdev

Posted 2017-06-12T14:27:15.250

Reputation: 9 656

12

C++

#include <iostream>
int main()
{
    char C = 1;
    std::string CPP;
    for(C++; C++ < 42; C++)
        CPP += "C++";
    std::cout << CPP[C++];
    std::cout << CPP[C++];
    std::cout << CPP[C++];
    return 0;
}

Try it online!

Steadybox

Posted 2017-06-12T14:27:15.250

Reputation: 15 798

11

><>, 8 bytes

"><>">o<

Try it online!

Fun fact, this actually reverses the name of the language. The name, however, is a palindrome. Which is extra funny to me, because 'paling' (which almost spells the start of 'palindrome') is a kind of eel in Dutch.

steenbergh

Posted 2017-06-12T14:27:15.250

Reputation: 7 772

Wait ><> isn't a palindrome, it's <>< backwards – Skidsdev – 2017-06-12T14:51:42.770

2@Mayube instinctively I thought that too and was "Huh, ><> outputs the stack reversed, why am I getting ><>". Then I counted the GT's and LT's... – steenbergh – 2017-06-12T14:53:42.370

3but this doesn't work, because it outputs ><> not <><, the goal is to output the language name reversed – Skidsdev – 2017-06-12T14:58:13.223

5@Mayube ><> reversed is still ><> ;) – user41805 – 2017-06-12T15:00:10.080

5Oh right yeah I see it now, I had to literally replace ><> with 121 in the code to understand what you were saying :P – Skidsdev – 2017-06-12T15:02:42.590

I am wondering how this got a downvote... – steenbergh – 2017-06-13T10:43:50.797

1@steenbergh I countered it. ;) – Arjun – 2017-06-15T08:21:47.913

8

C (gcc), 20 18 bytes

-2 bytes thanks to cleblanc.

Specification says nothing about any output on STDERR so...

main(){puts("C");}

Try it online!

totallyhuman

Posted 2017-06-12T14:27:15.250

Reputation: 15 378

3Why not use puts("C") to save a couple of bytes. – cleblanc – 2017-06-12T18:56:57.627

1First time using C lol. Thanks! – totallyhuman – 2017-06-12T19:43:34.763

@Downvoter, please explain. – totallyhuman – 2017-06-12T23:27:05.710

8

Jelly, 8 bytes

“Jelly”U

Try it online!

"U" is a meaningless enough atom for "reverse an array" that 99% of programmers will likely assume that this program will output "Jelly". Maybe not so much code-golfers, though.

scatter

Posted 2017-06-12T14:27:15.250

Reputation: 874

This is fairly obvious for even beginner Jelly programs like myself a few weeks ago. (I didn't downvote though). – HyperNeutrino – 2017-06-13T13:15:31.617

1@HyperNeutrino Wow, I didn't realize you were a beginner Jelly program! :P – Esolanging Fruit – 2017-07-17T22:12:20.550

1@Challenger5 Well I'm sorry that I can't engrish :p – HyperNeutrino – 2017-07-17T22:26:18.003

5

APL (Dyalog), 24 bytes

Outputs on STDERR. This is a simple identity reduction, but APL goes right-to-left!

{⍺⊣⍞←⍵}/' APL'

Try it online!


Alternate, tacit, self-documenting version:

Print←⍞∘←
Identity←⊣
All←/
Identity∘Print All' APL'

Try it online!


A.P.L.: An Interactive Approach (pun intended). Let's ask for the three letters and input them in proper order:

⎕⎕⎕
'A'
'P'
'L'

Works because APL evaluates from right to left and thus asks for the rightmost letter first, but we enter the "A" first, etc.

Try it online!

Adám

Posted 2017-06-12T14:27:15.250

Reputation: 37 779

4

J, 3 bytes

Jumping on the language-is-palindrome bandwagon:

'J'

daniero

Posted 2017-06-12T14:27:15.250

Reputation: 17 193

Hm… |.'J' would be more fitting. – Adám – 2017-06-12T19:30:59.507

2

q, 5 bytes

a one letter language name makes this problem trivial

1"q";

Output:

q

skeevey

Posted 2017-06-12T14:27:15.250

Reputation: 4 139

-1

Bash, 10 bytes

rev<<<Bash

Try it online!

DrnglVrgs

Posted 2017-06-12T14:27:15.250

Reputation: 145

4If you use sh instead of bash you can save two bytes. Never have I ever suggested switching languages for a program to save two bytes lol – Sirens – 2017-06-12T19:36:43.097

@Sirens: sh doesn't support the <<< redirection. bash is sometimes renamed to sh, but that doesn't change the fact that the language is still Bash. – None – 2017-06-12T21:59:23.727

I stand corrected: sh --version: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16). Kind of nasty that they do that given that sh and bash behave differently. – Sirens – 2017-06-12T22:41:58.460