?

Log in

No account? Create an account

Painful to read programming languages - Journal of Omnifarious

Jun. 9th, 2004

03:43 pm - Painful to read programming languages

Previous Entry Share Next Entry

Some programming languages are created as intellectual puzzles and jokes. In particular, this programming language recently captured my attention again. I've known about it for years, but someone recently mentioned that it had been ported to .NET

There's a whole archive of programs out there written in this language. Here's a small example program to multiply two numbers. It has helpful comments.

+++++>+++++++
                                                                                 
Tape on entry:  on leaving:
 v      v
ab00            c000 where c=a*b
                                                                                 
<[->[->+>+<<]>[-<+>]<<]    (add repeatedly)
>>>[-<<<+>>>]<<<           (result to right place)

A quine is a program that prints itself out. This is much harder than it seems like it would be, and clever quines are amusing (for programmers) to read.

Here is a very long quine in the aformentioned programming language:

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

The language is basically a very straightforward implementation of the basic mathematical model of a computer created by Alan Turing. As such, the programming language is capable of expressing any computation that you can express in any programming language. All computers are turing machines.

Current Mood: [mood icon] amused

Comments:

[User Picture]
From:hozed
Date:June 9th, 2004 04:53 pm (UTC)
(Link)
aaiiiEEEEEEEEEEE

My brain hurts!!!

This is definitely one appropriately named language.

Now, can you write a program that does the same thing in both perl and brainfuck?
(Reply) (Thread)
[User Picture]
From:omnifarious
Date:June 9th, 2004 05:33 pm (UTC)
(Link)

I believe that's been done already actually. The second language has the advantage that it's specified to ignore any of the 8 characters that are not part of its instruction set.

(Reply) (Parent) (Thread)
From:rosencrantz319
Date:June 10th, 2004 04:21 am (UTC)
(Link)
(Reply) (Thread)
[User Picture]
From:omnifarious
Date:June 10th, 2004 06:04 am (UTC)
(Link)

It's not really good for a lot. It's really hard to program in. It's mostly good for making programmers' heads hurt. The quine example with all the '+' signs is actually a very inelegant program. This quine, for example, is much more elegant and interesting.

(Reply) (Parent) (Thread)