r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Tech News] Interesting technology

Henrik
3-Sep-2008
[3267]
About java being fast: It's speed is outweighed by its size. REBOL 
may not be extremely fast, but it's nimble enough to not let you 
notice most of the time.
Dockimbel
3-Sep-2008
[3268]
I can write REBOL code that is faster than the equivalent code in 
Java
. Can you give us a short example ?
BrianH
3-Sep-2008
[3269x2]
If your REBOL code is not very fast, it may be algorithmic. My REBOL 
code is rather fast, though that is because I hand-optimize and don't 
use REBOL where it isn't appropriate. I don't generally use Java 
because it is never appropriate for my work, but if it were I might 
use it. I don't use REBOL to write C code.
Anything that is native-heavy, uses parse a lot, or does structure 
manipulation can be made to be really fast in REBOL. Anything interpreter-heavy 
is likely not. If what you are doing is basic math, consider a calculator 
(or C).
Dockimbel
3-Sep-2008
[3271x2]
Anything interpreter-heavy is likely not

 So, basically, you're saying that REBOL interpreter *is* slow. Parse 
  dialect is cool, but it's not REBOL dialect. If you make a fair 
 comparison, REBOL is orders (2-3) of magnitude slower than Java. 
 I guess that even Rebcode is slower than Java.
http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=rebol&lang2=java
BrianH
3-Sep-2008
[3273x4]
Doc, I have a lot of trouble coming up with a short example in Java 
- Java isn't really useful for that kind of thing. Almost any one-line 
REBOL program would be faster than the equivalent Java program. The 
REBOL interpreter is slower than JIT'ed Java code, after you factor 
out the JIT overhead. REBOL is more than DO though - it has a lot 
of high-level operations that are quite useful and fast. If I try 
to write code in REBOL using Java-style algorithms it will be slow. 
If I try to write Java code using REBOL-style techniques, I would 
have to reimplement most of REBOL first, and it would be slower.
Remember, the DO dialect is just one of many. This will be even more 
the case in R3 (in theory) as it is proposed that user-defined datatypes 
include function types. This would allow you to retrofit REBOL with 
different execution engines - including JIT'ed dialects if you like.
There is no such thing as a fair comparison between Java and REBOL 
- the closest would be to show how a program written to take advantage 
of one language's strengths would be wors when translated to the 
language of the other, and then vice-versa.
wors -> worse
Dockimbel
3-Sep-2008
[3277]
My concerns about REBOL execution speed are related to my will to 
use REBOL for every programming tasks, so I don't have to rely on 
other languages.
BrianH
3-Sep-2008
[3278x2]
That would be nice (especially for us if you were to do so, given 
what you have written so far). Still, you should write to the strengths 
of the tool. I actually come pretty close right now - Much of the 
code I write in other languages is actually generated by REBOL scripts, 
something I would never dream of doing in Java.
If it makes you feel better, know this: You can bet that I will be 
making user-defined function types :)
Dockimbel
3-Sep-2008
[3280]
I wasn't talking about relative strengths of languages but pure execution 
performances. I know how to implement fast algorithms in C, Java 
and REBOL. In REBOL, you can only find some "tricks" that will make 
 your code faster, but there's no intrinsic feature of REBOL language 
