Hello World in Multiple Languages

72

9

Task

Create a program or a function that is valid in multiple programming languages, and when compiled/interpreted as a different language outputs "Hello, World!" in a different natural language.

For example, a valid solution might output Hello World! (English) when compiled and run as C, Hallo Welt! (German) when compiled and run as C++ and 你好世界! (Chinese) when run as Python.

Rules

To avoid ambiguity about the validity of an answer, below is a list of allowed versions of the phrase in several languages. The list consists of the phrase in languages for which Google Translate has a community-verified translation of the phrase (as of this writing).*

The accuracy of these translations is debatable, but they are what this challenge will use. The printed strings must follow exactly the format below (with the exception of leading or trailing whitespace).

Afrikaans:    Hello Wêreld!
Albanian:     Përshendetje Botë!
Amharic:      ሰላም ልዑል!
Arabic:       مرحبا بالعالم!
Armenian:     Բարեւ աշխարհ!
Basque:       Kaixo Mundua!
Belarussian:  Прывітанне Сусвет!
Bengali:      ওহে বিশ্ব!
Bulgarian:    Здравей свят!
Catalan:      Hola món!
Chichewa:     Moni Dziko Lapansi!
Chinese:      你好世界!
Croatian:     Pozdrav svijete!
Czech:        Ahoj světe!
Danish:       Hej Verden!
Dutch:        Hallo Wereld!
English:      Hello World!
Estonian:     Tere maailm!
Finnish:      Hei maailma!
French:       Bonjour monde!
Frisian:      Hallo wrâld!
Georgian:     გამარჯობა მსოფლიო!
German:       Hallo Welt!
Greek:        Γειά σου Κόσμε!
Hausa:        Sannu Duniya!
Hebrew:       שלום עולם!
Hindi:        नमस्ते दुनिया!
Hungarian:    Helló Világ!
Icelandic:    Halló heimur!
Igbo:         Ndewo Ụwa!
Indonesian:   Halo Dunia!
Italian:      Ciao mondo!
Japanese:     こんにちは世界!
Kazakh:       Сәлем Әлем!
Khmer:        សួស្តី​ពិភពលោក!
Kyrgyz:       Салам дүйнө!
Lao:          ສະ​ບາຍ​ດີ​ຊາວ​ໂລກ!
Latvian:      Sveika pasaule!
Lithuanian:   Labas pasauli!
Luxemburgish: Moien Welt!
Macedonian:   Здраво свету!
Malay:        Hai dunia!
Malayalam:    ഹലോ വേൾഡ്!
Mongolian:    Сайн уу дэлхий!
Myanmar:      မင်္ဂလာပါကမ္ဘာလောက!
Nepali:       नमस्कार संसार!
Norwegian:    Hei Verden!
Pashto:       سلام نړی!
Persian:      سلام دنیا!
Polish:       Witaj świecie!
Portuguese:   Olá Mundo!
Punjabi:      ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ!
Romanian:     Salut Lume!
Russian:      Привет мир!
Scots Gaelic: Hàlo a Shaoghail!
Serbian:      Здраво Свете!
Sesotho:      Lefatše Lumela!
Sinhala:      හෙලෝ වර්ල්ඩ්!
Slovenian:    Pozdravljen svet!
Spanish:      ¡Hola Mundo!         // Leading '¡' optional
Sundanese:    Halo Dunya!
Swahili:      Salamu Dunia!
Swedish:      Hej världen!
Tajik:        Салом Ҷаҳон!
Thai:         สวัสดีชาวโลก!
Turkish:      Selam Dünya!
Ukrainian:    Привіт Світ!
Uzbek:        Salom Dunyo!
Vietnamese:   Chào thế giới!
Welsh:        Helo Byd!
Xhosa:        Molo Lizwe!
Yiddish:      העלא וועלט!
Yoruba:       Mo ki O Ile Aiye!
Zulu:         Sawubona Mhlaba!

So there are 74 languages that can be used.

Winning Criterion

The solution that can output the phrase in the greatest number of languages wins. In case of a tie, the shorter solution (in bytes) wins.


*The translations for Malagasy and Maltese were marked community-verified, but were clearly incorrect (one was just "Hello World!" and the other "Hello dinja!", but "Hello!" alone translates to "Bongu!"). These were excluded. Also some languages (Arabic, Hebrew, Pashto, Persian and Yiddish) read from right to left on Google Translate, but when copied here they read from left to right. I hope that's okay.

Steadybox

Posted 2017-10-28T13:39:15.760

Reputation: 15 798

Are we allowed to use a consistent method of counting bytes that is not used by any of the programming languages that are used? – Zacharý – 2017-10-28T17:05:06.830

@Zacharý I guess any single encoding that has a representation for all characters used in the answer can be used to count the bytes. Or perhaps the bytes should be counted in UTF-8 for every answer? – Steadybox – 2017-10-28T17:31:11.713

1If I have a language that uses a different encoding than all the others, should I convert the code to that language's codepage or use the same byte representation? (which would be hard because some of the bytes result in incorrect UTF-8) – NieDzejkob – 2017-10-28T18:59:13.750

@NieDzejkob Convert to a code page that supports all characters in the answer (in all languages) if possible. – Steadybox – 2017-10-28T19:24:17.313

