• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Kaj
19-Oct-2012
[2896]
It would be much better to have a real IDL for the command descriptions
BrianH
19-Oct-2012
[2897x3]
Most extension module scripts are currently IDL-like, but that is 
only because they aren't (and don't need to be) very ambitious in 
their system integration because they just export a bunch of functions. 
Any native implementation of a port scheme, native dialect, or other 
system enhancement would need Rebol code to integrate that enhancement. 
Doing that in Rebol code is what allows the actual native interface 
to be that simple. It is also what would allow Red wrapper code (which 
could be returned from the same RX_Init function in the same string) 
to use the same native code unchanged, even though Red's runtime 
model is likely to require different integration code.
[rebol [] do something]
[red [] do something]
People who stick to IDL-style extension modules are really underestimating 
the power of the model :)
Kaj
19-Oct-2012
[2900x2]
Yes, there's endless opportunity to make it incompatible with anything 
but R3 :-)
That has been a fabulously successful strategy for Microsoft
BrianH
19-Oct-2012
[2902]
I was really careful to make extensions support mixed-language multi-modules. 
For that matter, with my recent patches it even supports same-language 
multi-modules.
Kaj
19-Oct-2012
[2903]
Except that in a careless extension, you wouldn't be able to execute 
the module script in Red
BrianH
19-Oct-2012
[2904]
Same goes for any module, even the non-native ones. Multi-modules 
are supported in regular scripts too.
Kaj
19-Oct-2012
[2905]
Not if you split off the interface into a proper IDL
BrianH
19-Oct-2012
[2906x4]
Ah, but the interface is too simple to need an IDL - make command! 
will do. The extra stuff is for system integration, which is only 
needed when you are doing port schemes, dialects, anything that you 
wouldn't expect to be cross-language compatible anyways, unless you 
explicitly implement a compatible system model. If you're just exporting 
functions then you can implement a simple IDL just by interpreting 
the (cooincidentally the same) module spec code with a very limited 
IDL dialect processor if no Red script wrapper is found.
The same could be said for changes in major versions of the same 
language if they weren't made with deliberate compatibility in mind.
I didn't have Red in mind when I implemented multi-modules, as Red 
didn't exist yet. I was actually thinking of other languages that 
didn't even need to have the same syntax as Rebol.
Carl was thinking of better encapping methods for R3 itself. It works 
for both :)
Kaj
19-Oct-2012
[2910]
I think you don't want to understand me, but my time is up
BrianH
19-Oct-2012
[2911]
Btw, you can't run applications for Linux on Unix without a compatibility 
library either. Bringing MS into it is just an insult.
Kaj
19-Oct-2012
[2912]
Ah, see, you do understand me :-)
BrianH
19-Oct-2012
[2913]
I don't expect Red and R3 to have the same system model, because 
if they did there would be no point to having Red at all. Being able 
to have extensions that can integrate into both would be an unusually 
amazing bonus :)
Kaj
19-Oct-2012
[2914]
I still don't know if you really don't see it, but I could easily 
define them
BrianH
19-Oct-2012
[2915x2]
For that matter, I expect to make my own Rebol spinoff language that 
will follow a completely different system model than either Red or 
Rebol, and the only reason to do so is because those other languages 
don't cover that situation (otherwise I would have been more active 
in Red so far). Being different justifies their existence; interoperating 
with each other justifies their cooperation :)
I don't expect Red and R3 to be compatible because Red is compiled 
and R3 is interpreted. Both models have their place and their strengths. 
That doesn't mean that they can't be compatible with each other where 
that makes sense, or interoperate with each other where that makes 
sense.
DocKimbel
20-Oct-2012
[2917]
I don't expect Red and R3 to be compatible because Red is compiled 
and R3 is interpreted.
 I hope you like surprizes then. ;-)
BrianH
20-Oct-2012
[2918x4]
I don't expect it, but that doesn't mean that we won't do our best 
to fake it :)
Are you planning to use the direct binding model, and value slots?
Out of curiosity...
Assuming that Red will be compiled (even JIT), the actual semantics 
will be different even if the outside behavior will appear to be 
similar enough that it won't matter for most people, hence the "fake 
it" phrase. It would be a disservice to us if we got a compiler, 
which has definite if minimal disadvantges over an interpreter, without 
getting the advantages of a compiler such as a practical optimizer. 
The behavior of R3 and Red could be quite similar to an outside observer 
that doesn't look closely, but they would require different optimization 
strategies to get the most efficient code. In that way I don't expect 
them to be compatible - they would likely be even less compatible 
than R2 and R3. But that's not really a problem :)
DocKimbel
20-Oct-2012
[2922x2]
Are you planning to use the direct binding model, and value slots?
 That's already there in Red runtime.
