Esoteric .NET Language Challenge

Esoteric .NET Language Challenge

  • Comments 11

It's Friday afternoon, I'm bored with "conventional languages" such as C# and VB, so let's play a game! I've got four different code snippets from somewhat esoteric languages. They've only one thing in common - they can all be compiled with a .NET compiler into intermediate language. Can you guess a) what language each is, and b) what the snippets actually do?

I'll reveal the answers and the compilers in a couple of days if there's anything nobody can get! In ascending order of difficulty, then:

Snippet 1

 <%@ page language="#omitted#" %>
<script runat="server">
OBJECT.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 FONT-SIZE PIC S9(9) COMP-5.
END OBJECT.
</script>
<% PERFORM VARYING FONT-SIZE FROM 1 BY 1 UNTIL FONT-SIZE > 7 %>
<font size="<%=FONT-SIZE%>">Nostalgia with a disturbingly novel twist...</font> <br>
<% END-PERFORM. %>

This is fairly straightforward, I think.

Snippet 2

 ! This is the main program
Program MultiDog
use System
use VirtualDog
type (Dog) :: d
type (Greyhound) :: g
type (Labrador) :: l
call d%RollOver()
call g%RollOver()
call l%RollOver()
end program MultiDog

A little bit less obvious in terms of the language, but its meaning is pretty clear.

Snippet 3

 <%@ page language="#omitted#" %>
<script runat="server">
 
   </script>
 
   <html>
   <body>
      <H1>Can you guess what I do?</H1>
      <form runat=server>
         <asp:Button id="Pressme" Text="Press Me" runat="server" OnClick="Reverse" />
      </form>;/form>
   </body>
   </html>

In this one, the language is a giveaway but it takes more skill to work out what the code is doing!

Snippet 4

   400 constant bar

   : foo \ Performs a mystery operation
     2 
     begin
       over over mod 0= 0=
       rot rot dup >r
       over 2 / > 0=
       rot and r> swap
     while
       1+
     repeat
     over 2 / >
   ;
 
   : main \ Entry point
     ."Values up to " bar . .": "
     limit 1 do
             i foo
             if i . space then
     loop
   ;

This is much harder to get right, I think...

Let the challenge commence :-)

  • Hi,

    I think number 1) is COBOL, number 2) might be Smalltalk, no idea about the other two though :)

    I havent programmed in either, but I tried googling on the syntax to see what was brought back.
  • 1. COBOL, 3. APL, 4. FORTH

    I think...
  • 1. COBOL 2. FORTRAN 3. APL 4. FORTH
  • Educated Guesses
    1) Cobol
    Sets a the font size to 9pt

    2) SETL
    instantiates 3 classes in VirtualDog and makes them roll over :)

    3) APL
    Reverses the Array Args

    4) Forth
    Err ... Some kinda loop :)
  • Some of you are doing well at guessing the languages - but still a little way to go in terms of the operations performed by each!
  • There's a bug in the Fo(u)rth snippet. The "2 2" line should be just "2". Also if you aren't worried about integer overflow (and you shouldn't be, given the algorithm) you can speed up the search significantly by changing the loop condition. I also added comments as hints for other puzzle-solvers.

    : foo \ a
    2 begin \ a b
    2dup mod 0= 0= -rot \ mod a b
    2dup dup * > 0= \ mod a b stop
    rot and \ a b f
    while 1+ repeat
    dup * < ; \ result

    \ note: untested; there may still be bugs
  • Thanks Raymond :-) If I've edited that duplicate 2 out once, I've edited it out ten times. There's some funny bug in the HTML editor, I think, as it just wouldn't stick. Hope it's now fixed for good.
  • Woohoo,

    1) COBOL : Which is nice. Displays "Nostalgia with a disturbingly novel twist..." in increasing font sizes from 5 to 7. I think 5 is the staring point

    2) Isn't smalltalk, the comments look wrong, and making 3 different types of dog, inherited from the dog class rollover. Where's the "beg for biscuit" method? :) Now the only thing I can remember using ! for comments is Fortran90, so Lahey's fortran.net?

    3) Is APL, and maybe reverses the args on the query string?

    4) Forth. And I only just remember the Jupiter Ace, as the only consumer computer in the early eighties which used forth instead of basic :) Caculating mystery operation on all values up to 400. Aggh, stack manipulation
  • Somebody should implement INTERCAL.NET
  • Looks like others beat me to it. The only one I know is number 2. It's Fortran. Though I never use FORTRAN or Fortran professionally it's the first "real" language I used so I've been keeping an eye on it for years. Maybe someday I'll get a project that requires heavy duty calculations and I'll have an excuse to install my copy of Fortran.NET.
  • Sadly, raymond spoiled my answer on the 4. "Forth" entry. Looks loke 1. COBOL, 2. FORTRAN, and 3. some perversion of Prolog. Wish I had time to do the rest of the challenge. Thanks for the mental break though.

    Tom
Page 1 of 1 (11 items)