Live data from Hacker News

Red Programming Language: Plans for 2019

red-lang.org

121–130 of 141 posts

Re: Red Programming Language: Plans for 2019

#121
post #116

Earlier quoted context omitted.

> Where is the BNF? Here [1]. Red and Smalltalk syntax look similar, but semantics are very different. They only relation to object-oriented languages Red / Rebol have is through prototype-based OOP, e.g. Self [2]. Forth doesn't have any grammar specification AFAIK - any space-separated string of ASCII tokens is a valid Forth program, but it may vary from dialect to dialect. It's more of an idea than programming lang…

It is good to see there IS a specification; I - and I think some others (see the Temple OS comments) - had concern Red/Rebol might actually be too ad hoc (throw things against the wall and see if they stick). Is there means to access the lexer directly as a means to explicate how, exactly, Red is interpreting? The use of blocks in Red, and the layout in general, did remind me of Smalltalk but in Smalltalk I could at…

> Red/Rebol might actually be too ad hoc

No offence, but very few people who raise such concerns actually take time to learn the language (or even launch a REPL at least once) and understand its design, so I appreciate you digging deeper. "Things are thrown against the wall" only in terms of constant search for a sound business model, and this, I believe, is the struggle that any startup (esp. programming languages) faces.

> Is there means to access the lexer directly as a means to explicate how, exactly, Red is interpreting?

I think you can start by, well, reading lexer code, which is written in Parse dialect [1], but specification I showed you might be more approachable. But really, just grab the latest build and start playing, I'll give some very basic examples below.

Now, to the main point: from what I know, Rebol (and Red) are based on research in denotational semantics that Carl Sassenrath did. I'll try to briefly explain the main points.

As you already know, everything starts with a UTF-8 encoded string. Each valid token in this string is converted to an internal data representation - a boxed structure, called a value slot or sometimes a cell.

Value slot is composed of a header and a payload. Header contains various flags and datatype ID, payload specifies exact content of the value. If content doesn't fit in one value slot, then payload contains a pointer to an external buffer (an array of value slots, bytes, or other units + offset and start/end addresses IIRC) with extra data.

So, lexer converts string representation to a tree of value slots (this phase is called "loading"), which is essentially a concrete syntax tree (CST) - this is the crux of homoiconicity.

  >> "6 * 7"
  == "6 * 7"
  >> type? "6 * 7"
  == string!
  >> load "6 * 7"
  == [6 * 7]
  >> type? load "6 * 7"
  == block!
  >> first load "6 * 7"
  == 6
  >> type? first load "6 * 7"
  == integer!
 
Everything is a (first-class) value, and every value has a datatype (we have roughly 50 of them right now). And there's no code - only this data structure, which is just a block, which you can freely manipulate at will (so as any other value).

  >> reverse [6 * 7]
  == [7 * 6]
  >> append reverse [6 * 7] [+ 1]
  == [7 * 6 + 1]
  >> skip append reverse [6 * 7] [+ 1] 2
  == [6 + 1]
What interpreter does is just a "walk" over this tree of values, dictated by a set of simple evaluation rules (expressions are evaluated left to right, operators take precedence over functions and have a more tight left side, literals evaluate to themselves, functions are applied to a fixed set of arguments, symbolic values of type "set-word!" [more on this later] are bound to the result of expression that follows them, etc) but there are a couple of catches.

The first catch is that some values are symbolic - that is, they indirectly refer to some other values via a context (namespace). You can modify this reference (called binding) freely at runtime, and thus change the meaning of symbolic values and of an entire block that contains them.

So, the "meaning" of a given block is always relative to some context(s) - this is what relative expression means (RE in REBOL). And context itself is just an environment of key/value pairs (key is a "symbol", value is its "meaning") represented as an object (O in REBOL).

  >> block: [6 * 7]             ; "block:" is a value of type "set-word!"
  == [6 * 7]
  >> type? second block
  == word!                      ; words are one of the symbolic values I've mentioned
  >> do block
  == 42
  >> bind block object [*: :+] ; now "multiplication" means "addition"
  == [6 * 7]
  >> do block
  == 13