@Steadybox The point is: what should I feed to the interpreter? – NieDzejkob – 2017-10-28T19:25:20.590

I'd say either way (converting to the interpreted language's code page or using the same byte representation) is fine. – Steadybox – 2017-10-28T19:30:38.413

2

@NieDzejkob I think the rule for polyglot is have one file with measurable bytesize and can be run by multiple interpreter/compiler. (example)

– user202729 – 2017-10-29T09:38:37.587

4Note that the exclamation marks in Chinese and Japanese (, U+FF01) are different from the others (!, U+0021). – alephalpha – 2017-10-29T15:20:15.400

Answers

32

23 Befunges, 713 bytes

The only language I really know is Befunge, so instead of multiple languages, I've just gone with multiple implementations of Befunge. I believe this is still valid under PPCG rules, which consider the language to be defined by its implementation.

8023/# !-1401p680p88+79*6+1p238*7+0pg90p$#v0';1';+>9%80p$$$$"ph~s"+3vv
vv_2#!>#-/\#21#:+#:>#\<0/-2*3`0:-/2g01g00p>#< 2#0 ^#1/4*:*9"9"p00***<<
>>$:2%3*-4/3g68*-70p1-0`02-3/-03-2%1+2/-70g+80g65+70g`7++3g68*-70g9`*v
0168:0>0133?45130120340200v00:<+8*+76%4p00+5/4:+-*86g3++98/2%+98g09+<<
                         @>gg#^:#+,#$"!"-#1_@
       !Helo Byd!!!!!Hai dunia!!!!Ciao mondo!!!Hallo Wereld!!!!
       !Hallo Welt!!!Halo Dunia!!!Halo Dunya!!!Bonjour monde!!!
       !Hei Verden!!!Hej Verden!!!Moien Welt!!!Labas pasauli!!!
       !Molo Lizwe!!!Salut Lume!!!Hei maailma!!Sveika pasaule!!
       !Hello World!!Salom Dunyo!!Tere maailm!!Sawubona Mhlaba!
       !Kaixo Mundua!Salamu Dunia!Sannu Duniya!!!!!!!!!!!!!!!!!

The frustrating thing about Befunge, is that although there is an open source reference implementation, and the language itself is dead simple, there isn't a single third-party interpreter (that I'm aware of) that exactly matches the reference behaviour. Every implementation fails in a different way.

On the plus side, this gives us the opportunity to develop a single piece of code that will produce a different result in almost every interpreter. And that's what I'm attempting in the program above.

If anyone is interested in verifying the results, I've tried to group the various implementations into categories based on how easy they are to get up and running (e.g. some people may not be able to run Windows binaries, or may not be willing to build from source, but everyone should be able to test the online interpreters).

Online Interpreters

No installation required. It's usually just a matter of pasting in the code and clicking a button or two. But note that some of these are quite slow, so may need some time to finish executing.

Alexios' Befunge Playground - Salamu Dunia!

Click the Clear... button and paste the code into the input field. Toggle the Edit switch to activate the interpreter, and then click the Run button to begin executing.
Note that this site probably won't work in Browser's other than Chrome.

Befungius - Molo Lizwe!

Paste the code into the input field, making sure to overwrite the existing code. Then click the Run button to execute.

David Klick's Befunge 93 Interpreter - Sannu Duniya!

Paste the code into the Playfield input field, and then click the Run button to begin executing.

Ian Osgood's Befunge-93 Interpreter - Salut Lume!

Paste the code into the input field under the Show button, making sure to overwrite the @ that is already there. Click the Show button to import the code, then click the Run button to begin executing.

jsFunge IDE - Hej Verden!

First close the Help dialog, then click the Open/Import toolbar button (second from left), paste in the code, and click OK. To execute, click the Run Mode button (fourth from left), and then Start (fifth from left).

Also note that a few of the console-based interpreters are actually available on TIO, so while they aren't technically online interpreters, they can be tested online. For those that are supported (currently BEF, FBBI, MTFI and PyFunge), I've included a Try It Online! link next to their entry.

Java IDEs

You'll need to have the Java run-time installed for these, but they should theoretically work on any platform. Only tested on Windows though.

Ashley Mills' Visual Befunge Applet - Moien Welt!

This was initially an online applet which is unfortunately no longer available, but you can still download the jar and run it locally as a desktop application. You'll need to paste the code into the Program Editor window, then click the Convert button, followed by the Run button.

WASABI: Wasabi's A Superbly Asinine Befunge Interpreter - Hallo Welt!

To paste in the code, right click in the top left corner of the editor window (it must be the very top left) and select the Paste menu item. Then enable the Full Speed check box (otherwise it'll take forever), and click the Run! button to begin executing.

YABI93: Yet Another Befunge93 Interpreter - Halo Dunia!

Press Ctrl+A, Ctrl+V to paste the code into the editor window, being sure to overwrite the default source. Then click the Start button to begin executing.

Windows IDEs

You'll typically need Windows for these, although in some cases there may be binaries available for other operating systems. I can't promise the code will work on other platforms though.

BefunExec - Hello World!

You can't paste the code into the editor, so you'll first need to save it to disk somewhere. Then from the IDE, use the File > Open menu to load the code from disk, and select the Simulation > Run/Pause menu to run it.

BeQunge - Labas pasauli!

Press Ctrl+V to paste in the code, and then click the Debug toolbar button (the blue cog) to begin executing. Once the Debugger panel appears, you'll want to set the Speed to maximum - the button to the right of the slider - otherwise it'll take forever to finish.

Fungus - Tere maailm!

Press Ctrl+V to paste in the code, and then press F5 to run it.

Visbef: Visual Befunge '93 for Windows - Hallo Wereld!

You can't paste the code into the editor, so you'll first need to save it to disk somewhere. Then from the IDE, press Ctrl+O to open the file browser and load the code from disk, and press F5 to run it.

Windows Console Apps

Again these typically require Windows, although other platforms may be available, but not guaranteed to work.

In all cases the code will need to be saved to a file on disk and the filename passed to the interpreter as a command line parameter (source.bf in the example command lines given below). Also note that some of these are technically Befunge-98 interpreters, and must be run with a particular command-line option to force a Befunge-93 compatibility mode. If you don't do that, you won't get the correct results.

BEFI: Rugxulo's Befunge-93 Interpreter - Hei Verden!

Command line: bef93w32 -q source.bf

CCBI: Conforming Concurrent Befunge-98 Interpreter - Sveika pasaule!

Comand line: ccbi --befunge93 source.bf

MTFI: Magus Technica Funge Interpreter - Hai dunia!

Command line: mtfi -3 source.bf (Try it online!)

Python and PHP Console Apps

These require the appropriate scripting language installed - either Python or PHP.

Befungee - Helo Byd!

Command line: befungee.py source.bf

PyFunge - Halo Dunya!

Command line: pyfunge -v 93 source.bf (Try it online!)

Bephunge - Bonjour monde!

Command line: php bephunge.phps source.bf

Source-only Console Apps

These will need to be built from source, and that's usually easiest with a *nix-like environment. On Windows I use the Windows Subsystem for Linux.

BEF: Befunge-93 Reference Distribution - Ciao mondo!

Command line: bef -q source.bf (Try it online!)

cfunge - Sawubona Mhlaba!

Command line: cfunge -s 93 source.bf

FBBI: Flaming Bovine Befunge-98 Intepreter - Hei maailma!

Command line: fbbi -93 source.bf (Try it online!)

Fungi - Kaixo Mundua!

Command line: fungi source.bf

Rc/Funge-98 - Salom Dunyo!

Command line: rcfunge -93 source.bf

How it works

The challenge with this was finding the fewest number of tests that provided the most differentiation between interpreters. In the end it came down to four main test sequences:

  1. The first is an out-of-bounds memory read from offset -1,1. In theory this should always return 32 (ASCII space), but there were actually 10 variations in practice. This test is complicated by the fact that two of the interpreters crash on an out-of-bounds read, so a couple of special-case tests (division rounding and space bridging) were required to force those two back into bounds.

  2. The second sequence is a test of Befunge-98 functionality - specifically the instructions ; and '. Almost all of the interpreters are Befunge-93, or are run in Befunge-93 compatibility mode, so they should just ignore those instructions. In practice there were 6 different ways in which this sequence was interpreted.

  3. The third test checks the range of memory cells. In the reference interpreter, memory cells are signed 8-bit, but other implementations vary in range from 8-bit to unbounded, some signed and some unsigned. However, for the purposes of this test, we only had to distinguish between 5 of those variants.

  4. The fourth and final sequence is a combination of underflow and negative division tests. There are a number of ways in which interpreters get underflow wrong, and there are at least 3 different ways in which the division and modulo instructions are implemented, but there were only 3 combinations we cared about here.

Each of these sequences returned a single number, and those four numbers were combined (via some basic arithmetic and translation tables) to produce a final value in the range 0 to 22. That value could then be used as an index to lookup the actual message to display.

James Holderness

Posted 2017-10-28T13:39:15.760

Reputation: 8 298

Pretty cheep method, but there is no way I'm beating this. Now we could probably adjust this and squeeze BrainFuck variants in there. – Zacharý – 2017-11-03T17:58:27.213

10I assure you it's not as easy as you might imagine. It's a challenge just getting the code to run without crashing in 20+ buggy interpreters. If I wanted to be cheap, I would have used Befunge-98 and simply queried the implementation handprints (3y). – James Holderness – 2017-11-03T19:33:37.623

2I'm referring to cheap as in how you use only befunges, but this is actually very impressive. – Zacharý – 2017-11-04T17:29:43.097

This is an incredibly impressive, but is it possible to explain why different interpreters treat it differently? Maybe not all 23 versions, but a few examples of the behavioral differences you're exploiting, at least? – Jack Brounstein – 2018-11-19T23:42:13.047

1@JackBrounstein I've added a bit of an explanation at the end of the answer. – James Holderness – 2018-11-28T18:22:14.310

63

16 languages, 1363 bytes

 #define ip"MemuL tulaS",,,,,,,,,,"!",@++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.@,kc"Kaixo Mundua!"v#!
#define print(A,B,C)main(){printf("Helo Byd!");}//ss                                                                          ;ooooooooooooooooooo"Moni Dziko Lapansi!"<  
#ifdef __cplusplus//p                                                                                                                                 ;;];;
#include<cstdio>//ffffffffff?
#define print(A,B,C)int main(){printf("Halo Dunya!");}//ssp
#endif//;  [;;;;;;;;;     "!etejivs vardzoP"]
#ifdef __OBJC__//;;;;;
#define print(A,B,C)main(){printf("Hallo Welt!");}//ss
#endif//\
"""echo" "Salom Dunyo!";"exit";puts"Moien Welt!";\
__END__
#define B//\
"""#;;;;;
print(["Hai dunia!","Hej Verden!","Halo Dunia!"][(int(1>0)is 1)+~int(-1/2)*2])
#define s eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeejeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeejiiiiiiiijeeeeeeeeeeeeeejiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeejeejijiiiiiiiiiijeeeeeeeeeeejiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiij
#define U   !"!dlereW ollaH"<           ;
#define T@,kc"Sannu Duniya!?%?"

Try it online!

(use "switch languages" to change language)

  • Python 3 = Halo Dunia! (Indonesian)

  • Python 2 = Hej Verden! (Danish)

  • Python 1 = Hai dunia! (Malay)

  • C (gcc) = Helo Byd! (Welsh)

  • C++ (gcc) = Halo Dunya! (Sundanese)

  • Objective C (clang) = Hallo Welt! (German)

  • Brainfuck = Hello World! (English, obviously)

  • Befunge-93 = Salut Lume! (Romanian)

  • Ruby = Moien Welt! (Luxemburgish)

  • Bash = Salom Dunyo! (Uzbek)

  • Befunge-98 (PyFunge) = Kaixo Mundua! (Basque)

  • Unefunge-98 (PyFunge) = Sannu Duniya! (Hausa)

  • Cardinal = Hallo Wereld! (Dutch)

  • Alphuck = Ciao mondo! (Italian)

  • ><> = Moni Dziko Lapansi! (Chichewa)

  • Fission = Pozdrav svijete! (Croatian)

Any golfing tips are welcome (especially on the Brainfuck)!!

Thanks to @JonathanFrech for -1 byte! Also, thanks to @ovs for -40 bytes!

How (general ideas, I actually forgot specifics)??

The languages can be put into four groups:

  • Macro: C, C++, Objective C
  • Comment: Python3, Python2, Python1, Ruby, Bash
  • Dimensional: Befunge-93, Befunge-98, Unefunge-98, Cardinal, ><>, Fission
  • Vulgar: Brainfuck, Alphuck

The Macro languages see # as the start of a preprocessor directive. These are used for three reasons: to house code for other groups, to distinguish among Macro languages, and to actually define a macro. All three use // as comment, so after that we store code for the other groups. Also, the backslash continues the comment in these languages.

The Comment languages see # as the start of a comment. The quirk here is the triple quotes, which distinguish the Pythons from Ruby from Bash. And to distinguish Python 1 from 2 from 3, we use a distinguishing feature in all three, along with an array of outputs. Oh yeah, there's also that __END__. This is used to end the code for some (can't remember exactly which ones) of the Comment languages.

The Dimensional languages are distinguished in a way that is hard to explain. One has to know the specifics of each language to figure it out. For example, # is only a skip in the fungeoids, while it does various different things in the other languages. The code is strewn about everywhere for these languages.

And finally, we arrive at the Vulgar languages. These two ignore everything that isn't in their set of valid characters. A balancing act has to be played with these languages and the others, as the code already contains characters in the character sets.

Zacharý

Posted 2017-10-28T13:39:15.760

Reputation: 5 710

Can you combine the strings in the Python submission into one big string and use string slicing to index into it it? e.g. "abcabcabc"[n::3] -> "aaa" for n = 0, "bbb" for n = 1. I feel like there's probably a way you can slice it and save bytes by including the duplicated characters in the slicing somehow (like H and !). – cole – 2017-10-28T17:30:09.327

Eh, I'll do something like that when someone comes near my score. – Zacharý – 2017-10-28T17:58:49.437

I think -2*int(...)-1 can be +~int(...)*2, albeit the Python version to language mappings change. – Jonathan Frech – 2017-10-28T18:42:07.677

2Cool! the brackets in ["Hai dunia!","Hej Verden!","Halo Dunia!"] shield the commas! – Uriel – 2017-10-28T20:51:30.610

3They wouldn't need to, I abuse the fact that the TIO brainfuck defaults 0 (or does nothing, I can't tell) if it runs out of input from the user. There are 9 other unshielded commas that abuse this fact. – Zacharý – 2017-10-28T20:55:18.837

Whoops, I meant Bash, not powershell >_< – Zacharý – 2017-10-29T13:25:08.290

You can replace the befunge-98 part @,,,,,,,,,,,,, with @,kc (the same can be done for the unefunge part) – ovs – 2017-10-29T13:56:52.007

Like that matters now ... but thanks! – Zacharý – 2017-10-29T14:35:13.713

2

Is there a reason you're not using the +[++[<+++>->+++<]>+++++++]<<<--.<.<--..<<---.<+++.<+.>>.>+.>.>-.<<<<+. for your BF part? (source)

– Esolanging Fruit – 2017-10-30T05:35:44.003

The comma. The comma is why I'm not using that one. – Zacharý – 2017-10-30T11:07:42.323

The rep ... is unreal. – Zacharý – 2017-10-31T18:13:32.607

@Zacharý If the problem is that the commas are reading input into the cell, can't you just add a > to get move to a cell that's still zeroed and then do primo's 78 byte BF program? – Ray – 2017-11-06T20:00:10.133

The comma in the output of +[++[<+++>->+++<]>+++++++]<<<--.<.<--..<<---.<+++.<+.>>.>+.>‌​.>-.<<<<+. is the problem, I might be able to adjust it ever so slightly (and even reduce bytes), but it still wouldn't matter because of the 23 befunges answer. – Zacharý – 2017-11-07T13:18:21.387

1I've added an explanation, for anybody that wants to see it. – Zacharý – 2018-11-28T18:45:55.017

38

15 languages, 532 bytes

# ;"!audnuM oxiaK">:#,_@R"Hej Verden!";;@,kb"Tere maailm!";# w"!amliaam ieH"ck,@oooooooooo"Hai dunia!"
`true #{puts'Hola món!'}` \
__END__
"Hola Mundo!" puts
case `ps -p$$ -oargs=` in \
b*)echo Hallo Welt!;;k*)echo Ndewo Ụwa!;;d*)echo Ciao mondo!;;z*)echo Moien Welt!;;a*)echo Hei Verden!;;esac
true; 
#xx
#x%"Olá Mundo!"x
#xx+++[++[<+++>->+++<]>+++++++]<<<--.<.<--..<<---.<+++.<+.>>.>+.>.>-.<<<<+.
   	  	   
	
     		  	 	
	
     		 		  
	
     		 				
	
     	     
	
     	    	 
	
     				  	
	
     		  	  
	
     	    	
	
  

