Strange Brouhaha

Friday, January 13, 2006

Programming Languages To Learn

Intercal has been on my list for a while now, and I finally--in a fit of madness--downloaded C-INTERCAL and set about trying it out. My favorite "features" of Intercal:


  • The compiler intentionally inserts errors at random. You never know if your code will actually run, or if it will need to be recompiled.


  • The compiler forces you to be polite...but not TOO polite. If your ratio of PLEASE to DO is too high, you're forced to recompile.


  • If you need to enter a number, you spell out the digits. 4092 is FOUR OH NINE TWO. ESR's implementation also accepts NINER for NINE, in case you're in an airplane.


  • Output is in Roman numerals.



Here's the first Intercal program I wrote. I admit, it's trivial; I just wanted to make sure I was able to get the compiler to work.


PLEASE NOTE THAT THIS PROGRAM IS TRIVIAL
DO .392 <- #0$#100
DO READ OUT .392
DO GIVE UP


It prints out 5136. You get that because the big money operator ($) interleaves the bits of 0 (0000000000000000) with the bits of 100 (0000000001100100) to get...well, I'm not writing out all 32 bits, but it's 5136 in decimal. That gets shoved into the 16-bit variable .1, and it all gets printed as a Roman numeral. (I obscured it up a little bit after that.)

We're not even getting into character output.

ESR's Intercal page also has some links to other languages that I've been meaning to mess with, like Brainfuck (here's a complete program, supposedly: ,+[-.,+] ).

Also of interest is Whitespace, a language whose elements consist of various combinations of whitespace (spaces, tabs and newlines). The only reason I'm not jumping all over it is because I don't really want to install Haskell (another language, required to compile the interpreter).

It's just an amusing little pastime.

0 Comments:

Post a Comment

<< Home