
Red programming language 0.6.2: LibRed and Macros - throwaway7645
http://www.red-lang.org/2017/03/062-libred-and-macros.html
======
sevensor
I've noticed that Red shows up on HN with some regularity, and it sounds
interesting. But I don't really understand where it comes from or who it's
meant for. The Red / REBOL community seems more than usually self-contained,
although it's possible that it's because almost everybody involved is Czech,
and I am not. It seems like most of the English-language resources for Rebol
were written by one guy with a thing for really long website names like
withoutwritingcode.com.

~~~
pebblexe
I remember reading somewhere that there is funding/support from China. I can't
find any support for that.

I stumbled upon this site in my search though
[http://red.reb4.me/](http://red.reb4.me/)

~~~
greggirwin
Yes, Team Red (as I like to call them), got some funding from a tech
incubator, and Red's creator became Entrepreneur-in-Residence there for a
time.

------
dillon
This is definitely a neat release. Red seems to be coming along great, and am
interested in what a 1.0 release might look like. Checking their "Roadmap"
they have some very interesting (great?) goals. They seem to be heading
towards a sort-of "runtime purity" by (at least aiming for) targeting:

    
    
        - Native (bridging to Obj-C)
        - JVM
        - CLR
    

While also supporting shared objects so my assumption is that dynamically
linking is possible.

On top of this it looks like they want to support a sort-of wxWidgets-like GUI
programming (which I personally believe to be the correct approach to GUI
abstractions). Backends they aim to support:

    
    
        - Windows (done)
        - GTK+
        - macOS
        - iOS
        - Android
    

This reminds me of the approach a lot of JVM focused languages are taking like
Clojure that support the CLR, JVM, Node and Web Browser.

I guess the obvious questions to ask would be:

1\. Any reason for not wanting to target WebAssembly/JavaScript (and in
conjunction node.js [I understand that this isn't trivial])?

2\. Any reason targeting QT isn't on the roadmap? [targets for KDE, Sailfish,
ect..]

3\. Any reason wxWidgets wasn't a great choice as a foundation? (I believe
they have a C API last I looked)

4\. Is there or will there be an API for creating custom languages that can
target/leverage Red's infrastructure? (basically a Red version/wrapper for
flex/bison)

Finally, adding support for Erlang nodes should be fairly trivial if it was a
wrapper to the C Node API, but it could also be implemented via a pure Red
implementation.

tl;dr I'm interested to see how Red will evolve further not necessarily
because the syntax intrigues me, but because of the goals the team have set
for themselves as far as polymorphic runtimes go.

EDIT: formatting

~~~
greggirwin
> 1\. Any reason for not wanting to target WebAssembly/JavaScript (and in
> conjunction node.js [I understand that this isn't trivial])?

Wasm will likely be the browser target.

> 2\. Any reason targeting QT isn't on the roadmap? [targets for KDE,
> Sailfish, ect..]

They wanted to go native to start. QT is GPL licensed. Not a good fit for Red.
Their "small" installer, which downloads the big stuff, is 18M. Red, with
self-contained toolchain and cross compiler + GUI, is 1MB.

> 3\. Any reason wxWidgets wasn't a great choice as a foundation? (I believe
> they have a C API last I looked)

Targeted at C++, and also very large.

> 4\. Is there or will there be an API for creating custom languages that can
> target/leverage Red's infrastructure? (basically a Red version/wrapper for
> flex/bison)

You can use libRed, which makes Red available as a DLL you can call into from
other langs, like C. See [http://www.red-lang.org/](http://www.red-lang.org/)
where a couple GIFs show integration with VBA and Excel even.

Ultimately, the decision _not_ to use something comes from value added and
available resources. Team Red is small, and has to pick their battles
carefully.

~~~
Narishma
> QT is GPL licensed

Wrong. It is triple-licensed (GPL, LGPL and commercial).

~~~
greggirwin
Thanks for the clarification. Still not compatible with Red's licensing model
IMO.

------
mVChr
I've never seen a language with such a variety of built-in data types (e.g.
coordinates, tags, email, url, issues). There's support for IPv4 numbers as a
base type (tuples) but I can't tell if there's support for IPv6, which shows
the trouble with this approach for the language maintainers.

~~~
taliesinb
Where do you see a nice list of these types?

~~~
mapcars
No need to go anywhere :)

    
    
      >> words: keys-of system/words
      >> types: collect [forall words [if datatype! = type? get/any words/1 [keep words/1]]]
      >> probe types
      [datatype! unset! none! logic! block! paren! string! file! url! char! integer! float! word! set-word! lit-word! get-word! refinement! issue! native! action! op! function! path! lit-path! set-path! get-path! routine! bitset! point! object! typeset! error! vector! hash! pair! percent! tuple! map! binary! time! tag! email! handle! image! event!]