Try it online!

  1. Kaixo Mundua! in Befunge-93
  2. Hej Verden! in Fission
  3. Tere maailm! in Unefunge-98
  4. Hei maailma!! in Befunge-98
  5. Hai dunia! in ><>
  6. Hola món! in Ruby
  7. Hola Mundo! in GolfScript
  8. Hallo Welt! in bash
  9. Ndewo Ụwa! in ksh
  10. Ciao mondo! in dash
  11. Moien Welt! in zsh
  12. Hei Verden! in ash
  13. Olá Mundo! in Cardinal
  14. Hello World! in brainfuck, courtesy of primo.
  15. Helo Byd! in Whitespace

Explanation

Line 1 distinguishes between five 2D esolangs:

  1. ><> reads # as a mirror, wraps around to the left, prints "Hai dunia!" and crashes (@). All the Funges read it as a trampoline and go right.
  2. Befunge-93 ignores ;, prints Kaixo Mundua! and exits (@).
  3. The ’98 Funges jump from the first ; to the second, then from the third ; to the fourth. w is a NOP for Befunge-98, printing Hei maailma!.
  4. But w reflects the instruction pointer in Unefunge-98, printing Tere maailm!.
  5. Fission doesn’t start in the top-left corner at all. R"Hej Verden!"; is executed. (Another instruction pointer starts from the D in __END__, but it does nothing then dies to the ; in true;.)