The second catch is that you are not restricted by default interpreter (represented by "do" function) and can use any other one or even implement your own, thus making an embedded DSL - a dialect in Red/Rebol parlance.

* Red/System takes a block of C-level code and does the prescribed job.

* View takes a block that specifies GUI layout and shows a fancy window.

* Draw takes a block of drawing commands and renders an image.

* Parse takes an input series and a block of PEG grammar, and parses the input.

* Math takes a block and interprets it with common operator precedence rules.

Sky is the limit, and its dialects all the way down.

To reiterate: the basic building block (no pun intended) is a block of values, which can represent either code (relative expression which, upon evaluation, will yield a value) or data (just a bunch of values arranged in a specific format - such micro-formats are considered to be dialects too †). Block can also contain symbolic values (called words) which can change their binding during evaluation, and thus alter the semantics of expression.

There's a lot hiding behind the facade, as you can see. And what is there is hardly an ad-hoc hodge-podge slapped together.

[1]: https://github.com/red/red/blob/master/environment/lexer.red

(†): one example of such micro-format dialect is function specification, e.g.

  spec: [
      "Add two numeric values together"
      x [number!]
      y [number!]
  ]
is a specification (or an "interace") for a function that performs addition. Here's a block that expresses addition of two specific numbers:

  [1 + 2]
If we wish to abstract over it, we can substitute 1 and 2 for words:

  expression: [x + y]
And then we can alter bindings of these words to actual arguments we wish to add together:

   bind expression object [x: 1 y: 2]
We then can evaluate such expression and yield a resulting value:

   == do expression
   >> 3
The trick is that functions are just abstraction over evaluation of expression in some environment, that is, a syntax sugar for

  do bind [...] object [...]
with some additional optimizations and type-checking. So, addition instead can be expressed as:

  >> add: func spec expression
  == func [
    "Add two numeric values together" 
    x [number!] y [number!]
  ][x + y]
  >> type? :add ; ":add" is a value of type "get-word!" which, on evaluation, yields function's value referred by word "add" as-is, without triggering its application.
  == function!
  >> add 1 2
  == 3

Re: Red Programming Language: Plans for 2019

#122
post #118

Earlier quoted context omitted.

> this is provably false If it's provably false, then take your time to actually prove it before calling someone a liar. > my initial an subsequent posts remains just as valid. They remained as biased as the were. You waved away project's history and keep imposing "high" standards pulled from other projects, without respecting their retrospective history and goals. > At best, Red sees one minor version increment per…

> If it's provably false, then take your time to actually prove it before calling someone a liar. 1. It was your claim that it was "just formatting changes". Which they are not 2. This doesn't explain why 99% of bug fixes contain no tests > If it's provably false, then take your time to actually prove it before calling someone a liar. Testing and comments in code are not high standards. They are basic development hyg…

Dimitri, you've obviously looked into Red in some depth, which is appreciated. And your comments and criticisms have been heard. It's easy for miscommunication to occur in chat like this, so we can probably close this particular thread of conversation, as I don't think it's productive anymore. As much as I now want to chime in to defend our position, it wouldn't help. You make valid points, but comparisons with other projects are hard.

If you don't like Red, or how the project is being managed or progressing, that's fine. Sharing what you've learned is also great, as long as others can form their own opinions from facts presented (again, hard to present deep info in chat). All we ask is that you try to be fair, and think about how harmful negative press can be to a project. When you've put a huge amount of time and effort into something you believe in deeply, it's easy to get defensive when someone criticizes it (in ways that may seem unfair).

How things are said is important, as well as balancing pros and cons. In re-reading the chat, I admit that I got defensive, which is why I didn't respond initially.

In conclusion, can we do better? Yes, of course. Is much of the code written by a very small core, who knows the system well, and isn't writing it with the expectation that others will read and learn from it? Yes. Can we do better on testing? Yes. Do we already have more than 30'000 tests? Yes. Are those core devs pretty darned amazing, considering what they've built (insert feature list here :^)? You bet they are.

