Not a Programming Language

Enough suspense. I mentioned that Red isn't really a programming language, but you can use it as one. I'm planting this seed now, as I will for some other concepts, knowing it may not seem important. It may even seem strange. Someday, maybe, you'll hear a little <click!> in your head, and one of these little seeds will sprout. We joke about "Taking the Red Pill" and "There is no spoon." in reference to The Matrix. Until that day comes for you, live happily in the matrix and think of Red as a programming language.

This is your last chance. After this there is no turning back.

You can stop reading now, if that's what you want.

You take the red pill, you stay in Wonderland, and I show you how deep the rabbit hole goes.

It won't be all that. At least not all at once. The whole "It's dangerous to free a mind after a certain age" thing, freaking out because everything you know is wrong? Nothing so dramatic. But, one day, you may write a piece of Red code and hear a little voice in your head say "I know Kung Fu!"

Because I haven't included any actual Red in this blog so far, if you haven't already seen Red in action, what I'm about to say will seem a bit abstract. We will get to Red code and examples soon enough. Wait! I just said Red "code", which surely implies that Red is a programming language and I am a bold and bald-faced liar. Not so.

code: 1a. A system of signals used to represent letters or numbers in transmitting messages. -- American Heritage Dictionary

Charles Petzold, in his book Code, refers to code as:

...a system for transferring information among people and machines.

and also says

[Most] codes must be well understood because they're the basis of human communication.

