Slashdot Log In
Esoteric Programming Languages
Posted by
michael
on Fri Oct 12, 2001 10:07 PM
from the befunge-befuddled-bewildered dept.
from the befunge-befuddled-bewildered dept.
led_belly writes: "I came across this interesting page from the #alt.linux IRC chat room topic (irc.keystreams.com). It is an interesting read for all those who have ever been baffled by why/how some people do things. The Yahoo! Webring listing of similar topics is here."
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Full
Abbreviated
Hidden
Loading... please wait.
My head hurts (Score:3, Interesting)
Re:My head hurts (Score:5, Informative)
55+
put 5 on the stack twice, add the numbers on the stack together, leaving 10, or a newline in ascii.
".dlrow
put "Hello, world." on the stack in reverse, this is so we can pop it off in the proper order.
>:#,_@
very nice code to print out everything on the stack. '>' sets the IP velocity to "east", ':' duplicates the last item on the stack. '_' pops an item off the stack and tests it, if true, set IP to west, if false set it to east. The # skips the next instruction, and the comma prints the character off. So you're testing and printing until there's nothing left on the stack. The '@', finally, exits, which is executed when there's nothing left on the stack.
Makes sense?
Parent
Re:My head hurts (Score:2)
Of course string order can be arbitrary as long as the pattern is parsable by the language.
Re:My head hurts (Score:2, Informative)
If you're really interested, you might look at www.catseye.mb.ca, which is Chris Pressey's (creator of befunge) website.
Re:My head hurts (Score:2, Funny)
> the following is the smallest 'Hello, World' program:
> 55+".dlrow
Ah! So the notorious seineewerasreenigneepacsteN gig was just some source accidentally shipped with the executable, rather than an attempt at obfuscation.
I think perl is shorter (Score:3, Funny)
55+".dlrow
print"Hello, world.\n"
Note that the space after print and final semicolon are optional in perl.
-Ted
Re:My head hurts (Score:2)
"Your comment looks too much like ascii art."
Not a bad description of BrainF*** really.... Anyway check it out on this nice little page: http://www.roesler-ac.de/wolfram/hello.htm
Re:My head hurts (Score:2, Informative)
r:#,_q#:"Hello world!"+55
(wrote it myself
-xmath
Slashcode :) (Score:2, Funny)
INTERCAL (Score:2, Interesting)
Of course, it appears very inefficint - A search for prime numbers less than 65535 took 17 hours while C can handle that in a about half a second.
Re:INTERCAL (Score:5, Informative)
They don't bother, but the language isn't static. There is a multi-threading extension for example. Typical of Intercal it is unlike all other threading packages I know of. It doesn't share data, only the code, all messages must be passed by altering the code (disabling and enabling blocks). Trintercal is base-3, there is also a base-N variant (the base-3 one shares some ops with the Klingon programming language...)
Parent
I thought *I* had it bad enough... (Score:2)
What's wrong with Haskell? (Score:2)
Care to elaborate on what you think is wrong with it?
Re:What's wrong with Haskell? (Score:5, Interesting)
I mean really, in Haskell, "factorial" looks like this:
fact 0 = 1
fact n = n * fact (n - 1)
Write that, and "fact 20" works just fine:
Examples> fact 20
2432902008176640000
Examples>
However, implementing Haskell (or Self) on a von Neumann architecture is non-trivial. Implementing an efficient compiler or interpreter is tres difficil. People get Ph. D. dissertations for that sort of thing. For someone deeply used to C, Haskell and Self are perverse.
To wit:
- In Haskell, nothing changes. Ever. State change is handled by creating a new state from the old one. Semantically clean, but about as far from C as you can get.
- In Self, anything can change at any time. Yes, Virginia, you can redefine "if-then" whenever you feel like it. Change the inheritance hierarchy? No problem! Whoops! I made a cycle in the inheritance hierarchy! No problem! (yes, A can inherit from B and B can inherit from A). Think of C without the reliability that any particular operation (function call, operator, whatever) maps to the same place more than once. This kind of thing gives most C-family compilers hives. It used to be that C++ was perceived as significantly slower than C - I don't see anyone complaining about it anymore, but Haskell and Self are more extreme examples. C++ made it easy to use jump tables. Haskell makes it easy to use recursion, lazy evaluation, and a bunch of other things. Self makes it easy to use dynamic inheritance, multiple inheritance, even cyclical inheritance.
What is most impressive about these kinds of languages is that you can build efficient implementations, without the compromises to the semantics that C (or its derivatives) entails. The fastest FFT library out there is in C, but the C code itself was generated by Haskell code (code that came up with some original optimizations along the way). The Self compiler is the root technology for Java JIT compilers (when Sun killed the Self project, all the compiler people went to work on "virtual machine" compilers). Self was able to hit 50% of the speed of optimized C while maintaining:- Full source-level debugging
- Garbage collection
- Checks for stack and integer overflow
- and the ability to change the "class" of any object at any time (I put class in quotes because Self is an object-oriented language without classes - part of the super-simple semantics)..
In short, there isn't anything wrong with clean linguistic semantics. But essentially every computer sold today is built around the von Neumann architecture, and non-von-Neumann semantics (like that used by Self and Haskell) are non-trivial to implement.Parent
Re:What's wrong with Haskell? (Score:2)
Being an (almost) purely functional programming language, I imagine that writing mathematical programs in it would be a piece of cake, but for anything else that requires states it's a royal pain in the but.
Re:What's wrong with Haskell? (Score:3, Interesting)
For example, consider the expression,
which literally means and, by the way, is equivalent to your (fact 1000). Now, how much space is going to be consumed by its evaluation?Humans can easily see that the expression can be evaluated left to right, treating the operator (*) as strict, and, with the list defined by [1..1000] being built lazily, it is possible to evaluate the expression in constant space:
But is this what Haskell guarantees? Nope. An implementation might also do it like this: In this case the accumulator in foldl builds up a linear chain of thunks, which is evaluated only after the entire list is consumed.You and I can see that the second method is wasteful, but the language definition provides no guidance as to whether a Haskell implementation will choose the second or the more-efficient first. (In fact, GHC would until recently choose the second for this expression.)
Don't get me wrong. Haskell is, without a doubt, my favorite language. It's what I used for my entry [moertel.com] in this year's ICFP Programming Contest [inria.fr], and I consider it the best hope for a truly great mainstream functional programming language. I love Haskell. But its lack of intuitive space-consumption semantics is a serious weakness.
And, regarding your fact example, it doesn't really show off Haskell's semantics as much as its syntax. Why not show the classic Fibonacci Series implementation, which highlights Haskell's non-strict evaluation semantics?
Now, if that isn't a beautiful line of code, I've never seen one. Actually, the FFTW code was generated by code written in O'Caml [fftw.org] not Haskell.Cheers,
Tom
Re:I thought *I* had it bad enough... (Score:2, Interesting)
It's more abstract, so it often requires more thought from your side. But once you've gone there and explored and learned you are rewarded with a new way of viewing the world of computation and what goes on in it. Even if you never use it again, you'll at least know it's there and have a chance to understand why you do the things you do.
But sure, it costs a few hour of pure thought before you see that light. And you don't seem to be interested in bending your mind around something different in this manner.
Ah well. Your loss. Or mine =)
Programming challenge (Score:4, Interesting)
Re:Programming challenge (Score:5, Funny)
Actually, deCSS HAS been written in Brainfuck. See this link on David Touretzky's home page [cmu.edu].
Parent
OS? that outta be ..uhh..quite interesting (Score:2, Funny)
Brainfuck! (Score:4, Funny)
Lameness filter encountered. Post aborted!
Reason: Please use fewer 'junk' characters.
Goddamnit, I just want to post brainfuck source.
Re:Brainfuck! (Score:2)
GCC front-end for brainf*ck (Score:3, Informative)
I'm right in the middle of writing one. Hopefully I'll get free time to go back and work some more on it, after GCC 3.0.2 gets released (in a week).
Why? Because I can, and it's fun.
My Favorite Quote (Score:4, Insightful)
It has to be a toss up between:
(from INTERCAL)The Sieve of Erosthenes test for prime numbers up to 65535 took over seventeen hours on a SPARC--it requires only a half second using C.
and
(from SMETANA) The language has two instructions: "Swap step n with step m", and "Go to step p".
Re:My Favorite Quote (Score:2, Funny)
Re:My Favorite Quote (Score:2)
With the operation translation tables, it looks like trying to write a program in it is similar to brute-force encryption cracking.
It is impressive that the one guy managed to write a "hello world" implementation.
Last time I posted a link to this (Score:3, Informative)
Anyway, here's Brainfuck [muppetlabs.com] Also here [catseye.mb.ca]
It's Turing complete, 8 instructions, and programs look something like this [catseye.mb.ca]
What about var'aq? (Score:4, Informative)
On a more serious note (Score:2, Interesting)
The Beer Page. (Score:5, Informative)
http://core.federated.com/~jim/99/ [federated.com] (mirror)
This is a collection of programs written in over 200 languages designed to print the canonical "99 bottles of beer on the wall" song.
Universal Machine in 371 Bits (Score:5, Interesting)
A mere 371 bits suffice to encode a universal combinator equivalent to ...(a) universal Turing machine:
11100110010100110010110011000010001110010101110010 110 0 100 1 100 1 100 0 010 0 110 0 001
0110010100110010110010100110010110010101110011001
0110111001100110011000101101011010010101110010101
1011001100101001100001000111001100101001001010010
0111000101110011000010001101110011001010011001011
1001100101100101011100110010100011011100110001011
0011011100110010100110011001010011000010001100011
Dan Brumleve [mailto] has a written a combinator interpreter in Perl that may be capable of evaluating Tromp's strange machine.
where's Refine??? (Score:2, Interesting)
Unlambda (Score:2)
Users of unlambda should note that the "i" combinator is strictly speaking unnecessary. For further obfuscation, replace "i" with "skk".
Re:Unlambda (Score:2)
Yeah, that's right. Sorry, misunderstood the bracketing rules.
Incidentally, s and k can be constructed from another combinator (can't remember what it's called right now). Unfortunately it's not a supercombinator, so the graph reduction rules aren't simple to implement.
Unlambda (Score:2, Informative)
I've written an Unlambda interpreter/stepper in Python, available here [uchicago.edu]. It's correct, as far as I know, but extremely slow for lengthy programs.
Incidentally, here's "cat" in Unlambda:
```sii ``s``s``s``s``s``s`ks``s`kk`kc``s``s`ks``s`kk``s`
Loads of fun!
APL (Score:5, Funny)
APL was defined by coding which wasn't particularly inventive but which required a complete keyboard overlay - it didn't use ASCII characters (except in text, as I recall), but rather a mixture of greek symbols and shit the author just plain made up. So in effect you had to match 'objects' to keys on the keyboard, a completely non-intuitive way of typing. Talk about watching your hands while you work....
Unfortunately the college was incredibly gung-ho on APL and thought it would revolutionize coding, so if we wanted to do any serious work we had to do it in APL. This meant that about a dozen of us sat around learning APL so that we could program what might have been (don't really know, but I don't know of any other examples in 1983) the most massively multiplayer Star Trek ship battle game to date (up to 127 players, although the mainframe usually came to a grinding halt when we passed the 70 or 80 player mark). We then passed this program off as a science project, which it was accepted as since no one else could read the damned thing.
Well, I guess it had a use after all....
Max
Re:APL (Score:4, Interesting)
I find it odd how every syntax I have ever seen in a computer language looks ugly and stupid to me, until I become fluent in it, then I won't abide any change after.
Parent
Re:APL (Score:5, Interesting)
APL was a lot more common than you might think. It was the first language to treat matrices as first-class entities, and so was popular for a time among the mathematics set. It was amazingly fast, in part due to its innovative use of lazy evaluation (e.g. if you only wanted a single column of a large matrix, it wouldn't bother computing the rest of it).
A bit of APL lore: Back in the late 1970's, Ken Thompson (one of Unix's creators) spent a summer at UC Berkeley (an event that was rather influential in BSD's development). Just for fun, he wrote an entire APL interpreter -- in one weekend. It was a real pain to work with since it used two-letter codes instead of the APL character set, but other than some of the quad functions (various OS primitives and so on) it was complete.
It's one of the more spectacular feats of programming I've ever heard of.
Parent
Re:APL (Score:2)
For example, take a look at APLus [freshmeat.net], a GPLed language created at Morgan Stanley and derived from APL.
For more information about J (another offshoot of ALP) and APL, take a look at J\APL - the journal of APL [demon.co.uk].
Welcome to SpodNet! (Score:2, Informative)
My bad (Score:2, Funny)
argh... so many languages so little time (Score:5, Insightful)
Of course, you could also approach the task a little more systematically. A possible approach, and this is based purely on learning a language in order to improve one's thinking processes, rather than learning a language based on the marketability improvements possession of such knowledge brings, is to broadly catergorise them along the lines of 'problem solving styles', or 'programming mindsets' that they directly support or encourage.
Assuming no prior knowledge, you could start by learning procedural programming; a very good starting point is C. It is a small, compact language that will help you learn the basics of procedural programming; it's not a difficult language if you stay away, initially, from its more esoteric features like pointers and bitwise operators. Having learnt C, you will have a very solid grounding for learning languages such as JavaScript, C++, and Java because the 'syntactic core' of these languages is very similar.
Another procedural language is COBOL. It is quite a big language in terms of the number of reserved words ('verbs' in COBOL-speak) it offers. However, it is really quite a simple language and provides, as core facilities, tremendous file processing capabilities. In addition, it forces the programmer to be systematic, that is, you need to spell out exactly, and in painstaking detail, what it is you wish to do. In a way, its wordiness is its strength, and it is difficult to produce 'sloppy' code the way it is possible to do in, for example, C.
Next, you could tackle object oriented programming. You could start with either one of the very popular object-oriented languages, C++ and Java. Personally I would start with C++ as it is, I believe, more complex, and thus, more difficult to learn; if you master it, Java will come easy, and the hardest part will be simply to learn its rich set of packages (collections of objects).
Smalltalk is probably one of the purer object-oriented languages, is widely respected in the programming community, and, I should admit that the main reason I included it here is that its the next language on *my* list to learn. I've looked at a couple of Smalltalk code listings and have found it difficult, at first glance, to understand it; that being the case, I look forward to the challenge of learning it !
Now, for a couple of oldies, but goodies: LISP and Prolog. Neither of these has, as far as I'm aware, very significant commercial application, but if you are looking to try some truly 'different' programming approaches, in a bid to extend your thinking processes, then these are it !
LISP, for me, is a truly enjoyable programming experience. I won't pretend to be an expert in it, but by simply spending time with this language I have learnt so much about data structures, programming techniques, and, generally, problem solving techniques. It's a really good tool for 'doodling', that is, quickly whipping up little algorithms and immediately testing them. A definite 'must-learn' language !
Prolog is one I find fascinating. I'm still struggling with it, and although I've developed nothing more than simple database query applications with it, every time I work with it I find myself approaching a 'simple' problem in non-conventional ways, always forced to rethink how something should be done. I would recommend you look at this language to learn how to program in a truly non-procedural way, that is, to work 'with' the help of the language itself, rather than simply writing down commands for the compiler / interpreter to follow.
Finally, on top of these you could add interpretive 'scripting' languages, tools which are aimed more at 'gluing' applications together than being fully-fledged development languages in their own right (I know perl purists will probably scream, claiming this is heresy, but basically it is not so much a development language as a 'super-shell', an all-encompassing environment, almost an 'operating system within an operating system').
Finally, I should stress that, as a programmer, it is not just languages that you should be striving to learn, but to expand your knowledge in general. For example, acquiring general business, management, communication and 'people' skills will make you more aware of the 'real world' in which you must apply your skills.
While the idea of learning other programming languages is to extend your ability to identify and abstract problems, as well as adding to your 'armory' of programming tools, there is no substitute for a good grasp of your problem environment, that is, understanding the nature and type of 'problems' you will be asked to solve. Not every problem necessarily translates into a computer-based solution, hence the importance of also acquiring non-programming skills.
My favorite esoteric language... (Score:2, Interesting)
The Language List (Score:2, Informative)
It won't be complete if I don't include The Language List [unige.ch]. Not only this page contains resources for those esoteric ones, but also other "saner" languages too.
For those of you who want to create programming languages, make sure you read [aw.com] the underlying principles. If you know all these stuffs, your programming language will not be just a toy!
Here's a similar page (Score:2)
Another page on weird languages is here [catseye.mb.ca].
Eubonicode (Score:5, Funny)
sup
{
gimme fibo bitch
a be 1 bitch
b be 1 bitch
putou a bitch
putou b bitch
fibo be fibo widout 2 bitch
slongas (fibo bepimpin 0)
c be a an b bitch
a be b bitch
b be c bitch
putou b bitch
dissin fibo bitch
nomo
}
double backwards for loops (Score:2, Interesting)
for (condition) {
statement1
statement2
statement3
}
the condition is checked, and statement1-3 get executed. Then statement3, 2, 1 get executed followed by the condition being examined. Essentially flow runs down and then *up* the block.
I always thought this was a kinda cool, half baked idea. Useful? No, not really, but cool nonetheless.
Re:thoughts.... (Score:5, Funny)
Parent
Re:thoughts.... (Score:2)
I know perl. My boss even knows perl.
The lame "I-know-Visual-Basic!" interns where I work even know perl.
(Yes, I know I'm an intern, but... I'm not lame)
My point is that tons of people know perl. It's not exactly an obscure language... it's easily in the top 10 most used languages.
Re:wow (Score:2, Insightful)