?

Log in

Tue, Mar. 8th, 2005, 09:08 pm

Howdo?
No vastly exciting new news this time, which is probably for the best.
Sent off some paperwork to Popstar agreeing to work for them (well
duh...), and I'm starting on 4th April - which will lead to a truly
hectic move to Leeds, but since when are these things ever easy?
In other news, despite (or perhaps because of?) Wikipedia currently
trying to decide if it should delete my horribly geeky page about a
programming language I made up ( http://electrodruid.zapto.org/l33t.htm
, for anyone who happens to be interested), I've had a whole bunch of
new stuff sent to me. One bloke is putting the finishing touches to an
interpreter written in C, and another guy sent me a very very scary
program which, well, does what it says on the tin:



#define print(x) main(){printf(x);return 0;} /* >+++++[<++>-]<[>++++

# +++<-]>++.+.[-]>+++++[<++>-]<.[-][

#

# This polyglot prints "HI" when run in

# Brainfuck, C, COW, Perl, Python, Gammaplex, l33t, and ruby

#

# */

print ("HI\n")

#/*

# @X"H"Xr X"I"Xr RE

# moOMoOMoOMoOMoOMoOMOOmOoMoOMoOmoOMOomoo

# mOoMOOmoOMoOMoOMoOMoOMoOMoOMoOmOoMOomoo

# moOMoOMoOMooMoOMooMOOMOomoomoOMoOMoOMoO

# MoOMoOMOOmOoMoOMoOmoOMOomoomOoMooMOOMOo

# moo 5 0 7 99999998 1 7 0 1 8 9999998 1 91

# ] */



(What's the betting LiveJournal totally messes up the formatting on
that?)
Incidentally, the l33t bit of it is that bunch of numbers near the end.
It's "cheating" to write l33t code in that way, but that's another
story. I'd never heard of polyglots before (a polyglot is a program
which does the same thing in several different programming languages),
but I soon found loads more:



 http://www.nyx.net/~gthompso/poly/polyglot.htm





If you're a geek, enjoy the craziness. If you're not, best to completely ignore all of this and back away slowly...

Wed, Mar. 9th, 2005 12:51 pm (UTC)
icrisisuk

Is that enough to work in C? Aren't there some other includes needed? Been such a long time since I've started off a new project and needed to use printf though :)

Tis crazy nonetheless :s

Wed, Mar. 9th, 2005 02:01 pm (UTC)
electrodruid

Technically the program is missing a #include
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]

Technically the program is missing a #include<stdio.h> or #include<stdio> (I can never remember which one of those is C and which is C++), but you can get away with not putting it in the source assuming you're compiling under *nix (or GCC?) and put the command to do the #include in the makefile.

I haven't tried compiling it in C (though I've run it in l33t and BrainFuck), but I can't see how adding the include right at the beginning would hurt. The pointy brackets would translate to a couple of BrainFuck commands (move forwards 1, then move back 1 in memory), and it would add a NOP or two to the start of the l33t version, but it shouldn't change the output of the program in any of the languages.