Ruby sees `true #{puts'Hola món!'}`, then __END__.

GolfScript sees `, then true (NOP), then a comment; then __END__ (NOP); then "Hola Mundo!" puts (this is executed); then case (NOP), then ` (crashes on empty stack).

The shells see a comment, then an invocation to true (NOP), then invocations to unknown commands __END__ and "Hola Mundo!" (which error to STDERR but execution continues), then the case statement which distinguishes based on the first letter of the name of the current process.

Cardinal is another 2D esolang which starts at the %, sending 4 IPs up, down, left, and right. They're all killed by the surrounding x commands, but one prints "Olá Mundo!" before dying.

The brainfuck code is primo’s, prefixed with ++ to counteract the dashes in ps -p$$ -oargs=.

The whitespace in my code is executed as the Whitespace program

 push 0
 push 0
label_0:
 push 0
 push 0
 drop
 drop
 push 72; printc
 push 101; printc
 push 108; printc
 push 111; printc
 push 32; printc
 push 66; printc
 push 121; printc
 push 100; printc
 push 33; printc

which prints Helo Byd!

EDIT: I forgot that adding UDLR characters breaks the Fission program, so I’ve changed the strings up to avoid these.

Lynn

Posted 2017-10-28T13:39:15.760

Reputation: 55 648