Appeals to authority make weak arguments, which is not what I'm doing here. These are not facts to be argued, but bits of information that help set a context for discussion. I'm going to post a number of quotes by Carl Sassenrath here, because Rebol's fundamental design objectivess and choices are effectively Red's DNA (sometime I'll write about Red being both DNA and RNA, but not now). Environment plays a role, but you can't escape your DNA. Here are some things Carl has said about Rebol and its design:

It's about language...the enabling technology behind all technologies.

It is a language for representing data and metadata. It provides a consistent architecture for computation, storage, and exchange of information.

REBOL was designed to solve one of the fundamental problems in computing: the exchange and interpretation of information between distributed computer systems.

REBOL gains its advantage through lightweight domain-specific sublanguages and micro-formats. REBOL introduces the concept of dialecting: small, efficient, domain languages for code, data, and metadata.

Although it can be used for programming, writing functions, and performing processes, its greatest strength is the ability to easily create domain- specific languages or dialects.

I describe it as "A language that facilitates the exchange of information between people and machines." There is intentional overload of meaning there. It isn't just a way for us to communicate with machines, by writing program code. It also isn't just a way to share information between machines and processes. It's also a way to exchange information, person to person. With the added bonus that what a person can read and understand, a machine can process as well.

Next time, we'll see some examples, then start digging into some technical details.

Why Red: Part 2

Having used Rebol for many years, I've found that it is the most productive general purpose language I've used. Some language are good at one thing, but not another. In my work, I develop a wide range of tools, products, and infrastructure. Having a single language that I can tailor to different circumstances, by building dialects (DSLs), provides a lot of leverage. Time isn't spent changing mental gears between languages when I need to write the GUI that talks to a server component I was just working on, or when using it as a portable shell for admin work. This is particularly helpful when you have smaller teams. The more technologies they need to keep up with, and keep in sync, the less time they can devote to the real work.

One shortcoming in Rebol is that it wasn't easy to extend. Being closed source, R2 (Rebol 2) could only be extended for performance or system integration by writing and calling into DLLs, which you can't write in R2. So I have DLLs written in other languages, to interface to devices or the operating system in ways R2 can't. R3 was released as open source, but is written in C. In order to extend it with compiled elements, you need to drop out of Rebol and write in C.

What makes Red unique is that is provides all the high level features of a modern, dynamic, functional language, adds elements other languages have not adopted yet (native datatypes for common values like email addresses, urls, and IP addresses), which provide enormous value on their own, and is built on the language itself. This, in itself, isn't new. Lisp has done it all along. And that points out how powerful and important this concept is. Lisp is still around, and influencing new language development every day, including Red. A shortcoming in many Lisps is low-level efficiency. This is where Red/System comes in.

Having a low level dialect of Red as the base language that it's all built on lets you write code at any level, for any purpose, without having to change mental gears. Complete leverage. There is no other language I'm aware of that does this. The features available in each dialect are different, of course. Red is a high-level, dynamic language. R/S (Red/System) is a C-level language. R/S uses values that can fit into CPU/FPU registers, and gives you control over memory allocation. It can only be run compiled, while Red can be interpreted. Aside from that limitation, you can freely mix and match the two. Red is implemented in Red/System. Think about that for a moment. Red/System is a dialect of Red, an embedded DSL of its host language, yet the host is implemented in that dialect.

It just looks more and more like a programming language, doesn't it? But it isn't. You can use it as one, and it is extremely effective when applied that way, but it's not the whole story.

Why Red: Part 1

Everything has strengths and weaknesses. Programming languages don't succeed or fail based solely on technical merit. They are subject to whim as well as trends, corporate support, and luck as much as design. That may seem a shame, but it's the way the world works. And, just as you can't tell another person that something tastes good, you can't tell them one language is better, easier to learn, or more productive than another. Maybe if you're a twin, you could tell your sibling. Otherwise, it's just too hard to know what's going on in someone else's head. One person's beauty is another's modern art.

Javascript was (in)famously designed and prototyped by Brendan Eich in 10 days. Only his deep experience in building languages made that possible, but even then he was constrained in various design aspects. Rebol, Red's direct ancestor language, was designed over a 20 year period by Carl Sassenrath, famed architect of the Amiga operating system. The two languages couldn't be more different in some ways yet, perhaps ironically, they share some fundamental concepts that make them cousins in other ways. Both are part of the Lisp and Smalltalk/Self family tree, which is at the very core of things, but they part ways after that. You can find a lot of Javascript resources, so I will focus on Red's lineage here.

As a programming language, Red's roots start with Lisp, but take Logo's syntax, eliminating the parentheses. It also draws inspiration from Forth, in its focus on brevity and the idea that you can (and should) write programs by defining a vocabulary that helps you describe the problem you need to solve. That is, you think about how you would like to express your solution, then, in mild form, implement the language that lets you do that. Objects in Red are prototype based, as in Self, not class based. Sassenrath had built many languages himself, including a Smalltalk, and did a lot of OOP work for many years. When he designed Rebol, he had reached a point where he felt OOP wasn't the answer, at least not as a foundational element of the language design. Objects are a way to group things, but they are not the foundational structure on which everything is built.

What exactly is Red then? We're getting there. You may guess that I'm cooking you slowly, warming up the water so you don't jump out. You're right. Relax and enjoy the warm water for just a bit longer.

Based on the above, you're correct if you think Red is a multi-paradigm language. That's not novel anymore, but there's another level yet to come. Yes, Red is a homoiconic (self-representing) impure functional (functions are first class values) like Lisp. It is an OO language like Self, and a minimalist symbolic language like Logo and Forth. Still comfortable? Good.

What I'm about to say may seem unimportant. Trivial even. A "So what?" moment. Later, something will happen in your head and you will see the camera pull back down the long hallway as you reach for the doorknob that leads to a quiet place of revelation, rather than falling backwards through what you thought you knew.

Don't be afraid.

Red isn't a programming language at all.

(I apologize if you don't like cliffhangers. Blogs are serial by nature.)

Why Another Language

Languages exist, and are designed, for many different reasons and purposes. Some have a clear, practical goal. Others are experiments, agglomerations of ideas from other languages, put together in a new way. Sometimes new ideas are mixed in. Still more are research projects; the very science of computer science, and will bear fruit in the genetics they pass on to real world implementations of their ideas that escape the lab. There are those born of corporate mandate, funded, designed by committee or, perhaps, a vetted visionary or respected greybeard. Many are beloved pets and lifetime hobbies.

Occasionally, a fresh perspective sparks something very different in a designers mind. Not just an attempt to forgo text as the main expression of intent, but sometimes just one element, or a few, central to the core vision for the language. Something without which the language ceases to be what it is, and becomes something else. Lisp has lists. C has pointers. Perl has regular expressions. APL has arrays and special characters. Smalltalk has messages, objects, and the image. Erlang has processes, messages, and pattern matching. Python has indentation, Ruby is meant to be fun.

Red's design comes largely from Rebol. We sometimes use the term Redbol to refer to all Rebol-like languages, which is a fun homophone of Red Bull (a popular energy drink, for future archaeologists). Red's designer, Nenad Rakocevic, gives full credit to Carl Sassenrath for his pioneering work. You, dear reader, must remember to give them both credit, as we see more branches in the programming languages family tree incorporate their ideas.

About Me

This can be brief, because you don't need to know all about me. You only need to know enough to decide whether I'm qualified enough in my knowledge of Red that you'll get value from what I write.

I've been programming professionally since 1991, and unprofessionally for some time before that. I specialized in Visual Basic for 11 years, through the 90s, starting with VB 1.0. I was one of the first 4 VB MVPs in the world, when they started the MVP program. Heady days.

Even though I like to specialize in a small set of tools, I'm always on the lookout for new and better ways to do things, and am a bit of a language junkie. Just because I specialize in something doesn't mean it's the only thing I've looked at. I do like when people turn me on to things I haven't seen, but if you feel the urge to say "You should check out X", I probably already have. Unless it's a JS framework or lib, because nobody can keep up with those. And I prefer long term relationships.

In 2001 I discovered Rebol. It was my mainstay for 15 years. I still have a lot of production code running under it, but the king is dead, long live the king. Red is a direct descendant of Rebol, and highly compatible. It adds new capabilities, and some things are different, but knowing Rebol let me dive right into Red when the time came. There were a few adopters earlier than me. Glancing at some folders, it looks like I took the Red pill in 2013 and decided it was the future.

I still bow to the gurus, continuing on my journey towards enlightenment as a software developer, but I do have a lot of what they call "experience", which is what I will share on this blog.