Slashdot Mirror


Quadrilingual Crazy Programming

mtve writes: "Have you ever seen source code that is valid on four languages: Perl, C, Befunge, and BrainF*ck? During last Perlgolf season famous Perl hacker Jérôme Quelin submit such inconceivable masterpiece and now he published expanded explanation of his solution. Caution: that text can hurt your mental health. Play Perlgolf!"

194 comments

  1. Not for me... by PepsiProgrammer · · Score: 5, Funny

    I have enough trouble making my code compile in ONE language, 4 at the same time is a bit much

    --
    "The United States has no right, no desire, and no intention to impose our form of government on anyone else." - Bush 05
    1. Re:Not for me... by Anonymous Coward · · Score: 0
      Two languages isn't too bad (if it's not a difficult program). Four is pushing it!
      #include <stdio.h>
      #define def /*
      sub
      #*/
      main() {
      return printf("Hello World!\n");
      }

      main();
    2. Re:Not for me... by larry+bagina · · Score: 4, Funny
      I have enough trouble making my code compile in ONE language, 4 at the same time is a bit much

      Hi Linus. I didn't know you posted to Slashdot!

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    3. Re:Not for me... by (outer-limits) · · Score: 1

      Look, if you are really going to try and make the shortest program, why not use a real language that is designed for brevity, and use APL. A beautiful little language that has yet to be beaten in this area.

      --

      Microsoft - Where would you like to go today, Maybe Jail?

    4. Re:Not for me... by Anonymous Coward · · Score: 0

      Except Linus is Finnish, so it should be BeerProgrammer

    5. Re:Not for me... by Lozzer · · Score: 1

      Knowing Perl very slightly it wouldn't surprise me if there is an Inline::APL or Language::APL lurking somewhere.

      --
      Special Relativity: The person in the other queue thinks yours is moving faster.
  2. crazy by thatnerdguy · · Score: 0

    that's just plain crazy. Why would you want to do that?

    --
    I saw the Sign, and it opened up my eyes
  3. If your brain is fucked, code in 4 languages? by kiwipeso · · Score: 0, Troll

    What sort of lunatic wants code that compiles in 4 languages, anyway?
    Isn't it bad enough that microsoft creates gigabytes of code bloat, let alone all the geeks who are now going to try multi-lingual code?

    --
    - Kaos games and encryption systems developer
    1. Re:If your brain is fucked, code in 4 languages? by Anonymous Coward · · Score: 0

      Asking such a question invites the statement "If you have to ask why, you are not a part of the intended audience".

    2. Re:If your brain is fucked, code in 4 languages? by Cenam · · Score: 0

      answering in such a way makes you a faciest..

      --

      The Truth: There is no string:)
    3. Re:If your brain is fucked, code in 4 languages? by (outer-limits) · · Score: 1

      I think a better answer is, if you aren't interested, that's fine, don't bother with it.

      --

      Microsoft - Where would you like to go today, Maybe Jail?

    4. Re:If your brain is fucked, code in 4 languages? by kiwipeso · · Score: 1

      Cenam is right, If you don't want people asking questions that don't fit with your opinion, that is facist.

      I'm sick and tired of the slashdot party members always saying stupid things like : "If you ask a question which does not fit our opinion, you do not belong here". Have you ever considered that there are always 2 sides to every story?
      [the part which is relevant to this story]
      I asked a fair and legitimate question, why the hell would you want to code something so that it compiles in 4 languages ?
      I speak 3 languages and can programme in 20, yet I see no reason for multilingual coding. Personally, I believe this is a great waste of time which is only reported because Slashdot loves stupid geek tricks.
      Perhaps we should get more 'news that matters' instead of stuff that splatters.

      This is hardly worth any note, it goes against any notion of efficient coding and practicality. However, it seems that there are those of you who believe they are better qualified to judge programming skill.
      I ask you if you can reprogram an operating system, create an internet protocol or even design a successful encryption system. Because then you will be qualified to judge me as an equal, not a slashdot party member.

      --
      - Kaos games and encryption systems developer
    5. Re:If your brain is fucked, code in 4 languages? by shobadobs · · Score: 1

      And what, some might ask, sort a lunatic would want to climb a mountain? Or fly in a heavier-than-air craft? Or fly the atlantic? Or break the speed of sound? Or land on the moon? Why launch the first satellite into space? Why, some might ask, post to Slashdot? Or read trolling posts modded down to zero?

    6. Re:If your brain is fucked, code in 4 languages? by Anonymous Coward · · Score: 0
      makes you a faciest..

      is that someone who judges people by what their faces look like?

    7. Re:If your brain is fucked, code in 4 languages? by Hellkitten · · Score: 1

      Why do people climb Mount Everest? Go to the North/South Pole?

      Too see if they can!

      You are right it's not practical, efficient or in any way useful. And a great waste of time. And if anybody tried this at work they should get fired. But it's fun!

      In my opinion the amount of fun you are able to have with programming is an indication of your skill in programming. If you don't have fun you may still be good, but you'll never be great. Simply because you'll go for the easiest solution every time. You may be good at programming things that have been done a 1000 times before but when it comes to creative new solutions you'll loose

      And it isn't facist to critisize someones opinion (which is what both of you does). Its facism when you prevent the other part from expressing his opinion

      --
      - We are the slashdot. Resistance is futile. Prepare to be moderated -
    8. Re:If your brain is fucked, code in 4 languages? by kiwipeso · · Score: 1

      Going to antartica is useful, you can see how much global warming has affected the glaciers. It's a place where my country has the most useful science experiments done.
      Wrong. it's not a question of liking what you do to be good at it.
      I've worked as a waiter and at a supermarket before, I was great at the job but I didn't like it.
      I never stop people from expressing there opionion, and I only meta moderate fairly. However, you aren't being modded down for expressing a point of view in contrast to the opionion of the slashdot herd.

      --
      - Kaos games and encryption systems developer
    9. Re:If your brain is fucked, code in 4 languages? by kiwipeso · · Score: 1

      I've climbed several mountains: Mt Victoria, Mt Tongariro to name the famous ones. I've flown in a plane almost every winter to queensland.
      I have no need, nor inclination to fly over the atlantic. Here's a clue: what country has the kiwi as a national bird?

      All of those are far more important than posting messages on a severely biased website or bothering to read them.

      --
      - Kaos games and encryption systems developer
  4. omg... by Danse · · Score: 5, Funny

    He should seek professional help. Soon. That's right up there with self-mutilation.

    --
    It's not enough to bash in heads, you've got to bash in minds. - Captain Hammer
    1. Re:omg... by glwtta · · Score: 1
      That's right up there with self-mutilation.

      Not nearly as much fun though.

      --
      sic transit gloria mundi
    2. Re:omg... by SkulkCU · · Score: 4, Funny


      He should seek professional help. Soon.

      at the bottom of the page:

      the referees were so impressed by my efforts (one of them told me that I deserve a book. And a straightjacket. And a padded room [...] they decided to grant me a book for my efforts.

      --
      .sig last updated Jan. 14, 2000
    3. Re:omg... by Jimmy_B · · Score: 1
      He should seek professional help. Soon. That's right up there with self-mutilation.
      The first thought that jumped to my mind was "can I add Generic Pre-Processor to the list of languages this works in?". I'm drawn to this task like a fly into a zapper. Please, someone write a +5 insightful essay about why I shouldn't do this...before it's too late.
    4. Re:omg... by red_dragon · · Score: 4, Insightful
      Please, someone write a +5 insightful essay about why I shouldn't do this...before it's too late.

      I'm afraid that before someone writes such an essay, someone else will have written a +5 Funny post on why you *should* do it. Sorry.

      --
      In Soviet Russia, Jesus asks: "What Would You Do?"
    5. Re:omg... by thogard · · Score: 1

      It could be worse. What would happen if Larry Wall decided this type of thing was a "good thing[tm]"?

      Remember he has only won IOCCC twice so far.

  5. Wow, but slight dilemma by lkaos · · Score: 4, Funny

    Now this is exactly why I am proud to be a programmer. Screw Picaso and DaVinci, this is what real art is all about.

    This presents an interesting dilemma though. What Emacs mode do I use to look at the code??? perl-mode, c-mode, I dunno. Fontifying just complicates it even more.

    At any rate, this shit is going up in my cube. If they should this in a frame, I would buy it and hang it in my house.

    --
    int func(int a);
    func((b += 3, b));
    1. Re:Wow, but slight dilemma by Anonymous Coward · · Score: 0

      Screw Picaso and DaVinci, this is what real art is all about.

      That's really fucking sad that you can't appreciate things that you may not be as passionate about.

      Or that you're hellbent on "ranking" art. What is "real art"?

    2. Re:Wow, but slight dilemma by Anonymous Coward · · Score: 0

      The problem is that you would even use emacs.

      Use vi and there is no confusion.

    3. Re:Wow, but slight dilemma by lkaos · · Score: 2

      No, it was partly a joke and partly serious.

      I think there is just as much beauty in code as in many works of art.

      Mozart is famous for his table top pieces. These are pieces where two muscians sat on opposite ends of a table with a piece of sheet music in the middle. The first piece played the piece right side up, and the second played the piece upside down. His genius was being able to create with such incredible restrictions.

      Solving a problem in multiple languages represents a similiar ability. Of course, it wasn't a terribly complicated problem, but the basic idea is the same.

      --
      int func(int a);
      func((b += 3, b));
    4. Re:Wow, but slight dilemma by Happy+Monkey · · Score: 1

      Name the file "insane.program", and make symbolic links to it with the various extensions. Then emacs will automatically use the right mode.

      --
      __
      Do ya feel happy-go-lucky, punk?
    5. Re:Wow, but slight dilemma by egreB · · Score: 2, Informative

      What Emacs mode do I use to look at the code???

      No problem, just use vi(m)! In vim, you can use several colour-coding styles in one document. Just needs a bit of tweaking, that's all.

    6. Re:Wow, but slight dilemma by Doug+Neal · · Score: 0

      Use the multiple major modes for Emacs system! It's a bit of a bitch to get working, but it works nicely...

  6. "Polyglot" did that 10 years ago! by Lardmonster · · Score: 4, Informative

    http://www-2.cs.cmu.edu/afs/cs/user/chogan/Web/pol yglot

    Cobol, Pascal, Fortran, C, Postscript, shellscript, 8086

    --
    The more advanced the technology, the more open it is to primitive attack
    1. Re:"Polyglot" did that 10 years ago! by littlerubberfeet · · Score: 1

      Yo, the link doesn't work. I would be curious to see your decalingual program, can you fix it? deca=ten??

      --
      Sig (appended to the end of comments you post, 120 chars)
    2. Re:"Polyglot" did that 10 years ago! by Anonymous Coward · · Score: 0

      The link works; you just have to remove the space character that slashcode throws in there. Try this:

      http://www-2.cs.cmu.edu/afs/cs/user/chogan/Web/pol yglot

    3. Re:"Polyglot" did that 10 years ago! by Anonymous Coward · · Score: 1, Informative
    4. Re:"Polyglot" did that 10 years ago! by Lardmonster · · Score: 1

      > just remove the space

      Yeah - that's really queer. There was no space in the textarea widget, but it was there in the preview.

      So I typed it again, and again the space appeared.

      Maybe something to do with Opera??

      --
      The more advanced the technology, the more open it is to primitive attack
    5. Re:"Polyglot" did that 10 years ago! by Anonymous Coward · · Score: 0

      Thats a slashcode "feature". 50 characters without a space and - bam - slashcode puts one in for you. It's smart enough to leave the inside of an HREF property alone though, so if you code your link into an actual link you can save people the trouble of copy+paste+remove-the-space.

      (that "feature" is to prevent page-widening. though there are still many ways around it for the determined crapflooder)

    6. Re:"Polyglot" did that 10 years ago! by Iamthefallen · · Score: 1

      It's slashdot's way of circumventing the page widening bug, force a space into long unbroken textstrings.

      --
      Wax-Museum Fire Results In Hundreds Of New Danny DeVito Statues
    7. Re:"Polyglot" did that 10 years ago! by egreB · · Score: 3, Interesting

      No. No, no. These people should have been shot. THIS IS NOT NORMAL! Go find a shrink!

      On the other hand, it's really, really cool.. How about a contest? Write a program that does a particular thing (dunno, calculate something (like Pi)), and should be compilable/runnable in a lot of languages. You get points from a jury from how good the program solved the task, times number of languages it is written in. Could be quite fun. (-8

  7. LOL, the tradition continues by Anonymous Coward · · Score: 0

    I used to work as a research assistant at the Artificial Intelligence Projects lab at Carnegie-Mellon University. When it was late at night, and we were all bored, we would try to put together C programs that were illegible but yet would still compile. That was lots of fun, and it had lots of people scratching their heads, all night long.

    1. Re:LOL, the tradition continues by qslack · · Score: 1

      When it was late at night, and we were all bored, we would try to put together C programs that were illegible but yet would still compile. That was lots of fun, and it had lots of people scratching their heads, all night long.

      Are you sure you didn't work for Microsoft?

  8. Whoa... by tcd004 · · Score: 0, Insightful

    Apply these same principles to a virus and you'd have a pretty dangerous bit of code.

    Meet the White House Whores

    tcd004

    1. Re:Whoa... by Foogle · · Score: 2

      The above comment doesn't make any sense at all. I think that much is clear to everyone.

    2. Re:Whoa... by TheOnlyCoolTim · · Score: 2

      Uhm.... the virus writer could compile his virus even if all he could get was a Brainfuck compiler?

      Nope.... Once it's compiled, it's all CPU instructions anyway...

      Tim

      --
      Omnia vestra castrorum habetur nobis.
    3. Re:Whoa... by larry+bagina · · Score: 1

      Really? you didn't hear aboutthe new IE buffer overflow error. It's only exploitable if you send 7-bit source code and then run brainfuck, perl, C, or befunge on the code.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    4. Re:Whoa... by Anonymous Coward · · Score: 0

      lol! I know! I was like 'what is this guy talking about? like people are going to compile the programs on their machines?'

    5. Re:Whoa... by _Knots · · Score: 1

      While *this* isn't helpful - as C/perl/brainfuck/etc. are high-level languages - one certainly could (try to) design quadralingual machine code so that all of a sudden there's a BSI-style virus that runs on x86/PPC/m68k etc. Granted it probably wouldn't work *well*, but it'd be interesting to see even bilingual assembler.

      =)

      -Knots

      --
      Anarchy$ dd if=/dev/random of=~/.signature bs=120 count=1
  9. Shouldn't this tell us something? by solistus · · Score: 1, Insightful

    The whole purpose behind having so many languages is for different specialized needs. There used to be PASCAL for scientists, FORTRAN for mathematicians, BASIC for hobbyists or new programmers... each server a purpose, and was not made to do anything more.
    Nowadays, Perl and PHP are almost identical, Obj C, C, and C++ are very similar, Java bears many similarities to Obj C and C++ as well, and most of the new 'Basic' environments like REALBasic and VisualBasic are near clones as well.
    All of today's popular coding environments could be condensed to Java, Objective C, Perl, and some form of BASIC. This point is exemplified nicely by the fact that a bit of code can be done to compile in 4 languages... the syntax is already quite close, having so many minor variants is just messy.

    1. Re:Shouldn't this tell us something? by NETHED · · Score: 1

      interesting Freudian Slip,
      each server
      Either that, or its a typo...

      --
      --sig fault--
    2. Re:Shouldn't this tell us something? by Papineau · · Score: 2

      Have you read the article?

      This is an excerpt of the Befunge part:
      > 2ep 1ep :0ep :0fp '0+, v > 2eg 1- : 2ep !#v_ 4eg : fg 1- \ fp 4eg fg #v _ 3eg ! 3ep 4eg 1+ 4ep v
      v pe30 < a


      And this is an excerpt of the BrainF*ck part (a language with 8 instructions):
      >+>+<<<<<-]>>,--------- ---

      And keep in mind that the actual program is much longer than that.

      I wish I could include more, but the lameness filter won't allow me to...

      So much for nearly identical languages...

    3. Re:Shouldn't this tell us something? by sydneyfong · · Score: 2, Informative

      Perl and PHP is different. Sure they may have that dollar sign as variables, and they have C style flow control, but that's where the similarity ends.

      PHP borrows its syntax from various other languages, including Perl, but also C, Java, Javascript, etc

      --
      Don't quote me on this.
    4. Re:Shouldn't this tell us something? by joto · · Score: 5, Informative
      This must be some of the worst bullshit I've heard about programming languages in quite some time.

      Did you even read the article. I'll challenge you to find languages with much more different syntax from C/Perl than Befunge-98 and Brainfuck!

      There used to be PASCAL for scientists, FORTRAN for mathematicians, BASIC for hobbyists or new programmers...

      Actually, Pascal was for education, (and systems-programming (once you added some much-needed non-standard extensions)). Fortran was for scientists (mathmaticians would probably be happier with Lisp, or something like Mathematica, only scientists needs actual numbers).

      Obj C, C, and C++ are very similar

      No, they are not. Well, ObjC and C are the most similar of the three, but modern C++ has little in common with idiomatic C. Java looks very similar to Objective C (which pretty much tells you how different C and Objective C are).

      ...and most of the new 'Basic' environments like REALBasic and VisualBasic are near clones as well.

      Maybe. My experience with VB didn't leave me thinking it was anything close to Java (or any other of the above mentioned languages). However, VB.NET is supposed to be so.

      All of today's popular coding environments could be condensed to Java, Objective C, Perl, and some form of BASIC.

      Well, if by popularity, you mean lots of users, or lots of jobs available, I am very confused why Objective C is on the list (although OS X should give it a boost). On the other hand, if you mean liked by it's users, you will hardly find any language not fitting that description. By any account, you need C++ on the list.

      But yes, I agree that such a list can be made, and mine would be: C, C++, Java, VB, Perl, COBOL, PL/SQL, HTML/XML, ASP/JSP/PHP, SAS, Python, Matlab, Fortran, Common Lisp, mostly in that order, but maybe COBOL even more to the front of the list.

      Anyway, there is no way to avoid C, C++ and or Java on the top of the list. (Which maybe was your point, but anyone taking more than a cursory glance at those languages will find that they are in fact very different from each other. They look similar on the surface, but are just as different as Pascal, Fortran and Basic).

    5. Re:Shouldn't this tell us something? by rmohr02 · · Score: 1

      But then BF is sort of an anomaly among computer languages.

    6. Re:Shouldn't this tell us something? by Phroggy · · Score: 1

      My experience with VB didn't leave me thinking it was anything close to Java

      The impression I got from VB was that it was sort of a bastardized combination of HyperCard, JavaScript and Q-BASIC all wrapped into one - the GUI concepts from HyperCard, the concept of objects and properties from JavaScript, and the syntax and vocabulary from Q-BASIC.

      Note that the HyperTalk language is actually designed to be used in that kind of GUI environment, and is probably the highest-level language I've ever heard of (that's not to say it doesn't have shortcomings, like the lack of intangible objects, the awkwardness of storing arrays as text, inability to handle strings over 32k or containing nulls, and other issues I've forgotten about). Q-BASIC is absolutely not designed for this sort of thing at all, and is really not appropriate for working with objects. And JavaScript is a PITA all the way around.

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    7. Re:Shouldn't this tell us something? by copyconstructor · · Score: 2, Interesting

      Did you even read the article. I'll challenge you to find languages with much more different syntax from C/Perl than Befunge-98 and Brainfuck!

      Malbolge. See these notes on writing hello, world in malbolge:

      this malbolge program generates:

      HEllO WORld

      it's not perfect - i ignored case to make the problem simpler (completion left as an exercise for the reader - it should be possible).

      when i finally got a decent algorithm worked out (i've been playing around with this for the best part of a month - see below), it took a few hours to generate the program on a 500mhz nt box with 96mb memory (the code was written in lisp - i started with clisp on suse linux and then changed to corman lisp on nt) (more numbers here).

      incidentally, i've come to hate malbolge.


    8. Re:Shouldn't this tell us something? by majiCk · · Score: 1

      But yes, I agree that such a list can be made, and mine would be: C, C++, Java, VB, Perl, COBOL, PL/SQL, HTML/XML, ASP/JSP/PHP, SAS, Python, Matlab, Fortran, Common Lisp, mostly in that order, but maybe COBOL even more to the front of the list.

      Functional languages are sorely under-represented in your list. It ought to include at least some dialect of ML (SML or O'Caml) and at least one pure functional language (e.g. Haskell). Really, though, it is a silly academic exercise to try to form a list that comprehensively includes every ``useful'' language, as definitions of useful vary widely. (In fact, that's why there are so many languages in the first place, and in some sense, why it's justifiable to have so many languages.)

      Case in point: your list leans heavily towards the imperative and object-oriented styles of programming (C, C++, Java, COBOL, Perl, Python, Fortran), and also towards web technologies and scripting languages (HTML/XML, ASP/JSP/PHP (which are really three different things anyhow), Perl, Python, Java (arguably)). (It's also arguable that you include some languages which are decidedly less useful -- e.g. VB, SAS -- but i only mention that to point out that these things are all a matter of taste; let's not get into a holy war on everyone's favorite programming language! :)

    9. Re:Shouldn't this tell us something? by joto · · Score: 2
      Yup, that is true. And it was intended. Functional languages are also sorely underrepresented in the real world. Luckily, I don't have too much experience with it (the real world), but it seems like they use the weirdest, clunkiest, and most inelegant languages there (VB being one of the nicer, in fact).

      Also, web-technologies are important in the real-world. To the point where I am almost surely convinced that one day, 90% of us will all work on web-infrastructure for each other, while the remaining 10% will take care of the rest of society.

      Also, I was not trying to put together a list of useful languages. If a was, then my list would look entirely different. I was trying to list "popular" languages, for a suitable definition of "popular". I am very aware of the fact that just because something is "popular" and "much used" doesn't make it useful. And I am aware of functional languages, and do consider some of them to be useful. That doesn't make them "popular" though.

      It might be that I was trying too much to remove my own bias from academia, and smart, well-educated programmers, but I don't really think so. Much of the real world revolves around the silliest programming languages.

    10. Re:Shouldn't this tell us something? by thogard · · Score: 1

      VB's syntax is very close to the microware os/9 basic that was written before the 68000 was finished (in part by one of the guys who was designing it)

    11. Re:Shouldn't this tell us something? by big_hairy_mama · · Score: 2

      Have you read the article?

      [parent's parent] All of today's popular coding environments could be condensed to...

      BrainFuck and Befunge are designed to be different, and more importantly, unintelligable. There are a million different languages out there (for example, Lisp looks nothing like Java) but the popular ones (not counting Lisp) all stem from either C or Basic.

  10. Obligatory polyglot programming link by Anonymous Coward · · Score: 3, Informative
  11. How about 7 languages? by Zifter · · Score: 5, Informative
    What about the famous Polyglot?

    It runs/compiles under 7 languages: ANSI COBOL, ISO Pascal, ANSI Fortran, ANSI C, PostScript, Shell Script, and 8086 machine language!!! Check it out, it rocks.

    1. Re:How about 7 languages? by Anonymous Coward · · Score: 0

      Yeah, the submitter is clearly a kid. He could have done some research to compensate but nope, he chose to demonstrate his cluelessness in front 1/2 million slashdot readers. Pathetic.

    2. Re:How about 7 languages? by Internet+Ninja · · Score: 4, Informative

      The offical 'home' of polyglot is http://ideology.com.au/polyglot/.
      One of the authors was until recently my boss. While you're there have a good laugh and Corporate Hoore and Geocaching.

      BTW: polyglot has been mentioned here before.

    3. Re:How about 7 languages? by ironfroggy · · Score: 1

      yes, of course, he didnt do the absolute best in the world, and that makes him nothing. rethink yourself.

    4. Re:How about 7 languages? by Hydrogenoid · · Score: 1

      But writing in Befunge or Brainfuck only is enough a challenge already...

  12. Code includes preprocessor directives by Sancho · · Score: 4, Interesting

    He uses the fact that # is a comment in Perl VERY frequently to use #defines etc that will allow C to act like Perl. Interesting solution, although I question whether the use of such preprocessor directives REALLY counts as making cross-compatible code. Then again, I nitpick the difference between preprocessor and compiler, so...

    1. Re:Code includes preprocessor directives by interiot · · Score: 2

      The preprocessor is always available in C, it's run by default by the compiler. This almost seems like nitpicking that he's using the assembly generator too much for his C code.

    2. Re:Code includes preprocessor directives by Anonymous Coward · · Score: 0

      And for that matter, one has to ask what the value of competing to write the shortest, least maintainable code is.

  13. Portable by Myshkin · · Score: 2, Funny

    Well, I guess that is one way to keep people from saying that your implementation isn't portable enough.

  14. simpler version by damiam · · Score: 4, Funny
    This program is valid in C, C++, python, perl, basic, and a few other languages, and it also accomplishes the rare feat of printing its own source code without reading from a file:





    Note that, even though this is standard C, gcc won't compile it, complaining about the lack of a "main" function.

    --
    It's hard to be religious when certain people are never incinerated by bolts of lightning.
    1. Re:simpler version by DEBEDb · · Score: 1

      Yes, most people get to this realization
      at some point. :)

      I don't thikn the moderators are there,
      or else it'd be 5, funny :)

      --

      Considered harmful.
    2. Re:simpler version by Anonymous Coward · · Score: 0

      Quines are fun.

      Here's one you might find interesting: a quine which, rather than printing out its source code, prints out its own executable. and, interestingly, it is itself an executable. put this into a file in unix and chmod +x it:

      #!/bin/cat

      I am not aware of any non-null quine which has a smaller executable.

    3. Re:simpler version by Anonymous Coward · · Score: 0
    4. Re:simpler version by Anonymous Coward · · Score: 0

      interesting..
      i'm sure 'they' would count this as cheating though i don't think it is technically that as #!/bin/cat refers to interpreter rather than command to read the source file and print it.

    5. Re:simpler version by Anonymous Coward · · Score: 0

      Actually, an empty translation unit is a syntax error in C (gcc -ansi -pedantic will confirm this). And the complaint about the lack of a main function can be turned off with -c.

  15. It's neat, but... by meta-monkey · · Score: 5, Insightful

    First off, this guy obviously has much better kung-fu than I do...I've never even heard of BrainFuck or Befunge...but I think he kinda cheated on the last two languages. He just hid the code for Brainfuck and Befunge in perl and C comments, so they wouldn't interfere with each other. Now, the perl/C part is really neat, because he used C #defines to translate various Perl characters into C, so the Perl interpreter and C compiler are reading and understanding the exact same code...that's cool. But the B & B code just gets ignored by the Perl interpreter and C compiler because of comments, so this amounts to writing 3 seperate programs (one in BrainFuck, one in Befunge, and one that's bi in C and Perl) and then putting them all in the same file with intstructions as to which compiler/interpreter reads which part, as opposed to writing one piece of code that's meaningful in all 4 languages. I'd call this bilingual, not quadlingual.

    --
    We don't have a state-run media we have a media-run state.
    1. Re:It's neat, but... by Anonymous Coward · · Score: 0

      Are you sure you aren't a bit jealous?

      Sure sounds like it *tihi* ;*)

      Btw, what's the difference of using comment blocks as opposed to preprocessor commands? They're both equally part of the language. Preprocessor hacks may be cooler, but it's the comment-blocks that makes it at all possible.

      Now, a generic translator from Perl into this monster would be great *hydre* :->

    2. Re:It's neat, but... by Xerithane · · Score: 2

      I see your point, but if you read through the entire explanation he talks about the problems with the embedding of the befunge and brainfuck scripts.

      #include can't be used because i is a valid instruction, so you have to use #undef. The reason why this is quadlingual is because you are able to run it through any of the 4 compilers/interpreters and get the same result. I could see the Perl and C working together without much difficulty, but when I read Brainfuck I was completely stumped how he would manage to do that. I think it's a very elegant solution. If by elegance, I mean insane and beautiful in a sick and twisted way. Just because the code gets ignored by the C/Perl interpreter doesn't make it any less bilingual. The code also gets ignored by the aidbf and b98 interpreters as well.

      --
      Dacels Jewelers can't be trusted.
    3. Re:It's neat, but... by Anonymous Coward · · Score: 0

      Here's how to tell if this is really
      quadrilingual code:

      Modify the program a bit.
      You only need to make one mod to change
      the C and Perl versions. But..
      Do you need to make separate modifications
      for BrainFuck and Befunge to work correctly?
      If so, then it's not really quadrilingual.

    4. Re:It's neat, but... by Anonymous Coward · · Score: 0

      But what if the change I make uses C-specific or Perl-specific features? Then I have to make separate modifications to make it work with both.

  16. Too Bad... by susano_otter · · Score: 5, Funny
    Have you ever seen source code that is valid on four languages: Perl, C, Befunge, and BrainF*ck? During last Perlgolf season famous Perl hacker Jérôme Quelin submit such inconceivable masterpiece and now he published expanded explanation of his solution. Caution: that text can hurt your mental health.

    Ironically, the article isn't even valid in one language.

    --

    Any sufficiently well-organized community is indistinguishable from Government.

    1. Re:Too Bad... by larry+bagina · · Score: 1

      a little for everybody is a lot for nobody

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

  17. not quite as cool as it sounds. by neurojab · · Score: 2, Insightful

    Yeah, it's great to have a piece of code that compiles for four languages, but what's the point if you're just using pre-processor and compiler tricks to get the compiler to look at a different section of the same file? In this file, if I change the problem-solving logic slightly, I have to change it in several places. What would be truly cool (and incredibly difficult), in my opinion, would be to completely eliminate redundant logic.

    1. Re:not quite as cool as it sounds. by csguy314 · · Score: 2, Funny

      In this file, if I change the problem-solving logic slightly, I have to change it in several places. What would be truly cool (and incredibly difficult), in my opinion, would be to completely eliminate redundant logic.

      What?!? Eliminate redundant logic? That would put microsoft out of business!
      MacOS ~ Windows
      Java ~ C#
      Diablo ~ Dungeon Siege

      --
      This is left as an exercise for the reader.
    2. Re:not quite as cool as it sounds. by Sancho · · Score: 2

      While funny, I gotta call you on that last one. If games with similar premises/engines were not out there, the market would be incredibly smaller. For example, we'd only have Doom.....Ok, so we allow upgrades. We'd have Q3. We'd never have gotten the beauty that is halflife :)

    3. Re:not quite as cool as it sounds. by Forkenhoppen · · Score: 2

      Okay, I agree with you, eliminating redundant parts would be cool, but where do you draw the line? I mean, #defines will only get you so far. Are you suggesting that one attempt to restrict themself to languages that map more easily to one another? Or are you instead suggesting a more obtuse approach, like writing an interpreter in each language, and then using that to run an inlined copy of the actual program? (The inlined program being written in yet another language, of course.)

      My point? Just because you've seen the slight of hand behind the magic doesn't make the feat any less impressive. I mean seriously, how'd you expect him to accomplish this? : )

  18. Befunge? by Quixote · · Score: 4, Funny
    From the article (yes, I read it, and yes, my jaw won't close now):
    Befunge is, ... a topological language on a 2D cartesian Lahey space.

    Holy mackerel! I am in love. I've found the object of my dreams.

    1. Re:Befunge? by Thing+1 · · Score: 1
      Holy mackerel! I am in love. I've found the object of my dreams.

      "Hol[e]y rusted metal, Batman!"

      Yes, I'm offtopic again. Mod me down.

      Actually, Befunge looks like a lot more work than traditional procedural languages. What actual benefits does it offer? (Apart from "I can think in a language that causes your brain pain!")

      --
      I feel fantastic, and I'm still alive.
    2. Re:Befunge? by Anonymous Coward · · Score: 0

      There was an old (1993) DOS graphicalish thingy kinda like this, only easier to work with called "corelife," in the "core wars" genre.

      You can still find it at places like:
      http://riverbbs.net/files/output/620.Html
      http://www.filelibrary.com/Contents/DOS/84/14.html

      "Visual 2D virus coding program, Watch your viruses come to Life and crush the opposition"

      It was fun for a while, kinda wish I'd paid for it, but ah well.

    3. Re:Befunge? by Anonymous Coward · · Score: 0

      I can think in a language that causes your brain pain!

      No, no. You're thinking about Brainfuck, not Befunge.

    4. Re:Befunge? by PurpleBob · · Score: 4, Insightful

      Benefits? It's really fun to program in.

      Useful benefits? Does it need any?

      --
      Win dain a lotica, en vai tu ri silota
  19. huh by Anonymous Coward · · Score: 0

    Man, just go buy the book you need....all this for a book :)

  20. Multilingual is the norm... by KFury · · Score: 4, Interesting

    ...on th web, anyhow. All the time we deal with several languages, burying one inside another so they'll make sense as they go through successive levels of parsing.

    For example, every day I write SQL that is buried in PHP libraries which extracts more PHP that in turn has HTML and Javascript in them.

    For another example of the crazyness, check this simple example. Now if you look at the source, you'll notice the end part of that A-tag was: .');"> For those of you who are counting, that's SIX 'enders' in three syntax languages just to form a simple alert box.

    . - English syntax
    ' - Javascript string syntax
    ) - Javascript function syntax
    ; - Javascript instruction syntax
    " - HTML attribute syntax
    > - XML (err, HTML, whichever) tag syntax

    And that's not even a particularly hairy example. That's just client-side and wetware-side parsing.

    1. Re:Multilingual is the norm... by Phroggy · · Score: 1

      Yeah, I wrote some Perl code that uses a database to print out HTML containing JavaScript that uses some of the information in the database to dynamically set certain form values according to the values of other form elements. In other words, dynamically-generated JavaScript that dynamically generates HTML. Debugging that was hell. I feel your pain.

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    2. Re:Multilingual is the norm... by Tablizer · · Score: 2

      I think web programming for B-to-B and intranets needs an overhaul. We need an HTTP-friendly GUI protocol (like SCGUI, plug plug).

      HTML+DOM+JS is great for e-brochures, but crappy and messy for complex business forms.

      Even if you don't like SCGUI, at least promote something along the same lines. Trying to make web pages act like VB/Delphi/Powerbuilder is a royal micromanaging pain that is almost as as much joy as using Brianf*ck.

      BTW, if you use ColdFusion, it has two language modes/syntaxes. Thus, you may end up using Coldfusion 1, Coldfusion 2, SQL, HTML, and JavaScript. 5 languages to get the job done.

    3. Re:Multilingual is the norm... by Anonymous Coward · · Score: 0

      Note that the semicolon is completely superfluous in this example.

    4. Re:Multilingual is the norm... by KFury · · Score: 1

      So are the doublequotes around the HREF parameter, and the period, but who's counting? ;-)

    5. Re:Multilingual is the norm... by CvD · · Score: 1
      Yeah, kinda reminds me of my last compiler construction class. God, that was hell. Anyways, what happened was that we were using basically 4 different languages and compilers to get one thing done:
      1. Write simple code in a language that the course instructors had thought up themselves: SL (Simple Language)
      2. Load an interpreter which was written using the UU_AG attribute grammar system, which in turn is written in Haskell (you first had to load UU_AG in Hugs98 (a Haskell interpreter).
      3. The interpreter would produce SSM code.
      4. You could then load the SSM code in a SSM java program, where you could see the result of your SL program.


      A variation on this didn't produce SSM code, but LaTeX, which you would have to run through the latex 'compiler', and finally be able to view it with xdvi or something like it.

      Ugh!
  21. Didn't Game Boy teach you anything? by Anonymous Coward · · Score: 0

    Four computer languages in one code block, no problem.

    But proper use of one human language? Look out!

    The correct term is tetralingual, not quadrilingual.

    1. Re:Didn't Game Boy teach you anything? by cscx · · Score: 1

      I think Sega gets the honors on that one.

      "Someone set us up the bomb!"

  22. I'm glad I'm already a programmer... by yorgasor · · Score: 4, Funny

    Wow, if I saw that a few years ago, I would've been so scared I would've never touched another programming language again! Slashdot, please think of the children before you post things like that.

    --
    Looking for a computer support specialist for your small business? Check out
    1. Re:I'm glad I'm already a programmer... by Xerithane · · Score: 2

      Damn, inverse for me. The first code I looked at from other people was the obfuscated code.

      Just seeing people do some beautiful and crazy twists of logic inspired me on so many levels. I still remember the first piece of obfuscated code I got my hands on was this great Hello World program. Another one was a console animation that displayed an ASCII movie of a McDonalds delivery truck running a cow over then throwing the carcass into the back of the truck and driving off.

      Sadly enough, those two programs inspired me to code more than anything to date. More sad, I've never entered an obfuscated code contest. I find myself more intruiged by finding elegant twists of logic that look pretty, and functional :)

      --
      Dacels Jewelers can't be trusted.
  23. Wishlist by hickmott · · Score: 1

    Now if only he could come up with an version that did APL, too.

  24. No, you're the one on drugs by yerricde · · Score: 4, Informative

    The correct term is tetralingual, not quadrilingual.

    "Quadri" comes from Latin. "Lingual" is from Latin. "Tetra" comes from Greek. In general, a compound will be all-Greek or all-Latin, with the occasional exception such as "homosexual".

    Quadrilingual is used in 1,210 pages, whereas tetralingual is used in only 14.

    I assume your Game Boy reference alluded to Tetris®. In that case, the existence of Quadra negates any "by default, go with the name of the block game" rule. In other words, you need to lay off the drugs ;-)

    --
    Will I retire or break 10K?
  25. I multi-program.... by xtremex · · Score: 2, Insightful

    When I get into my "programming language learning" mode, when I learn a new procedure in one language, I try to make the same program in at leats 7 others....sure, it sounds lame, but it really sticks in my head..

    --
    If you're not a Liberal in your 20's, then you have no heart.If you're still a Liberal in your 30's you have no brain.
  26. just curious by Permission+Denied · · Score: 5, Interesting
    #define ARGV argv

    Why not just do this instead:

    main (int argc, char *ARGV[])

    Also, another minor quip: the C program is not valid C in either C89 or C99. It's not valid C89 because it uses '//' for a comment, and it's not valid C99 since it introduces main() without declaring the return type. C89 defaults to int if you don't declare the type (both for functions and variables, which can be fun), whereas this behaviour is undefined in C99. Normally, I don't follow the anal-retentive lingual purists, but I think this situation calls for this.

    But yeah, this is pretty cool.

    1. Re:just curious by Dr.+Awktagon · · Score: 2

      Yeah, many people don't think about that. When I write C code I always write:

      main (int ac, char *av[])
      Some weird habit I picked up but it drives people nuts.. "hey, is that legal in C?", etc.
    2. Re:just curious by Xerithane · · Score: 2

      My biggest pet peeve of all:
      int main( int argc, char** argv);

      My first CS teacher did that, and I objected and had to pull the reference. I see char** argv all the time, and can never figure out why it bothers me but it does. It's similar to misspelling definately[sic] -- no reason, just irritating.

      --
      Dacels Jewelers can't be trusted.
    3. Re:just curious by Skiboo · · Score: 1

      It may be because the square brackets are among the few valid characters in brainfuck, and writing it that way would change things. (I'm no expert, and [] probably does nothing in brainfuck if the byte at the pointer is 0).

    4. Re:just curious by Skiboo · · Score: 1

      In fact, read the article, and that explains it perfectly. (I was wrong)

  27. Polyglot is just a hello world by upper · · Score: 1

    OK, so it actualy prints "hello polyglots", but still, all it does is output a fixed string. Quelin's program does an actual computation, admittedly a relatively minor one.

    Moreover, all of polyglot's languages are languages that people have actually used to write real code. I'm not saying they are all reasonable languages, but one can at least semi-plausibly claim that they were written to be useful. Befunge and BrainF*ck are both toy languages written expressly to be perverse in some way (Befunge to be uncompilable, and BrainF*ck to be absurdly minimalist.)

    That said, I was disappointed at how separate the languages' code blocks were in Quilen's program. C and perl share most of the same code, but there are three completely separate code blocks and the work is mostly in getting each language to ignore the others' code. It's probably the only way it can be done, but it's really a short quadralingual wrapper around three separate programs, one of which is bilingual.

    1. Re:Polyglot is just a hello world by Anonymous Coward · · Score: 0

      Duno, the way the 'v' cut right through the brainfuck was kinda 'cute' ;)

  28. 5 languages by Henry+V+.009 · · Score: 2

    5 languages...I'll bet they forgot to count C++

  29. i know it's silly... by tps12 · · Score: 0, Troll
    Okay, obviously this is just a joke. Those are all toy languages that haven't been used in production level applications.

    But think about what this means for more serious programming.

    Imagine a program that runs in C++, MySQL, and Apache. This could be a new era in cross-platform development!

    Programmers: please study this closely, and we will finally allow Linux to compete.

    --

    Karma: Good (despite my invention of the Karma: sig)
    1. Re:i know it's silly... by skribble · · Score: 2, Funny

      Huh?

      Of your list only C++ is a language. However one could right an Apache module in C++ that accesses a MySQL database... err wait actually that been done!

      --
      --- Nothing To See Here ---
    2. Re:i know it's silly... by lkaos · · Score: 3, Funny

      Don't mind him, he's just a troll...

      Gees, maybe I need to stop reading /. ... I'm starting to recognize the trolls by username.

      --
      int func(int a);
      func((b += 3, b));
  30. This article is a gem. by theolein · · Score: 3, Interesting

    I sort of think it's things like this that make slashdot so worth reading. These gems of pure geekness. +5 to /.

    I discovered BrainFuck by chance two years ago and immediately got lost in two nights of trying to get my first quine to compile in the interactive JavaScript BF interpreter. For some perverse reason it is fun. It brings out the little boy in me who used to build model airplanes out of toothpicks: Little unimportant things that become something when you stick them together. perhaps this would also be a possible real world language for programming Nanobots, whose processors wouldn't yet cope with a P4 strapped to their backs.

  31. How about dialects? by The+Monster · · Score: 2
    I have enough trouble making my code compile in ONE language
    Closest I come to this is making a shell script that can run equally well in SCO and AIX. That hurts my brain enough right there.
    --

    [100% ISO 646 Compliant]
    SVM, ERGO MONSTRO.

  32. 4 Languages? Whoopty doo. by Clay+Mitchell · · Score: 3, Funny

    Try to get a website to look the same in every web browser.

    That's an impressive feat?

    Netscape 4.X = Worst browser ever!

    1. Re:4 Languages? Whoopty doo. by rufusdufus · · Score: 1, Offtopic

      Netscape 4 rules! I am writing cross-browser dhtml, and ns 4 has one thing going it for it: it is fast! IE in any version has fewer bugs, and is fast enough. But NS 6.2 is THE WORST. It has so many bugs coding for it is like walking through a mine-field. And, to top that off, its 10 times slower at many DHTML tasks than version 4 was.

    2. Re:4 Languages? Whoopty doo. by Phroggy · · Score: 2

      Exactly! Just try writing cross-platform JavaScript! There seems to be little pattern to which browsers support window.innerWidth vs. which support document.body.clientWidth, and since the alternative browsers usually munge their USER_AGENT strings you can't rely on that to be meaningful. Sure, you can support Netscape and MSIE, but can you tell me which one of those properties will work and which one will abort with an error in Opera, iCab, OmniWeb and Konqueror? I wound up with this, which I think seems to work universally, mostly, kinda:

      if(!isNaN(parseInt(window.innerWidth))) {
      pageWidth=parseInt(window.innerWidth);
      } else {
      if(!isNaN(parseInt(document.body.clientWidth))) {
      pageWidth=parseInt(document.body.clientWidth);
      } else {
      pageWidth=700;
      }
      }


      Falling back on a default if neither works.

      Does someone have a better suggestion?

      --
      $x='S24;r)>63/* h@<5+oZ)32"5cz';$me='phroggy'x$];
      $x=~y+ -xz+\0-Tx+;print$_^chop$me for split'',$x;
    3. Re:4 Languages? Whoopty doo. by Arandir · · Score: 2

      This is why the web is fucked, and will remain fucked. Ignoring the fact that it's impossible, here is no valid reason for a web page to look the same in all browsers.

      Yes, I said "no valid reason", and I mean it. I know some of you will give "presenting a uniform corporate image" as a reason. But it still won't be valid unless the corporate image you want to present is "style over substance".

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    4. Re:4 Languages? Whoopty doo. by showboat · · Score: 1

      No, it's possible. Just use a big png and an imap.... unless you need to count video cards and bit depths.

    5. Re:4 Languages? Whoopty doo. by rajinder · · Score: 1

      It's not always a case of 'looking the same in all browsers'. Problems arise normally from getting the site to *not* look fugly in as many possible configurations as possible. (browser/screen res/OS/etc)

      That is more important (IMO) than getting all the different browsers to display the page the same.

      It's not as simple as saying 'style over substance' (those corporate whores! how dare they care about showing consistency and clean, efficient design!) ... next thing you know you'll start saying that slashdot with all of it's fancy images for story categories is just trying to emphasize style over substance.....wait a minute. :)

      --
      - It is simple to make something complex, and complex to make it simple
    6. Re:4 Languages? Whoopty doo. by Arandir · · Score: 3, Funny

      "We detect that you're using the Konqzilla browser. Since by using Konqzilla our site may appear 'fugly', we have no other alternative but to deny you entrance."

      "Your browser identifies itself as Internet Explorer 5.5 running on Windows XP. But it's really Konqzilla. I don't know why you want to see our site using Konqzilla. Please use a modern browser to view this site. Now go away."

      "It appears that you're running Internet Explorer 5.5 running on Windows XP. And it's the real thing this time. But you're running it under WineX. Do you think we're stupid. We don't want you to view our site. Now bugger off!"

      "Ah, a genuine Internet Explorer 5.5 running on a genuine Windows XP! Congratulations. But you have your monitor temperature set to 5000! Our site was designed for 9300. It will look fugly without it. Please correct the situation before returning"

      --
      A Government Is a Body of People, Usually Notably Ungoverned
  33. And they call ME crazy... by mfarah · · Score: 2

    My colleagues at work think *I* am nuts because I refuse to use notepad or Visual Café's builtin-text editor to edit .java source files, preferring instead a much more powerful older DOS-based text editor (TSE). They're gonna suffer a heart attack when they see this.

    --
    "Trust me - I know what I'm doing."
    - Sledge Hammer
  34. If I had written it by Anonymous Coward · · Score: 0

    #define ARGH argh argh argh

  35. where's my O'Reilly book? by WebMasterJoe · · Score: 2, Troll

    I don't know if there's an official term for it, but I often write a function in one language that writes code for another language - for example, using PHP or Perl to write javascript. I've even gone so far as to use PHP to write a SQL statement which in turn is used to determine what will go in a Javascript function that writes HTML code. The example below is rather pointless, but I have come across real situations where it is beneficial to use that many languages together.

    function hello() {
    $q = "select * from helloworld where id=1;";
    $connect = pg_pconnect("dbname=hw user=webber password=dipsh*t");
    $cursor = pg_exec($connect, $query);
    $r = pg_fetch_row($cur,0);
    echo "<script>\n";
    echo "function do_it() {\n\tdocument.write(\"".$r[0]."\");\n}\n";
    echo "</script>";
    }

    That's three "real" languages and one markup language. And if you think that was crazy, think about this - I just had to write that in HTML in a slashdot posting textbox!

    My next goal is to make the javascript write out HTML for parameters in a Java applet. And, the whole PHP page is going to be written by a C program exectuted by a cron job that was set up via a perl script (webmin!) That's eight different languages - perl -> bash (I think) -> C -> PHP -> SQL and Javascript -> HTML -> Java. Sadly, I don't think that's nearly as crazy as the quadrilingual program. I need to learn Brainf*ck.

    --
    I really hate signatures, but go to my website.
    1. Re:where's my O'Reilly book? by Tablizer · · Score: 1

      (quote) user=webber password=dipsh*t"); (end quote)

      Hey, that is MY password!

      You copied it, you dipsh*t hacker you! FBI cometh.

    2. Re:where's my O'Reilly book? by Anonymous Coward · · Score: 0

      In the end, that's all any program
      in any language does...
      it's written in one language (C, Perl, whatever)
      and writes out in another (english).

    3. Re:where's my O'Reilly book? by Anonymous Coward · · Score: 0

      You're such a stud.

    4. Re:where's my O'Reilly book? by BenjyD · · Score: 1

      I'm having to do the same thing, except using C++ to write Prolog programs. Now that is a strange language. Recursion after recursion after recursion...

  36. It depends on the file extension you give it... by RyanFenton · · Score: 2


    If you rename the file to quadlang.c or quadlang.cpp, then open it as c/c++. If you rename it to quadland.cgi, open it as perl, and so on. That's assuming you're going to rename it before sending it to any compiler.

    Of course, that's just another problem with multiple languages per source file - figuring precisely how to name the file.

    :^)

    Ryan Fenton

  37. Even more interesting if .... by 3seas · · Score: 2

    only it was in human to human language......oh wait we have some that can't understand their own language and those languages which are universal like money and the hand/finger gesture of giving someone the bird.

    How may languages is that understood in?

    1. Re:Even more interesting if .... by rajinder · · Score: 2, Insightful

      oh wait we have some that can't understand their own language and those languages which are universal like money and the hand/finger gesture of giving someone the bird.

      Slight nit-pick ... in JSL (Japanese Sign Language) the 'birdie' is used quite often, and does not have any negative connotation to it when used in the context of that language.

      However, it can be assumed that a fair number of people in the Japanese speaking (and signing) world have had to communicate with the western world, and they know that perticular hand guesture may not be taken well :)

      --
      - It is simple to make something complex, and complex to make it simple
  38. Genetic algorithm by Tablizer · · Score: 2

    A genetic algorithm might be a great way to produce such examples. You may be able to speed it up by having lists of common language commands to use as mutation material.

    Turn it into a screen-saver ala Seti style, and maybe /. can set the world record......if there is such a record.

  39. Esoteric language challenge by The+Pim · · Score: 3
    If you want to test your knowledge of esoteric programming languages, try this problem from the 2002 MIT Mystery Hunt.

    I was happy to solve 1840, even though I immediately recognized the language, because it is poorly specified and there is no interpreter. But that was nothing compared with my teammates, who solved 1183 with nothing but the problem and pure reason.

    --

    The evaluation of an action as 'practical' . . . depends on what it is that one wishes to practice.
    1. Re:Esoteric language challenge by Anonymous Coward · · Score: 0

      holy hell, wtf are they, sm queens? my brain just blew up. thanks man...

  40. not valid c by Anonymous Coward · · Score: 1, Interesting

    He tries to declare an array with a size returned by a function call. In C, array sizes have to be static (that's why C++ has "new" for arrays). He's writing to illegal locations in memory.

    1. Re:not valid c by Anonymous Coward · · Score: 0

      Actually this is no longer true. As of ANSI C99
      standard you can use dynamic values to create
      arrays ;)

  41. Big deal. by NoMoreNicksLeft · · Score: 2

    I've been working on truly bilingual code for a few years now. Machine code. That will run on both PPC and x86. Now, if only the damn elf header didn't cause one cpu to reject it, even though the binary is valid...

    Same with x86 machine code that is clever enough to determine if it's running inside of linux or windows... even though the code itself is valid, the elf vs. .EXE headers aren't even close. Oh well.

  42. Editors, edit! by czth · · Score: 4, Insightful
    mtve writes: "Have you ever seen source code that is valid on four languages: Perl, C, Befunge, and BrainF*ck? During the last Perlgolf season famous Perl hacker Jérôme Quelin submitted one such inconceivable masterpiece and now he has published an expanded explanation of his solution. Caution: that text can hurt your mental health. Play Perlgolf!"

    Why is it that Slashdot's editors can't fix the mistakes in the above and many, many other articles before posting? Either they don't notice the errors (in which case they should be sacked and replaced), or it's that important to post the article a minute earlier (highly unlikely), or somehow the original wording is considered "sacred" and Not To Be Changed (stupid if true). Come on here. Does the error rate on the front page have to be so high?

    The only reason I'm not blaming the submitter (mtve) as well is because it's possible English is not his first language (or even his second). If it is, shame on him too. We all deserve better.

    (Oh yes, for those clueless enough to say "What errors", I threw in the required changes in bold. Also, isn't one Perlgolf link enough?)

    czth

    1. Re:Editors, edit! by showboat · · Score: 1

      What errors? During the last season the guy submitted on thing; now he has published an expanded thing.

  43. Esperanto... by xRizen · · Score: 0, Offtopic

    ... is the name of the language, and I fail to see what it has to do with this article.

  44. SLASH, BABY!! by Anonymous Coward · · Score: 0

    More slash, bitches! Everyone loves slash!

  45. ac karma whoring by Anonymous Coward · · Score: 1, Informative

    did you come up with by yourself or did you rip it from ioccc?

  46. My goodness by Succa · · Score: 1

    This is practically art. Just reading this guy's solution was amazing, the way he reasoned about each step, and just the IDEA of it. Absolutely unbelievable.

    However, I'd like to see more difficult languages. Has anyone done LISP? Has anyone even ATTEMPTED Haskell or ML?

  47. Now THIS is what slashdot is all about.! by Performer+Guy · · Score: 3

    This would be worth a subscription if there was more of it (not more of the same but more in a similar vein of geekiness). REAL geek news! None of that Kayz crap or friking freshmen case mods with melted plastic and neon bulbs. Let them come and stare in awe as the fail to grok the code because the wasted their lives drilling holes in their PC case.

    1. Re:Now THIS is what slashdot is all about.! by Performer+Guy · · Score: 2

      I think my 'y' key is acting up. I'll have a few more beers and get back to you on that.

  48. Perl Coders by Tremul · · Score: 1

    This just shows what coding Perl will do to you.

    --

    "Can't sleep. Clowns will eat me"
  49. Polyglots... by fungus · · Score: 1

    check the following page for source code that can be used in many languages...

    polyglots list

  50. A Brainfuck Interpreter in PHP by the_danielsan · · Score: 4, Informative

    I wrote a Brainfuck interpreter in PHP a while ago which also includes a short introduction to the language.

    By the way, Brainfuck was initially named "Mental Masturbation", but the Author Oliver Müller then stuck to a less offensive name :)

  51. Re:Now.. by Anonymous Coward · · Score: 0

    with obsolete warnings that result mainly in confusion and code bloat this is only a good thing.
    i'm not going to write my expressions like a+(b*c) so why should i write a&(bc) either?

  52. Re:too navy or not to navy? by Anonymous Coward · · Score: 0

    Go for it. Make sure you are in shape though, nothing sucks more than being unprepared for your initial training it will demotivate you. Trust me, I know, I went to usmc boot camp and I learned the hard way. Now I'm in college and I'm planning to do the Marine Corps PLC program where they actually guarantee you a shot at flight school if you sign up under the aviation option.

  53. Something for all compilers by DarkHelmet · · Score: 2
    That story was okay. I have a program I've made that works in just about anything out there. I really wasn't sure about sharing the source code with you people on slashdot, but why not...

    -- Begin Code snippit beneath this line ---



    -- End Code snippit above this line ---

    Try it, it should work. You see, the key to getting it to work for everything out there is to compromise what the program can do.

    Fortunately, since the goal was to make the program run in as many languages as possible, I can make the code as minimalistic as possible, too!

    By the way, the code I mentioned above is property of myself. This code cannot be used in programs without my expressed permission. Doing so would be a violation of the terms in which I am distributing the above code.

    Licensing agreements are available. Contact me for more info.

    --
    /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
  54. Cease and Desist Warning. by DarkHelmet · · Score: 3, Funny
    http://slashdot.org/comments.pl?sid=32469&cid=3504 205

    Poster named Damiam, you are in violation of the terms of my license. You are hereby asked to cease and desist from distributing your code, and will be contacted shortly with a cease and desist letter saying the same message.

    If you do not pay royalties to me, I shall strip you of all your Karma, and fart in your general direction. :)

    By the way, if you claim prior art, this is not true. I came up with this program back in 1984 when I was banging enter on the keyboard of my Commodore Pet computer and realized that I was programming it without my knowledge.

    --
    /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
  55. BrainFuck Nanobots? by DarkHelmet · · Score: 3, Funny
    Can you seriously imagine on the Nightly News them doing a story about how BrainFuck programmed NanoBots kill AIDS cells, and kill off tumors?

    News Reporter: So how'd you do it?
    Guy: Well, the nanotech was already there. I just wrote a small program in BrainFuck in order to hunt down the virus.

    Well, at least censorship would go out the window the same time we cure World Disease.

    --
    /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
  56. Anyone here ever written any serious web scripts? by robert345 · · Score: 1

    This is pretty clever, but it's not that cool; I do similar stuff all the time. I have to mix VBScript and JavaScript and then there is the question of getting stuff to work on different browsers. You can easily call each different browser a new language because they never work the same.

  57. Program in infinity number of languages. by Anonymous Coward · · Score: 0

    From Brainf*ck The Null Program If a program is a series of instructions, then the null program is a series of zero instructions. The null program has some interesting properties, not the least of which being that it's simultaneously written in many languages and many paradigms...

  58. Not for MS, though ... by Taco+Cowboy · · Score: 2



    According to Microsoft, their "Visual Studio" will do 5 languages at the same time !

    --
    Muchas Gracias, Señor Edward Snowden !
  59. Esoteric programming languages by npsimons · · Score: 1
    It compiles in four different languages. Pffft. That's nothing. I'm not saying I could do better, but I know where I can find them.


    Also, for your masochistic programming pleasure, you may be interested in the polyglot list and the quine page.


    For even more zany programming fun, check out Esoteric topics in Computer Programming. Oh, and my own pathetic attempt at a similar page, Miscreant Programming Languages.

  60. Re:Moderators: stop smoking so much! by pacman+on+prozac · · Score: 1

    so you want it to have read:

    "During last Perlgolf season famous Perl hacker Jerome Quelin submit such inconceivable masterpiece and now he published expanded explanation of his solution"

    And that got you a +4 insightful? -1 gibberish more like.

  61. Re:more sleep by pacman+on+prozac · · Score: 1

    doh...thats what it did read...I stand over-caffined and underslept...sorry, maybe I should apply for an editors job.