~~~
greggirwin
Even easier:

    
    
      help datatype!

~~~
pekr
It can't be that easy, or can it? :-)

------
transfire
I think Red is a language to watch. It has a lot of potential. But my
understanding is that Linux support is still immature. Currently the focus is
Windows. Is that a correct assessment?

~~~
sqeaky
I read their about page and their newest post. It was a lot to take in. It was
concerning that all the screening had that windows look and feel.

I am kind of excited to try something so large in scope and so different, but
no Linux support would kill it before I even downloaded it.

~~~
mapcars
Linux support is just the beginning. Soon you'll be able to compile for iOS,
Android and other platforms.

~~~
throwaway7645
Yea, using a simple switch to compile tiny native executables for a ton of
platforms is a huge draw. Not having to walk a non-coworker through a python
install who doesn't want python on their computer will be nice.

------
esmi
I was hoping someone was bringing back corewar. The game was played in a
language called Red Code. Pretty fun game for it's time.
[https://en.m.wikipedia.org/wiki/Core_War](https://en.m.wikipedia.org/wiki/Core_War)

------
andrew-lucker
I hope this trend of Colour named programming languages continues. I would
maybe choose Cyan, red sounds too professional :P

~~~
steveklabnik
[http://cyan-lang.org/site/](http://cyan-lang.org/site/)

------
scardine
I know a lot of you may like case insensitive languages, but it just feels
weird for me. And there is the "nim" language which makes no distinction
between CamelCase and snake_case.

~~~
greggirwin
At least it doesn't force any casing on you, as some languages do.

Another thing to get used to is the ability to include characters in names
that you normally can't, e.g., - and ?.

~~~
jplatte
> At least it doesn't force any casing on you, as some languages do.

I'm not convinced that is actually a good thing. It really annoys me when two
libraries for the same language use different naming conventions, and so far I
haven't had any trouble with the strict casing rules in Haskell, or the casing
conventions in Rust where the compiler emits warnings when you don't follow
them (that you can disable with an annotation if you really need to).

~~~
greggirwin
We, as programmers, will never convince anyone that _our_ preferences are
right for everyone else, even when there are strong technical arguments. In
this case (pun intended), it's subjective. A lot of it is what we get used to.

------
ZenoArrow
If anyone wants to try out Red, I'd recommend setting up the Red plugin for
Visual Studio Code, it's not essential (you can code effectively without it)
but it does do the basics very well IMO.

[https://marketplace.visualstudio.com/items?itemName=red-
auto...](https://marketplace.visualstudio.com/items?itemName=red-auto.red)

------
MichaelMoser123
Rebol looks interesting; what does Red do for memory management? Is it garbage
collected or does it do reference counting? If it is reference counted then
what does it do with circular references?

i did take a glance at the documentation but did not find the answer to this
question - without knowing how the thing allocates memory it is sort of
pointless to invest time into learning the language...

~~~
greggirwin
Red will have GC, but it's not there yet. Soon. Red/System is a C level
language, where you have to alloc/free yourself.

Why do you think it's pointless to learn without knowing how it handles
memory?

~~~
MichaelMoser123
thanks for answering.

> Why do you think it's pointless to learn without knowing how it handles
> memory?

I think that a non trivial program will have to employ dynamic memory
allocation, so if it is not obvious how to do that then it will not be
possible to write a complex program. Learning a language that can handle only
simple cases may have some uses, but you already have existing tools for that.

~~~
greggirwin
Got it. Red does manage memory for you, but no GC yet so can't do long-running
procs without care. I've written small Red apps that used 800MB, loading a
large dataset. Totally stable but, again, maybe wait for GC if you're going to
grind a lot.

Red's complete toolchain, compiler, linker, etc. are bootstrapped entirely in
Rebol2. Red is more capable than R2 (though alpha, with features pending), so
it's safe to expect that it can handle more than simple cases. In fact, one of
the reasons Red 1 was implemented in R2 was to prove that Red would be able to
self host. It's possible most of the current toolchain would even work at 1.0,
but the team has learned a lot while building this version, and has said on
many occasions that Red 2 will only keep the best bits.

All that said, even if you never use it in production, it's a great language
to play with and expand your thinking, because it's so different.

~~~
throwaway7645
I'm waiting for a "Red in Action" book or the like. What I've seen in the
Rebol examples hasn't helped me a ton with understanding the Parse
dialect...etc.

------
kome
I can't wait for macOS GUI backend!

------
_pmf_
Their reactive (dataflow) dialect is beautiful.

~~~
greggirwin
Yeah. It hasn't been pressed much yet, since it's new to a lot of us. Here's
something I worked on to learn more about it:
[https://gist.github.com/greggirwin/38883ca5109175a60896d2f40...](https://gist.github.com/greggirwin/38883ca5109175a60896d2f406ee49f6)