that could change the complexity of an optimized algorithm (that 
kind of case would fall in my "fair comparison" view).
BrianH
3-Sep-2008
[3281x2]
The intrinsic feature of REBOL that changes the complexity of an 
optimized algorithm, for me, is runtime code generation. You can't 
make a fair comparison to C or Java about that though - you have 
to compare to Lisp or such. Tool for the job though.
My code wouldn't compile though. It is fast as-is, and I would rewrite 
it if REBOL were compiled to be fast then.
Dockimbel
3-Sep-2008
[3283]
REBOL has nice and clean abstractions that make writing code much 
easier and much more pleasant, IMHO, it fails to become a general 
programming language mainly because of lack of performances. As long 
as you deal with a lot of I/O (like in a Cheyenne) or waiting for 
user event (like in VID/View), that's not a big showstopper, but 
when you need to process big amounts of data in memory, you have 
to rely on another language to do the job in acceptable times.
Gregg
3-Sep-2008
[3284x2]
It depends on your needs, which is why it's important for Carl to 
know what has the most value for us, so he doesn't spend time on 
things that don't have as much value.
When VB1 came out, people would talk about how much faster C was 
for Windows apps. I would counter that VB was much faster than C...usually 
6 to 12 months faster. :-) I can argue the same for REBOL in many--though 
not all-cases.
Dockimbel
3-Sep-2008
[3286]
Runtime code generation can reduce size of source code and make it 
more elegant, but I didn't saw yet, in my own code, any benefit on 
algorithm complexity (the big O notation).
BrianH
3-Sep-2008
[3287x2]
I agree, Doc. I tend to do complex processing on smaller amounts 
of very complex data, so REBOL is very fast for me.
Very little math, much parsing and structure manipulation.
Gregg
3-Sep-2008
[3289]
I've only hit a couple things where REBOL isn't fast enough. Animation 
(obviously), and longest-common-subsequence algorithm (Rebcode version 
was much faster, but still not fast). And if I could save JPGs natively 
from REBOL, I could eliminate one of my largest external dependencies 
(ImageMagick).
Dockimbel
3-Sep-2008
[3290]
Gregg: as an old VB coder (still using it these days), I agree. But 
there's lot of applications you just can write in a slow executing 
language, and I *really* would like to only code in REBOL.
BrianH
3-Sep-2008
[3291]
For most of my code, it isn't interpreter execution time that makes 
REBOL more efficient. A typical REBOL program for me saves me days 
or weeks of work, sometimes more.
Gregg
3-Sep-2008
[3292]
I agree Doc. But even when I wrote VB, I often supplemented it with 
DLLs written in something else, so I'm OK with having to do that 
with REBOL, but I need to be able to do that easily--more easily 
than I do today.
Dockimbel
3-Sep-2008
[3293x2]
Rebcode could have been a solution, but it seems quite low priority 
for Carl.
I tend to think that JIT compiling block! values to native code before 
executing would be the best way (rather that rely on a very different 
dialect, like Rebcode).
BrianH
3-Sep-2008
[3295]
Rebcode will come as a side-effect of user-defined function types, 
which require user-defined datatypes, which requires the plugin model, 
which requires modules, which may require changes to object!, which 
are partly based on changes to the core that result from his current 
VID work.
Dockimbel
3-Sep-2008
[3296x3]
But I guess that even a JIT approach would require to give up on 
a few features of the DO dialect.
:-D
Brian, you're a good advocate for Carl's strategy, but Rebcode already 
exists without all that dependency chain and it's even usable, it's 
just a pity it didn't make it in 2.7.6 and Encap.
BrianH
3-Sep-2008
[3299]
Yes, the compilable dialect would have different semantics than the 
DO dialect but could look superficially the same, and execute a lot 
of the same code (not mine, of course). We have done this before 
in the R1 to R2 transition when we switched from a Scheme-like engine 
to a Forth-like engine without changing the syntax (except for getting 
rid of ELSE). I already have some ideas about how to do this - it's 
on my to-do list.
Dockimbel
3-Sep-2008
[3300]
What would be the compilation unit in your view of "compilable dialect", 
function! or block! values ?
BrianH
3-Sep-2008
[3301x3]
I am well aware of how the old rebcode worked - I was the main beta 
tester. It had the same dependencies then as well, though the execution 
engine being internal made the chain a little different. It was also 
unstable, buggy and insecure.
The natural compilation unit in REBOL is the function. That is how 
the different function types have different execution models already.
It is only the function type that makes the data in a block considered 
code.
Dockimbel
3-Sep-2008
[3304x2]
Function values
(sorry)
BrianH
3-Sep-2008
[3306x3]
Right. Functions are values in REBOL, and how they are interpreted 
(or compiled) depends on their datatype.
By the way, DELECT uses some of the same techniques that rebcode 
did to be fast.
The new function binding model in R3 makes Rebcode not as fast in 
R3 as it was in R2, if it uses the same semantic model. In order 
to be worth including we would have to change the semantic model 
accordingly.
Dockimbel
3-Sep-2008
[3309]
I would choose block-level for a JIT compilation in REBOL, that would 
allow to compile more semantics than at function level. For example 
[do append [print] "hello"] could be compiled using block-level JIT.
BrianH
3-Sep-2008
[3310]
I would keep the DO dialect as is - it would be faster that way, 
because Java is only faster after you factor out JIT overhead. By 
having the compilation overhead at function creation time you could 
plan for it accordingly.
Dockimbel
3-Sep-2008
[3311x2]
I don't agree for Java JIT overhead. Programs spend most of their 
time in loops where JIT overhead becomes rapidly unnoticeable (loops 
compiled code is cached).
Btw, I guess that Java JIT compiler can run in their own thread, 
so also being able to take real advantage from multi-core CPU.
BrianH
3-Sep-2008
[3313x2]
There would be 2 things you would have to give up in a compilable 
dialect of REBOL, if you want it to be worth it:

- Code blocks that aren't statically determinable at function creation 
time (unlike your example above, which could be partially evaluated)

- Functions that could be edited in place, or hot-patched (already 
gone in R3)

If you don't give these up you would be adding compilation overhead. 
Admittedly, Java isn't the right language to emulate here - Forth 
or other stack languages would be better, as they are closer to the 
REBOL execution model and compiled Forth can be drastically faster 
than the best Java code.
There are several functions in REBOL that operate on their argument 
blocks following the DO model. If you make those functions require 
a literal block you could compile REBOL as-is.
Dockimbel
3-Sep-2008
[3315]
Forth vs Java: well maybe it was very true 10 years ago, but since 
then, the gap is closing with some great  improvements in compilation 
like Java's Hotspot VM.
BrianH
3-Sep-2008
[3316]
That's why I mentioned "other stack languages". There has been a 
lot of research in that camp too - they just name their languages 
other names than Forth. I think that some of the research in type-inferenced 
stack languages will eventually make Java and .NET faster too.