1I'll get you soon. – Zacharý – 2017-10-29T13:52:03.160

1I think I surrender now, you did an amazing job. – Zacharý – 2017-10-29T14:32:30.407

I feel a little bad, because your solution has the languages interacting in far more interesting ways! I really just padded my “5 shells” answer with esolangs that are easy to polyglot with one another… >.<; – Lynn – 2017-10-29T14:35:08.370

It's actually not interesting, the #define trick is abused to no end. – Zacharý – 2017-10-29T14:36:09.940

1Now, if anyone can polyglot these languages with D, I will forever be in awe. (#define isn't a thing in D... that gets in the way of polyglotting a lot). Also, I really need to learn whitespace. – Zacharý – 2017-10-29T14:44:26.780

Unfortunately it seems that the Fission code has broken due to some edit. At least it produces rather erratic output on TIO.

– Steadybox – 2017-10-29T15:19:15.453

No wonder my fission code wasn't working! In that case, I have the lead again. – Zacharý – 2017-10-29T16:04:48.307

1oh, there are more uppercase letters now, I see. I’ll fix it in a bit by picking different Hello Worlds. – Lynn – 2017-10-29T17:06:51.923

I have you now! (16 languages) – Zacharý – 2017-10-30T14:09:27.413

17

4 languages, 75 bytes

#"Hej Verden!"o|
print ([]and(0and"Hola món!"or"Helo Byd!")or"Hai dunia!")

Python - Hai dunia!

Perl - Helo Byd!

Ruby - Hola món!

Haystack - Hej Verden!

Uriel

Posted 2017-10-28T13:39:15.760

Reputation: 11 708

12

7 languages, 221 bytes

<?php echo'مرحبا بالعالم!';die?>h+#;"!dlereW ollaH"ck,@;
;echo Kaixo Mundua!;                        <@,k+4f"ሰላም ልዑል!"

Բարեւ աշխարհ!
@,k+4f"Përshendetje Botë!";XXXX;"Hello Wêreld!"

Since this program contains some nasty characters, here's an xxd:

00000000: 3c3f 7068 7020 6563 686f 27d9 85d8 b1d8  <?php echo'.....
00000010: add8 a8d8 a720 d8a8 d8a7 d984 d8b9 d8a7  ..... ..........
00000020: d984 d985 2127 3b64 6965 3f3e 682b 233b  ....!';die?>h+#;
00000030: 2221 646c 6572 6557 206f 6c6c 6148 2263  "!dlereW ollaH"c
00000040: 6b2c 403b 0a0c 3b65 6368 6f20 4b61 6978  k,@;..;echo Kaix
00000050: 6f20 4d75 6e64 7561 213b 2020 2020 2020  o Mundua !;
00000060: 2020 2020 2020 2020 2020 2020 2020 2020
00000070: 2020 3c40 2c6b 2b34 6622 e188 b0e1 888b    <@,k+4f"......
00000080: e188 9d20 e188 8de1 8b91 e188 8d21 220a  ... .........!".
00000090: 0ad4 b2d5 a1d6 80d5 a5d6 8220 d5a1 d5b7  ........... ....
000000a0: d5ad d5a1 d680 d5b0 210a 402c 6b2b 3466  ........!.@,k+4f
000000b0: 2250 c3ab 7273 6865 6e64 6574 6a65 2042  "P..rshendetje B
000000c0: 6f74 c3ab 2122 3b58 5858 583b 2248 656c  ot..!";XXXX;"Hel
000000d0: 6c6f 2057 c3aa 7265 6c64 2122 0a         lo W..reld!".

NieDzejkob

Posted 2017-10-28T13:39:15.760

Reputation: 4 630

Why not <?='مرحبا بالعالم!';die?>? It's valid PHP (essentially the same as <?php echo ... ?>), – Ismael Miguel – 2017-10-29T13:51:29.080

@IsmaelMiguel because I forgot about that feature... simple as that – NieDzejkob – 2017-10-29T15:03:22.500

9

5 languages, 168 bytes

  //"!nedreV jeH",,,,,,,,,,,@R"Hello World!"*#x
///"!mliaam ereT">:?v; x"!dyB oleH"           %x
//               ^ o<                         x
// >`Sawubona Mhlaba!`;

I think 2-dimensional languages are interesting.

><> prints Tere maailm!
Befunge-98 prints Hej Verden!
Beeswax prints Sawubona Mhlaba!
Cardinal prints Helo Byd!
Fission prints Hello World!

Try it online! (Cardinal)

KSmarts

Posted 2017-10-28T13:39:15.760

Reputation: 1 830

2I see great potential here, since // are comments in a lot of languages. – Zacharý – 2017-10-28T21:55:41.290

@Zacharý That's the only reason most of them are there. Right now, two are used for ><> and one for Beeswax. The ones in the first two columns don't do anything. – KSmarts – 2017-10-28T22:19:37.903

Can you explain the control flow for Beeswax? I want to see if it is suitable for this challenge.

– Potato44 – 2017-10-31T12:53:41.187

@Potato44 It's a 2-d language that interprets the code as a bounded hexagonal grid, so pointers can move in 6 directions. Bees (pointers) are spawned by the characters */\_ and can be redirected in fixed directions or by mirrors or rotation. See here for more.

– KSmarts – 2017-10-31T13:23:22.077

You can cut it by 1 byte because for the beeswax part the ; after the second backtick is not necessary. The Bee just runs off the honeycomb towards the right. – M L – 2018-07-04T02:15:59.600

7

2 languages, 16 characters, 24 bytes

Well, at least that's shorter than both strings.

L"שלום עולם"33ç«

05AB1E - שלום עולם!

Help, WarDoq! - Hello World!

Help, WarDoq! can add two numbers and test for primes, so it is considered as a valid programming language per this meta post.

Uriel

Posted 2017-10-28T13:39:15.760

Reputation: 11 708

IIRC, they are not one byte in 05AB1E, it's only due to limitations of TIO.\ – Zacharý – 2017-10-28T16:55:37.820

@Zacharý are you sure? I know hebrew chars to be 1 bytes in some encodings. Could be overlapping char codes. – Uriel – 2017-10-28T16:56:42.030

Do you see Hebrew here?

– Zacharý – 2017-10-28T16:57:42.933

@Zacharý fixed (I think that would make 24 bytes) – Uriel – 2017-10-28T17:05:20.160

6

3 languages, 67 62 bytes

To qualify for this bounty (100 rep).

x:Helo Byd!
O
y:"Hai dunia!"
u?`h;`4$'5^5D+Asi:^:E+IvIvAB*vhm,

Add++: Try it online!

Foo: Try it online!

Somme: Try it online!

Explanation

Add++

Add++ sees:

x:Helo Byd!
O

"Output x's string"

y:"Hai dunia!"

"Set y to a different string"

u?`h;`4$'5^5D+Asi:^:E+IvIvAB*vhm,

"idk something weird, I'll error out"

Foo

Foo sees:

x:Helo Byd!
O
y:"Hai dunia!"

"Oo, quotes, I'll output those."

u?`h;`4$'5^5D+Asi:^:E+IvIvAB*vhm,

"Uh... something about a mode? Idk, I'll error out."

Somme

Somme sees, well, this:

8s+vi:4+vhIvE-Asi:^:E+IvIvAB*vhm,

Every column is converted to code points, then 32 is subtracted from them, then each is taken modulo 95. This corresponds to these characters, which print, "Hei Verden!"

Conor O'Brien

Posted 2017-10-28T13:39:15.760

Reputation: 36 228

Well, the week is up, and you're the shortest (and only) competing answer, so congratulations on the bounty! – caird coinheringaahing – 2018-01-28T00:08:42.157

@cairdcoinheringaahing Thanks! :D – Conor O'Brien – 2018-01-28T01:18:20.357

5

4 languages, 138 bytes

''' '/*' '''
print(["Bonjour monde!","Hei maailma!","Hallo Wereld!"][((int(not 0)is 1)+2*int(1/2==0))-1])
''' '*/print("Hallo Welt!")' '''

Try it online!

Py1, Py2, Py3, Proton; thanks to Mr. Xcoder; translated from Zacharý's answer

HyperNeutrino

Posted 2017-10-28T13:39:15.760

Reputation: 26 575

4 languages (Proton, Py1, Py2, Py3). Inspired by Zacharý answer. – Mr. Xcoder – 2017-10-28T16:43:06.233

@Mr.Xcoder Oh cool, thanks! – HyperNeutrino – 2017-10-28T16:47:16.430

4

4 languages, 115 bytes

print ((("b" + "0" == 0)and eval('"Hallo Wereld!"'))or(0 and"Hello World!"or(1/2and"Hei Verden!"or"Hej Verden!")));

Perl 5 gives Hallo Wereld! - TIO

Ruby gives Hello World! - TIO

Python 2 gives Hej Verden! - TIO

Python 3 gives Hei Verden! - TIO

Halvard Hummel

Posted 2017-10-28T13:39:15.760

Reputation: 3 131

107 bytes — print (((“b”+”0"==0)and eval('"Hallo Wereld!"'))or(0and"Hello World!”or((1/2and"Hei"or"Hej")+" Verden!"))); – Jollywatt – 2017-10-29T09:48:35.767

4

Four Languages, a whopping 650 bytes

//iiciccepepceaiiiaiaiaicccsascciijceeeeeejccijjccjceaajaajcccjeeejaajaaijcccej
//[
/*
GOTO end
*/
//pis
//p
//p
//\u000Apublic class Main{public static void main(String[]a){System.out.print("Salut Lume!");}}
/*
lblend
print Hola Mundo!
//s
*/
//]
//s
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++.--------.++++++++++++++.-------------------------------------------------------------------------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++.-.----------.+++++++++++.------------------------------------------------------------------------------.

Java gives "Salut Lume!" Try it!

S.I.L.O.S gives "Hola Mundo" Try it!

Brainfuck gives "Ciao mondo!" Try it!

(The alphuck code is modified from the Esolangs page on Alphuck)

Alphuck gives "Hello World!" Try it!

The line beginning \u000A is the Java code. The code on line one is the Alphuck code, which will ignore the rest of the code (as long as "p" and "s" are balanced. The relevant line for SIL/S.I.L.O.S is "print Hola Mundo", and the brainfuck code is at the end and will ignore the rest of the code.

Rohan Jhunjhunwala

Posted 2017-10-28T13:39:15.760

Reputation: 2 569

1

I think you can golf the BF code some using the constants provided by this page and the techniques used there.

– cole – 2017-10-28T17:33:50.960

@cole I try to take another look at the bf code when I get some more time to optimize it. Essentially, I don't think it's enough to just use constants, I'm going to have to define a recurrence relation – Rohan Jhunjhunwala – 2017-10-28T17:35:21.383

178 for 'Ciao mondo!': +>++>+>+++[+++++[>+++++++++++>++++<<-]+++<]>>--.>+.>.>-.>.<--.++.-.<+++.>+.>+. using the byte sequence [69, 104, 97, 112, 32] – primo – 2017-10-30T16:31:57.183

4

5 languages, 213 bytes

I decided to try and write a small answer myself.

#include<stdio.h>
#define hint(x)int main(){auto i=.5;puts(i?"Hallo Welt!":"Hei maailma!");}
#define R "Pozdrav svijete!";
#if 0
hint=print
goto=len
s="Tere maailm!"
goto("endif")
s="Hallo Wereld!";
#endif
hint(s)

Languages:

C:                                       Hei maailma!      (Finnish)
C++:                                     Hallo Welt!       (German)
Python 3:                                Hallo Wereld!     (Dutch)
Operation Flashpoint scripting language: Tere maailm!      (Estonian)
Fission:                                 Pozdrav svijete!  (Croatian)

C and C++ see the code as:

#include<stdio.h>
#define hint(x)int main(){auto i=.5;puts(i?"Hallo Welt!":"Hei maailma!");}
#define R "Pozdrav svijete!"; // Unused macro
hint(s)

auto i=.5; is (in effect) equal to int i=0; in C, but equal to double i=0.5; in C++.

Try it online! (as C)

Try it online! (as C++)

Python 3 sees the code as:

hint=print
goto=len
s="Tere maailm!"
goto("endif")         # Calculate string length and discard the result.
s="Hallo Wereld!"
hint(s)

Try it online!

OFP scripting language sees:

; (A semicolon at the beginning of a line comments the line in a script.)

; Four labels with strange names.
#include<stdio.h>
#define hint(x)int main(){auto i=.5;puts(i?"Hallo Welt!":"Hei maailma!");}
#define R "Pozdrav svijete!";
#if 0

; Assign a null value to "hint", no practical effect. Same for "goto".
hint=print
goto=len

; Assign the string to variable "s".
; I would like to have used the Czech phrase for OFP (because it's a Czech game),
; but it didn't recognize the 'ě' and printed a '?' instead.
s="Tere maailm!"

; Jump to label "endif".
goto("endif")

; This reassignment of "s" gets skipped.
s="Hallo Wereld!";

; Declare a label called "endif".
#endif

; Print the string "s".
hint(s)

Fission sees:

R "Pozdrav svijete!";

Try it online!

Steadybox

Posted 2017-10-28T13:39:15.760

Reputation: 15 798

2

3 languages, 184 181 bytes

Only works once - you have to clear the list to run it again.

when gf clicked
add<[]=[]>to[c v
if<(join(item(1 v)of[c v])[d])=[1d
say[Helo Byd!
else
repeat(300000
add[]to[c v
end
if<(length of[c v])>[250000
say[Hello world!
else
say[Hai dunia!

Scratch 1.4: Helo Byd!

Scratch 2.0: Hello world!

Scratch 3.0 beta as of the time of this answer: Hai dunia!

Explanation

In Scratch 1.4, adding a boolean to a list adds 1 or 0, but in 2.0 and up it adds true or false, but when checking if the item is equal to 1 with <[]=[]>, it will return true if the item is either 1 or true, so we add another letter to it and check that.

In Scratch 3.0, lists have a maximum size of 200,000 items, so we just add a bunch of items and see if the list is that long.

W. K.

Posted 2017-10-28T13:39:15.760

Reputation: 51

1

3 languages, 61 bytes

;“,ḷṅḳȦ»Ḋḷ“
x:Hai dunia!
O
y:"Helo Byd!"
;”

Add++ outputs Hai dunia!

Jelly outputs Hello World!

Foo outputs Helo Byd!

Just because I set the bounty doesn't mean I can't take part :D (ab)uses the brilliant string setting trick that Conor found for Add++

How it works

Add++

;“,ḷṅḳȦ»Ḋḷ“     ; A comment. This does nothing
x:Hai dunia!    ; Set the x accumulator to the string "Hai dunia!"
O               ; Output x
y:"Helo Byd!"   ; Set the y accumulator to the string "Helo Byd!"
;”              ; Another comment

Jelly

Comments in Jelly can be formed with the syntax ḷ“comment”, which is how the Add++ and Foo code is ignored. The code that is actually executed by Jelly is

;“,ḷṅḳȦ»Ḋ - Main link. Arguments: None
 “,ḷṅḳȦ»  - Yield the string "Hello World!"
;         - Append 0, yielding "0Hello World!"
        Ḋ - Remove the first character, yielding "Hello World!"

Foo

Foo ignores all characters here aside from "Helo Byd!", which, as it's in quotes, is outputted.

caird coinheringaahing

Posted 2017-10-28T13:39:15.760

Reputation: 13 702

1

3 Languages, 274 Bytes

#define b++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+>
#include<stdio.h>
#define p(x)int main(){printf("नमस्ते दुनिया!");}
#if 0
p=print
goto=len
goto("endif")
s="Helo Byd!";
#endif
p(s)

C:नमस्ते दुनिया!

Python: Helo Byd!

Brainfuck: Hello World!

Try it online!

SiD

Posted 2017-10-28T13:39:15.760

Reputation: 141