
Red Programming Language - Immortalin
http://www.red-lang.org
======
networked
The thing I find the most fascinating about Rebol and Red is their respective
type (runtime tag?) systems, which are unusual for modern dynamically typed
languages; today you'd expect such things as URLs and file paths to be
represented in the language as either plain old strings or classes, not their
own basic types. You can see Rebol's and Red's type systems at
[http://i.imgur.com/0XFuRmS.png](http://i.imgur.com/0XFuRmS.png) (this is a
slide from a presentation deck on Red's about page) and
[http://www.rebol.com/docs/core23/rebolcore-16.html](http://www.rebol.com/docs/core23/rebolcore-16.html)
respectively.

~~~
riffraff
I think the word you're looking for is "literals", i.e. rebol has URL literals
(cause there isn't much difference in many modern languages between "basic
types" and classes).

I always found that fascinating too.

~~~
networked
You are probably right. The distinct literal notation for the datatypes (which
is what the Rebol manual calls them) is their biggest draw for me.

Although the sequence! and the object! datatype in Rebol are not subtypes of
each other they have similar semantics (pass by reference, explicit copying,
mutation performed in place by built-in functions like sort).

Objects in Rebol and their literal representation are actually pretty
interesting, too. Douglas Crockford cites Rebol as one of the inspirations for
JSON, and you can see why when you look at an example:

    
    
        >> example: make object! [
            var1: 10
            var2: var1 + 10
            var3: now/time
            set-time: does [var3: now/time]
            calculate: func [value] [
                var1: value
                var2: value + 10
            ]
        ]
    
        >> print mold/all example ; mold/all serializes data
        #[object! [
            var1: 10
            var2: 20
            var3: 21:42:34
            set-time: #[function! [][var3: now/time]]
             calculate: #[function! [value][
                var1: value 
                var2: value + 10
            ]]
        ]]
    
    

I haven't read much Rebol application code but as far as I understand
serializing objects and storing them on disk as plain text is the norm for
configuration and persistence.

~~~
laumars
After reading up a little more about Red on Wikipedia, I came across the term
"Homoiconicity"[1] which I hadn't encountered before (though the concept
itself wasn't new to me, I wasn't aware there was a name for it). What
homoiconicity refers to is where the language syntax mirrors the metadata
markup - just as you described here with JSON / Javascript. In fact it's a
common feature of LISP and it's descendants, Scheme obviously being one. So
it's not that surprising that Javascript also inherited homoiconicity from
Scheme.

The other interesting thing about my research on Wikipedia was the tangent it
took me on. I started reading about other other homoiconicity languages that I
hadn't heard of; and that lad me to a page about the programming language
"Curl"[2] (not related to the cURL HTTP client that most Linux / UNIX
sysadmins would be well versed in). Curl is very interesting as it merges the
different stacks of web development (markup, style sheets and scripting
engine) in a unified language that can still be abstracted separately if one
so chooses. Baring the syntax, it was exactly the type of concept I was
suggesting a little while back when myself and a few friends were discussing
ideal world scenarios of how we'd reinvent the web-development stack.

Anyhow, Red is definitely an interesting language in itself. But it's always a
bonus when one interesting post on HN leads you on a journey of a few other
discoveries.