Red isn't for everyone. Our approach won't be to everyone's liking. But we hope people will be fair, wish us luck, and maybe even applaud us for trying to build something that will make their lives better. At the very least, we hope they won't talk us down unfairly.

Re: Red Programming Language: Plans for 2019

#123
post #92
post #78

Earlier quoted context omitted.

> (Are Red/Rebol creators seriously claiming that Clojure's syntax is complex?) The huge paragraph you're responding to refers to the programming stack as a whole. In reference to Clojure, it's including the JVM.

> encumbered by mainstream language syntax and development procedures which introduce an extraordinary volume of unnecessary complexity at many levels. This clearly states about Clojure that its syntax AND it's procedure of development (another grand claim) introduce said complexity. That whole write-up is just about as incorrect as it can get: > Virtually every other well known development tool in popular use is bui…

@hjek, as @dockimbel noted, and we have never concealed, Red was bootstrapped using Rebol. Doc's stats break things down pretty well, but there's another point to be made. Red is ~95% Rebol compatible. This is a very important detail, and proved that Red could be used to self host in the future. When the need to self-host becomes important, it can be done relatively easily, and with confidence.

Is that a fair and accurate assessment?

Re: Red Programming Language: Plans for 2019

#124
post #111

Earlier quoted context omitted.

But that was a very important choice. Do you understand why?

> But that was a very important choice. Do you understand why? I'm sure you have your reasons for doing so, and I'm glad that it's working well for you. I'm not having a go at you for making Red run on Rebol. But I am having a go at you for having a go at Clojure for running on the JVM, while claiming that Red is built "from the ground up". All this posting about how Red is better than all other languages, and that p…

As has been noted by others, we have never "had a go" at Clojure. Language designers and the people who build them have our respect, even if our choices differ. If we criticize them (and we do at times, being human, and thinking we're right ;^), we try to be fair. Rich Hickey's talks are some of my favorite to watch, and I have nothing but respect and admiration for him.

Of course everything has a cost, but to call us megalomaniacs is a bit harsh.

You didn't say you understood the reason, but I pointed it out in another reply here. By bootstrapping from Rebol, and being 95% Rebol compatible, we proved that Red could self host, and also leverage almost all the existing code when we get to that point.

To ask if we understand those issues comes across as insulting. Sure, we could be tech smart but miss obvious things, but that one we know about. ;^)

Re: Red Programming Language: Plans for 2019

#125
post #117
post #111

Earlier quoted context omitted.

> But that was a very important choice. Do you understand why? I'm sure you have your reasons for doing so, and I'm glad that it's working well for you. I'm not having a go at you for making Red run on Rebol. But I am having a go at you for having a go at Clojure for running on the JVM, while claiming that Red is built "from the ground up". All this posting about how Red is better than all other languages, and that p…

Can you back up your acqusations with palpable evidence? Neither Red author, nor any of official project representatives "made a go" on Clojure or any other language and its community, as far as I'm concerned. As for "defensive lashing" - you should make a distinction between informed, well-posed critique and arrogant, unbacked ranting. Everyone accepts the former and does not tolerate the latter - the team is no exc…

> And use official resources (Red and Rebol websites) as references, would you? Wiki page is an extremely weak testimony to whatever you have to say.

That's my mistake. The quote about Clojure I provided were from `redprogramming.com` which is linked to from the official website and from your Github, so it looked official to me.

The comparison with Python is from a blog of one of the Rebol developers. Not sure whether that qualifies as official.

If the Wikipedia article about Red is wrong, it might be a good idea to correct it..?

> Even if there is a cost in using Rebol2 as bootsrapping language, it will be gone with 1.0 release. [...] (since when bootstrapping language is a dependency?)

That's cool, and I wasn't aware of that. I just assumed Red was to Rebol what Hy is to Python and Clojure to Java, but that's great that that is a non-issue!

Re: Red Programming Language: Plans for 2019

#126
post #54

Earlier quoted context omitted.

> > If anything, it sounds too easy, making me think "what's the catch? > This is rude and uncalled for. I think she/he raise a fair point about how the Red language is advertised, and it's actually a rather friendly to assume that it's due to language barrier. Many posts about Red/Rebol are unequivocal praise with very few details or any acknowledgements of short-comings or limitations of the languages. Just to dig…

> (Are Red/Rebol creators seriously claiming that Clojure's syntax is complex?) Red's author here. I have nothing to do with those websites nor their content. They are not official Red nor Rebol sites. I do not see a single quote from me there, nor from Rebol's author. Stop spreading false information please.

Sorry about that. Looked official to me and was linked to from the Red page and from your Github, but sorry about the mistake. s/creators/community/

Re: Red Programming Language: Plans for 2019

#127
post #92

Earlier quoted context omitted.

> encumbered by mainstream language syntax and development procedures which introduce an extraordinary volume of unnecessary complexity at many levels. This clearly states about Clojure that its syntax AND it's procedure of development (another grand claim) introduce said complexity. That whole write-up is just about as incorrect as it can get: > Virtually every other well known development tool in popular use is bui…

> Never mind that Red is actually implemented in another abandoned proprietary language[0]! Github's code breakdown by languages for red/red repo: * Red 83.8% * Rebol 15.7% * C 0.2% * Visual Basic 0.2% * Java 0.1% * Shell 0.0% Only the compiler is implemented in Rebol, the rest, including the interpreter, the consoles, the GUI system and the whole runtime library are implemented in a mix of Red and Red/System. From t…

> The use of Rebol is only for boostrapping the language. The whole Rebol code part will be dropped after 1.0, and the toolchain rewritten in pure Red.

Cool!

Re: Red Programming Language: Plans for 2019

#128
post #121

Earlier quoted context omitted.

It is good to see there IS a specification; I - and I think some others (see the Temple OS comments) - had concern Red/Rebol might actually be too ad hoc (throw things against the wall and see if they stick). Is there means to access the lexer directly as a means to explicate how, exactly, Red is interpreting? The use of blocks in Red, and the layout in general, did remind me of Smalltalk but in Smalltalk I could at…

> Red/Rebol might actually be too ad hoc No offence, but very few people who raise such concerns actually take time to learn the language (or even launch a REPL at least once) and understand its design, so I appreciate you digging deeper. "Things are thrown against the wall" only in terms of constant search for a sound business model, and this, I believe, is the struggle that any startup (esp. programming languages)…

Thank you for the details; I will study them more.

But let me try again with my main question. I want to see what the lexer outputs. How can I view that?

I'd like to be able to hand a string (or file) of what I think is valid (or invalid) Red code and have the lexer return to me that input NOT executed but parsed into lexemes, grouping tokens, and appropriate white space.

Again, according to the specification you linked, the lexing is a discrete step to resolve any ambiguity of syntax in this manner ahead of interpretation/execution. So I'd think accessing the lex output would be trivial and transparent -- not to mention invaluable for learning and debugging Red. Why should lexer be crystal clear about exactly what is going to be interpreted, and in what order, while the human is sometimes left in the dark?

Then, obviously, I'd like to be able to pass this lexed and "grouped" string directly in to the interpreter for execution as a second step. Showing me the result of interpreting a string isn't nearly so helpful as this would be. Can this be done?

Why would I want to do this? Well, I've weird. ;-/ More seriously, at this point you guys don't have a good stepping debugger - it would help me debug my own code. It would also be a rather cool thing to be able to do just for the hell of it, as a great exploratory exercise. I would think I could then play with the lexemes individually once I can see exactly what the lexer sees instead of only what I think - too often mistakenly - the lexer sees.

Thanks for entertaining my questions.

Re: Red Programming Language: Plans for 2019

#129
post #121

Earlier quoted context omitted.

> Red/Rebol might actually be too ad hoc No offence, but very few people who raise such concerns actually take time to learn the language (or even launch a REPL at least once) and understand its design, so I appreciate you digging deeper. "Things are thrown against the wall" only in terms of constant search for a sound business model, and this, I believe, is the struggle that any startup (esp. programming languages)…

Thank you for the details; I will study them more. But let me try again with my main question. I want to see what the lexer outputs. How can I view that? I'd like to be able to hand a string (or file) of what I think is valid (or invalid) Red code and have the lexer return to me that input NOT executed but parsed into lexemes, grouping tokens, and appropriate white space. Again, according to the specification you lin…

> I'd like to be able to hand a string (or file) of what I think is valid (or invalid) Red code and have the lexer return to me that input NOT executed but parsed into lexemes, grouping tokens, and appropriate white space.

This is what "load" essentially does - it takes a string and returns a concrete syntax tree [1]. "do" then takes that CST and evaluates it. You can do that in a single-step manner with "do/next" (there's also "load/next"). Moreso, you can think of blocks as phrase markers (see wiki example):

  [S [NP John] [VP [V hit] [NP the [N ball]]]]
Now compare it to Red internal data structure written down in similar fashion:

    ]>
Here I loosely follow phrase marker notation - nonterminals correspond to datatypes, terminals correspond to literal values. But datatype is implied by literal form, and implicitly contained in each value slot (its a datatype ID tag in the header), so I can tidy this up to:

  [1 + 2]
This is what lexer returns - just a block. You can then manipulate it whichever way you want and evaluate.

> at this point you guys don't have a good stepping debugger

We don't have it for a reason - implementing it in user-space would be extremely limited as you can't really distinguish between code and data, and so can't adequately place debugging hooks. The best alternative is just to spruce up block with debugging "print"s and such, or, in case of syntactic errors use "load/trap" and search for error values. Rebol had some interesting projects in this regard, e.g. Anamonitor comes to mind [2]. I think someone already ported it to Red, or re-implemented using our reactive framework.

There was a recent discussion in community chat about that, and we came to conclusion that debugger should rather be implemented at the level of "load" and "do" themselves (e.g. "load" can provide some metainfo, like line numbers and file name, "do" then can single-step it in real time and provide the meaningful info).

[1]: https://en.wikipedia.org/wiki/Parse_tree

[2]: http://rebol2.blogspot.com/2011/11/anamonitor-2-check-block-...

Re: Red Programming Language: Plans for 2019

#130
post #125
post #117

Earlier quoted context omitted.

Can you back up your acqusations with palpable evidence? Neither Red author, nor any of official project representatives "made a go" on Clojure or any other language and its community, as far as I'm concerned. As for "defensive lashing" - you should make a distinction between informed, well-posed critique and arrogant, unbacked ranting. Everyone accepts the former and does not tolerate the latter - the team is no exc…

> And use official resources (Red and Rebol websites) as references, would you? Wiki page is an extremely weak testimony to whatever you have to say. That's my mistake. The quote about Clojure I provided were from `redprogramming.com` which is linked to from the official website and from your Github, so it looked official to me. The comparison with Python is from a blog of one of the Rebol developers. Not sure whethe…

> `redprogramming.com` which is linked to from the official website

Official page links to learning resources provided by community, to compensate for TBD state of official documentation. We can't, however, control other people's opinions, or dictate them how to express themselves.

People can unintentionally say provocative things in a burst of excitement, I hope you understand that. And there are reasons to be excited about Red and Rebol.

> The comparison with Python is from a blog of one of the Rebol developers. Not sure whether that qualifies as official.

As I said, we can't control other people, and are not responsible for other's bold claims. I too do not think that this benchmark was fair and objective. As for the wiki page - we'll note that. I'm just saying that any other person can go there and apply his/her edits, without project's consent.

> I just assumed Red was to Rebol what Hy is to Python and Clojure to Java, but that's great that that is a non-issue!

It's good that this confusion is resolved. Hy and Clojure are hosted languages by nature, but Red is entirely self-contained (although you might think that it depends on Red/System dialect).

Post reply on HN