Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I ran into Rebol and I was wondering about it.

I ran into the following script from here:

 use [feed questions answers][
    feed: load-xml/dom http://stackoverflow.com/feeds/tag/rebol
    questions: map-each entry feed/get-by-tag <entry> [
        find/match entry/get <id> "http://stackoverflow.com/q/"

    answers: make block! length? questions

    foreach question questions [
        question: load-xml/dom join http://stackoverflow.com/feeds/question/ question
        foreach entry next question/get-by-tag <entry> [append answers entry/tree]

    insert clear feed/find-element <entry> answers

All the collection manipulation operations like map-each remind me of JavaScript and C# both of which have functional abilities.

Is Rebol a functional language? Does it support functional programming? Would it classify as a pure functional language (PFL)?

share|improve this question
Here's an answer from the creator of REBOL: Is REBOL a Pure Functional Language? –  Greg Hewgill Feb 21 '13 at 2:15
@GregHewgill Thank you for that resource. I asked this question after a chat in the StackOverflow Rebol chat room (chat.stackoverflow.com/transcript/message/7836761#7836761) . They (We) figured that since there is no information about this on programmers or other sites in StackExchange I should ask it here for future reference. That link is great but it could be expanded and explained here so more users who are not experienced Rebol programmers could understand it. An answer with citations from that article and personal development experience would be appreciated. –  Benjamin Gruenbaum Feb 21 '13 at 2:20
Attributes barely improve Carl's XML scenario: you still have excess metadata (the attribute names) and untyped values (the attribute content). Rebol's implicit metadata provided by the carefully defined of types removes a fair burden on interpretation. With XML, you have to first unlock values, then decipher them (how is a date defined in XML—shall I check the RSS or Atom spec? Can you express the definition in XML?), and then possibly validate them, only then you can evaluate their context. **Intended as a comment in response to [this comment](programmers.stackexchange.com/questions/1 –  user82082 Feb 21 '13 at 10:01

1 Answer 1

up vote 10 down vote accepted

You know the answer is no, but you're asking anyway, because you don't think the existing explanations suffice...?

Not the worst reason to ask a question, gives me an opportunity to yap. :-)

Functional programming in its formal definition is about the idea of designing computational machines whose output is purely "a function of the input to the machine". If you feed the same input into the machine, it will produce the same output. Each input is named explicitly so you know precisely what the dependencies are. A functional programming language enforces this rigorously.

In Rebol you can write things like:

foo: function [value [integer!]] [
    return either now/date = 20-Feb-2013 [
        value + 1
    ] [

There's a function that returns its integer input on every day but today, where you get the value plus one. Hence an invisible dependency on the date which is not formally specified as an argument to the function. The sort of thing that makes Haskell people and software formalists like myself scream bloody murder. Imperative programming is good for some things but in my worldview, it is carelessly overused. Lots of good research has been done on better methods that apparently haven't been marketed well enough to the kids of today.

I could say Rebol is not functional programming, Q.E.D. and just stop writing here. But you might respond "Fork, you run around like a rabid weasel telling people to look at Rebol, and Douglas Crockford kind of brings it up when he gets a chance also, and you think imperative programming is overused. So there must be a little more to the story?"

Well, yes sort of.

If you spend any time in computer science you learn about things like Turing Tarpits and computability and these sort of principles of equivalences where "if you can connect X to Y then Z will be true". And just as you can write a Haskell implementation in C, and then restrict yourself to only using C calls mapped into the Haskell library, you might claim you're doing "functional programming" and be technically correct.

So if you wanted to say Rebol can be bent to functional programming styles, you might be a pessimist and say "well it's no better than pretending you're doing C when you're actually using such a confined subset of the language that you're using Haskell by proxy". The trick up Rebol's sleeve is how easily you slip from one "dialecting" paradigm to another. Writing a little domain-specific-language that happens to be functional is so easy and natural that it doesn't feel like you're twisting your language out of joint to do it.

Many people mix up Rebol with its most common dialect (the DO dialect) and think "that's what Rebol is". But Rebol's "essence" is more like XML, it's a data exchange format that coincidentally (okay, not coincidentally) has hyper-optimized code focusing on processing it in some certain ways out of the box. For a good background reading on how it beats the pants off XML, see Was XML flawed from the Start by Carl Sassenrath of AmigaOS (and now Rebol) fame.

share|improve this answer
That's a great answer but I think the "Was XML flawed from the start" article is pretty bad. First, he uses poor XML (everything he represents with nesting can be represented with attributes). Second, languages are represented by a tree like structure that resembles xml. When you parse a sentence you get a parse tree, it's not fair to compare the XML which contains the grammer information with the string that is domain specific. Thanks for the answer :) –  Benjamin Gruenbaum Feb 21 '13 at 5:31
I am a Rebol n00b and as you have said, I too am thinking as of now that Rebol is what the DO dialect is. Hope to break out of this mindset. :-) –  KK. Feb 21 '13 at 5:45
@BenjaminGruenbaum If I could edit Carl's website, believe me, I would. :-) –  HostileFork Feb 21 '13 at 5:58
@BenjaminGruenbaum But not all languages can freely manipulate that tree structure. Rebol is very lisp-y in that regard. –  Izkata Jan 17 at 0:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.