[1]
[http://en.wikipedia.org/wiki/Homoiconicity](http://en.wikipedia.org/wiki/Homoiconicity)

[2]
[http://en.wikipedia.org/wiki/Curl_%28programming_language%29](http://en.wikipedia.org/wiki/Curl_%28programming_language%29)

~~~
andolanra
JavaScript is _not_ a homoiconic language, because the important feature of
homiconicity is not that the syntax "mirrors" the syntax of data, but that the
syntax is _actually represented_ as a piece of data that can be manipulated in
the language.

For example, in Scheme, I can easily generate data structures and interpret
them as code to be executed _or as data to be manipulated_. For example, here
I can generate code corresponding to a given factorial, and also muck with it.

    
    
        > (define (fact-code n)
            (if (= n 0) 1 `(* ,n ,(fact-code (- n 1)))))
        > (fact-code 4)
        (* 4 (* 3 (* 2 1)))
        > (eval (fact-code 4) (the-environment))
        24
        > (eval (replace '* '+ (fib-code 4)) (the-environment))
        10
    

We can write a function similar to _fact-code_ in Rebol, which I'm borrowing
from an earlier comment[^1]

    
    
      >> fact-code: func [n] [either n = 1 [1] [compose [(n) * (fact-code n - 1)]]]
      
      >> fact-code 4
      == [4 * 3 * 2 * 1]
      
      >> do fact-code 4
      == 24
    
      >> do replace/all fact-code 4 '* '+
      == 10
    

There is no analogous way of generating and manipulating JavaScript code using
JavaScript. If _all_ JS code could be understood as JSON that then could be
fed back into JavaScript and manipulated there, then it would be homoiconic.

[^1]: Borrowed from this older comment with a minor name change
[https://news.ycombinator.com/item?id=5809980](https://news.ycombinator.com/item?id=5809980)

~~~
laumars
My mistake, thank you for the correction.

What made me believe JS / JSON were homoiconic was down to the following
vulnerable method of loading a JSON file:

    
    
        var obj = eval (json);
    

But after reading your post, I can see how this differs from homiconicity

------
ajkjk
This site should really have some code examples on the main pages. I shouldn't
have to watch videos to get a basic idea of the syntax and what it can do. The
blog on the front has some code, but it's not geared towards explaining the
basic ideas.

~~~
dockimbel
Red's author here. I agree and I apology for the currently poor web site. It
was built for the Red and Rebol crowd to help them follow us while we are
building Red. As we are getting closer to a beta version, we are planning to
move in the next couple of months to a brand new site that will properly
communicate about Red to newcomers.

About the syntax and semantics, in a nutshell, it's a Lisp without parentheses
and with infix operator support. Tokens are separated by a whitespace or a
delimiter (very few of them). Code is a tree of lists (called "blocks" in our
local jargon), blocks are delimited by square brackets [].

You can have a look here [1] for a larger code and syntax example.

[1]
[https://github.com/red/red/blob/master/red.r](https://github.com/red/red/blob/master/red.r)

~~~
leke
Good to see you have serious plans for this language. I was always interested
in Rebol, but never became any 'good' at it --- although I always like to read
updates about it and its forks.

------
FreeFull

        red>> .1 + .2 + .3 = .6
        == true
        red>> .1 + .2 + .3 - .6
        == 1.110223024625157e-16
    

This doesn't feel right to me. I usually would expect equality to be a
strictly exact thing. This is bound to cause some problems in code that
assumes IEEE-754 has been implemented exactly.

~~~
geographomics
The language distinguishes between equal and "strictly equal":

    
    
        red>> .1 + .2 + .3 == .6
        == false
        red>> .1 + .2 + .3 = .6
        == true
    

I'm not sure if that syntax is the wisest choice, but in the absence of
arbitrary precision arithmetic it seems a very good concept, to avoid common
IEEE-754 surprises.

They appear to be implementing it along these lines:
[http://randomascii.wordpress.com/2012/02/25/comparing-
floati...](http://randomascii.wordpress.com/2012/02/25/comparing-floating-
point-numbers-2012-edition/)

~~~
draegtun
It should be noted that Rebol comes with an arbitrary precision (bignum)
arithmetic option via it's _money!_ datatype -
[http://www.rebol.net/wiki/Money](http://www.rebol.net/wiki/Money)

    
    
      >> .1 + .2 + .3 
      == 0.6000000000000001
      
      >> type? 0.1    
      == decimal!
      
      >> $.1 + $.2 + $.3
      == $0.6
      
      >> type? $0.1
      == money!
    

Red will most likely get this soon but perhaps with a different nomenclature
(Red as already renamed _decimal!_ to _float!_ ).

------
johnk-
Another place to learn more about Red and Rebol is over at the stackoverflow
chat room. [http://chat.stackoverflow.com/rooms/291/rebol-and-
red](http://chat.stackoverflow.com/rooms/291/rebol-and-red)

------
soapdog
Does anyone has a link comparing Red to REBOL? I was a heavy REBOL user back
then and always missed the language. I wonder if Red is a viable substitute...

~~~
doublerebel
From my reading today it seems REBOL 3 and Red have semi-merged [1]. REBOL 3
extensions can be written in Red, and the communities seem to share the same
online spaces and goals.

Red looks awesome in the long run, the main weirdness being its refusal to
follow standard math operator precedence [2].

Although Red's macro/DSL buildup skips a ton of intermediate bloat, someone
needs to write a normal server framework to interact with standard industry
data sources. When it becomes easy to add a Red microservice to an
architecture, Red can enjoy an explosion of adoption as Go has.

[1]
[http://rebolforum.com/index.cgi?f=printtopic&topicnumber=27&...](http://rebolforum.com/index.cgi?f=printtopic&topicnumber=27&archiveflag=new)

[2] [http://stackoverflow.com/questions/26514041/fixing-the-
rebol...](http://stackoverflow.com/questions/26514041/fixing-the-
rebol3-example-calculator-to-use-normal-math-operator-precedence)

~~~
iArnold
As the person that replied to your second point on the SO question there, I
have to add something here. There are other calculators made in Rebol. (Search
rebol.org site scripts for those). Having this calculator adapted for the math
operator precedence would be too farfetched, for the example merely shows how
much can be done with so little code. The other is that I do not have the
ultimate say in what Rebol and or Red should do with math operator precedence,
I have nothing to say about that to be exact ;-) (I am free to express my
opinion on the subject). What I state there still holds for me, the operator
precendence is imho arbitrary, and not necessary at all, counterintuitive for
kids, and (I am a mathematician) the world can do without these rules. With
operator precendence I have no other choice then to use ellipses when I have 3
* 4 + 1 and I meant I wanted to add 1 to 4 before multiplying by 3: 3 * (4 +
1) in Rebol I can write 1 + 4 * 3 and I do NOT have to use "(" and ")" to
achieve what I intended saving me four keystrokes.

Regards,

Arnold

~~~
justin66
Does the operator precedence convention of treating addition and
multiplication equally apply to all of Red? All of REBOL? Or is it just that
program? Thanks.

~~~
dockimbel
Both Rebol and Red use that convention. It sounds weird at first look, but
proved to be a relief in practice (no need to remember any specific precedence
rule). Though, we plan to provide a small math-oriented DSL for writing
expressions using standard math conventions. It would look like this:

    
    
      >> print 1 + 2 * 3
      == 9
      >> print math [1 + 2 * 3]
      == 7

------
darkoverlord
I am happy to read that the site will become more accessible to a larger
group. I've REBOLed a long time in the 2000s and made good money of it.

Make no mistake: both REBOL and RED have an extremely powerful underlying
model model to help solve problems. In a world of containers and micro-
services "something like these" will emerge.

If nothing else, that's a reason to follow them - between Go and RED/REBOl you
can see a glimpse of computing as it will be.

------
jdeisenberg
As wonderful as the language might be, the site is nearly unreadable; the
black background makes the dark red links almost invisible, and it "swallows
up" the thin, small white text.

~~~
dockimbel
I have replied about the web site on the top comment. I have noticed that the
readability varies greatly across browsers/OS/devices. Anyway, the color
scheme and layout we are using currently are far from being the best. We will
change that before officially opening the doors to our guests. :)

------
gaius
Not to be confused with
[http://en.wikipedia.org/wiki/Core_War#Redcode](http://en.wikipedia.org/wiki/Core_War#Redcode)

