Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Write program in your favorite language in another language [closed]

The determined Real Programmer can write Fortran programs in any language.

from Real Programmers Don't Use Pascal

Your task is to write program in your programming language of choice, but you are allowed to use only another language. That is, throw away all coding conventions from one language and replace them with coding conventions from other language. The more the better. Make your program look as if it was written in another language.

For example, Python fan who hates Java could write following Python program in Java:

void my_function() {
 int i = 9 ;
 while(i>0) {
 System.out.println("Hello!") ;
 i = i - 1 ;}}

Pascal enthusiast forced to use C could write this:

#define begin {
#define end }
#define then
#define writeln(str) puts(str)
if (i == 10) then
begin
 writeln("I hate C");
end

You have to write complete program. The program desn't have to do anything useful.

Good Luck. This is a popularity contest so the code with the most votes wins!

Answer*

Draft saved
Draft discarded
Cancel
6
  • 3
    \$\begingroup\$ It runs without errors in GolfScript, BF, HQ9+, ... \$\endgroup\$ Commented Mar 21, 2014 at 22:38
  • \$\begingroup\$ OK, I wasn't aware that such many languages could do it. I edit the code in order to put the language I actually chose. \$\endgroup\$ Commented Mar 22, 2014 at 4:37
  • \$\begingroup\$ @ברוכאל it runs without errors in those languages because those languages don't have errors, or don't have errors applicable to this code. Eg. Brainfuck ignores all characters that are not in .,+-<>[] so your program is equivalent to ...[.]+ in brainfuck which is a valid but pointless program. AFAIK a brainfuck program can only be invalid by having mismatched []. \$\endgroup\$ Commented Mar 27, 2014 at 1:12
  • \$\begingroup\$ @immibis. This is false. dc is an old calculator and I can assure that changing one thing in my codes would raise an error. I spent much time on some parts of the code to figure out some tricky way of putting the letters in the right order. My piece of code Postscript/dc is quite extreme: no error but changing anything will make it faulty. dc has nothing to do with "those languages"; dc is about 20 or 30 years older than "those languages"; it is generally installed on any Linux distribution. Please, browse a little if you haven't heard about it. \$\endgroup\$ Commented Mar 27, 2014 at 3:57
  • 1
    \$\begingroup\$ @ברוכאל you misunderstood - I was talking about brainfuck, HQ9+, golfscript, etc. - not dc. \$\endgroup\$ Commented Mar 27, 2014 at 4:50

AltStyle によって変換されたページ (->オリジナル) /