Red runtime library
BrianH
20-Oct-2012
[2924]
Sorry for the dumb questions, I've been too busy to participate yet 
:(
DocKimbel
20-Oct-2012
[2925]
Semantics will be very close, probably 99% close, as I've moved from 
a statically typed system to an hybrid static/dynamic typing system.
BrianH
20-Oct-2012
[2926]
So, no lexical binding? Or do you plan to infer lexical binding where 
possible, and use direct where not?
DocKimbel
20-Oct-2012
[2927x3]
So, if all goes well, you'll have the full REBOL model + optimizations. 
There are many ways to optimize and on many different abstraction 
levels. Yet, some atomic operations will remain "unoptimized", like 
series atomic manipulations (maybe we'll figure out a way to optimize 
them too in the future).
Lexical binding will be added when we'll add contexts (in a few weeks), 
along with dynamic binding (yes, you'll be able to have fun with 
BIND again ;-)).
In a couple of days, I'll release the first Red alpha with a blog 
entry to describe it, you'll be able to get a better picture of what's 
in Red already and where it's heading.
BrianH
20-Oct-2012
[2930x2]
So, my module system will end up being of more use to you. I'll be 
sure to write up that TRANSCODE/part option request for R3 in CureCode, 
for your reference.
I ran into the need for that with multi-scripts.
DocKimbel
20-Oct-2012
[2932x2]
Well, maybe. :-) I must admit I haven't yet dived into R3 module 
system to see if it fits well our needs.
our needs
: they are not yet clearly defined, btw.
BrianH
20-Oct-2012
[2934]
It isn't specifically for R3. Most of the design decisions were based 
around the constraints of the direct binding model, and of making 
it as simple as possible for people who are not used to modular programming 
to use. Beyond that, we just made it as powerful as possible without 
killing the usability.
DocKimbel
20-Oct-2012
[2935]
Being simple

 is probably the most important feature I would require from a module 
 system.
BrianH
20-Oct-2012
[2936x2]
There are still some parts that I could use a little help with though, 
like resolving import cycles. And there are some bugs and/or weaknesses 
in the native code that I've had to work around in my patches collection.
The "being simple" part was mostly driven by Carl. I tried to make 
it simple, but it took some doing to make it even more simple for 
Carl. There's a lot of subtle code in there to make it simple enough 
for Carl to want to use it.
DocKimbel
20-Oct-2012
[2938]
Resolving import cycles

: we've solved that in Red/System compiler by having a simple "included 
files" list and it stops inclusion if already done once. But we do 
that at compile-time, so it's easy.
BrianH
20-Oct-2012
[2939x3]
I thought that something similar would work for R3, but haven't done 
it yet. R3 releases kind-of stopped before I got the chance.
A module system is where you would find a lot of places where the 
internals would be different, due to the compilation thing, but the 
external behavior could appear to be the same. There are a lot of 
nice tricks in R3's module system, and I've gone through a lot of 
trouble to make it possible to have the module system be handled 
by a preprocessor that doesn't have to execute any of the code in 
the modukle bodies to resolve dependencies. It was designed with 
preprocessors like prebol or Ladislav's include in mind. And all 
of that is in the specifications of how modules are declared, not 
in the actual mechanism that implements it, so the concepts would 
be portable to Red.
There's no reason that Red couldn't also implement compressed scripts, 
checksums, multi-scripts and embedded scripts the same way too. All 
of those apply to all scripts, not just modules, so they could work 
the same way for runtime-compiled Red scripts as well.
DocKimbel
20-Oct-2012
[2942]
Certainly, but AOT compilation would be a big plus. Also, in Red 
we need to modularize the compilation process itself, so  we can 
do incremental AOT compilation on multi-files projects instead of 
having to rebuild everything (include runtime libraries) each time. 
We need to, somehow, match those compilation units with the higher-level 
module system (it's not the only option, but probably the most simple).
BrianH
20-Oct-2012
[2943x3]
Multi-scripts would be mostly a packaging method. It could even help 
AOT compiled scripts at the script distribution phase. I'm thinking 
of install-time-compiled scripts, for instance. It would also help 
with mixed-Rebol-Red projects like what I described above for R3 
extensions. Also, it could help for data files in some cases, or 
metadata embedded in other files.
Well, the R3 module system is designed to be statically resolvable, 
so the same method would work for resolving Red modules in a project.
That is why Needs and Exports are headers rather than function calls, 
and export and hidden are module-code-block keywords instead of functions. 
You can determine the whole dependency chain by loading the script, 
examining the header, and searching the top block of the source for 
the keywords.