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

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp1209
r3wp4537
total:5746

results window for this page: [start: 1001 end: 1100]

world-name: r4wp

Group: #Red ... Red language group [web-public]
Pekr:
15-Jun-2013
8 times slower - do you consider it bad, or good? I mean - in regards 
to how is Red/System designed ...
Kaj:
15-Jun-2013
I'm torn between defending Red/System and defending my fellow countryman
DocKimbel:
15-Jun-2013
Knuth's code could compete at C obfuscated contests. Arnold seems 
to have done a literal translation to Red/System but keeping the 
same obfuscated symbols, so not easy to read. However, it seems at 
first look that the algorithm has been well preserved.
Pekr:
15-Jun-2013
Yes, you were comparing

 - wrong - I was not comparing anything, nor complaining to anything 
 ;-) My question was more general, headed towards if in regards to 
 red/system architecture, the measure of being 8x slower than C (in 
 a concrete example guys were talking about), is good, or bad. I simply 
 don't remember outcome of prior discussions, that's all.
Kaj:
15-Jun-2013
In limited tests so far, the indication was that Red/System was roughly 
as fast as unoptimised C, half as fast as optimised C compiled with 
GCC
DocKimbel:
15-Jun-2013
Arnold, if you clean up the code and make it look more like Red/System 
and less like C, we could add it to the library folder in the Red 
repo/
Kaj:
15-Jun-2013
However, it's more logical to put constants last, and it can also 
generate more optimal code in Red/System
Arnold:
16-Jun-2013
Thanks for the compliment Doc, not really sure what you mean exactly 
by making it more like Red/System and less C: use more descriptive 
names? I will take a closer look at some ed/System examples out there.

Thanks Kaj for finding those and for the tips, the size of MM makes 
it the same in effect in this case, but it has to be <= then. Program 
not crashing, I was lucky then! off-by-one errors? My index goes 
from 1 up, where in C it is from 0 up, I had to debug this to make 
sure elements were swapped in the same way as in the original program. 
That is also why I declare KKP and LLP to as to save from adding 
1 to KK and LL over and over again. 


Knuth's algorythm was the first one I found, and I knew already of 
its existence, so it made sense to use what you have. Sure my Red/System 
code is not optimised.


Going to work on it now and tomorrow, and later I take on the Twister. 
It is a good exercise!
DocKimbel:
16-Jun-2013
Actually, your work on porting that algorithm has many values, like 
showing us the trade-offs of 1-base vs 0-base indexing at Red/System 
level.
DocKimbel:
16-Jun-2013
About "making it more like Red/System" means applying Red/System 
coding style, which is not formaly defined, but it is very close 
to the official Rebol one. For example, the naming rules for variable 
and function names are the same as in Rebol.
DocKimbel:
16-Jun-2013
CPU are optimized for 0-based accesses. Using 1-base indexing will 
make Red/System a bit slower than it needs to be.
PeterWood:
16-Jun-2013
If register variables do improve performance I was going to add register 
variables to the Red/System V2 wish list.
Arnold:
16-Jun-2013
I would certainly expect that to be the case. My code is just Red/System 
compilable and executable.
DocKimbel:
16-Jun-2013
I was going to add register variables to the Red/System V2 wish list.


This is not required as one of the first change I have in mind for 
Red/System 2.0 is adding a good registers allocation method to backend 
code emitters.
Arnold:
16-Jun-2013
Put it on for the world to know :)

The mersenne twister has a lot of examples in other languages. finding 
out the closest 1 to red/system.
Kaj:
16-Jun-2013
Arnold, sorry about forgetting the parentheses. They will really 
be gone in Red/System v2 :-)
Arnold:
16-Jun-2013
About the pointer, I got the example of pointer/value: value somewhere, 
not saying from the fossil repository but might very well be so. 
The pointer: :value suggested confuses me. I tend to stick to what 
I had figured out. I prefer to avoid pointers almost always at all 
costs because of the trouble they can be. A good description is needed 
of how they are best used in  Red(/System).
DocKimbel:
17-Jun-2013
Arnold, if you have specific questions about pointers in Red/System, 
maybe you could ask them on SO and make the first SO entries for 
Red?
Arnold:
17-Jun-2013
I copied this from the documentation: http://static.red-lang.org/red-system-specs.html#section-4.8
paragraph 4.8.3 Dereferencing
Kaj:
17-Jun-2013
http://static.red-lang.org/red-system-specs.html#section-4.8.8
Arnold:
17-Jun-2013
Time for the Red rebolution to improve the readability of software.

I have been playing with the Mersenne Twister code, from C to Red/System. 
There is no unsigned integer in Red/System?
Arnold:
17-Jun-2013
Unsined integers is on the wish-list for Red/System v2 https://github.com/dockimbel/Red/wiki/Red-System-v2-Wish-List
point 29
Maxim:
17-Jun-2013
one question for Red/System.  


can it already, ( or is it planned ) to export static libs for use 
within (C/C++, other?) compiler/linkers?
Arnold:
20-Jun-2013
The deobfuscating Knuth's random program project is progressing into 
its final stage. It turned out that with getting the results of the 
program the same only the first part of the puzzle got solved. To 
use it in real programs you use the provided ran_arr_next function. 
This involved some pointer aritmetic that is not 100%  supported 
by Red/System. I finally got the function to produce the same results 
as the C version. The downside is it is now quite a mess with pointer 
indeces and other variables, so a lot of cleaning up to do and/or 
rework only using the index on the array approach.
DocKimbel:
20-Jun-2013
This involved some pointer aritmetic that is not 100%  supported 
by Red/System.
 What is it lacking precisely?
Arnold:
20-Jun-2013
my trouble seems to arise from the different roles the array and 
the pointer play in the C code vs the Red/System code. In C the pointer 
is used as indicator for initialisation and signals when a kind of 
reshuffle is required and it points to the next generated value. 
In Red/System the array points to the current/next value and a pointer 
is not needed, and you can no longer use it as before to signal the 
status. This complicates things in this case.
DocKimbel:
20-Jun-2013
You seem quite confused about pointers in Red/System. 


1) There's no "array" as distinct entity in Red/System, but you have 
indexed access, so you can "simulate" arrays to some extent.


2) "In C the pointer is used as indicator for initialisation and 
signals when a kind of reshuffle is required and it points to the 
next generated value." I don't understand this sentence, you should 
stick to C terminology (terms like "signals", "reshuffle" and "generated 
value" are alien to me in a C language context).


3) "In Red/System the array points to the current/next value and 
a pointer is not needed, and you can no longer use it as before to 
signal the status." I don't understand this one either... There's 
no array, only pointers. "to signal the status" has no meaning to 
me...sorry.
DocKimbel:
20-Jun-2013
I think you have a complicated mental representation of what pointers 
and arrays are in C and Red/System. It's simpler and more straightforward 
than your descriptions. Basically, Red/System pointers act the same 
way as C ones (including "array" support). The only difference is 
the base for indexed accesses (1 vs 0).
XieQ:
21-Jun-2013
@Arnold I write the Mersenne Twister random function in Red/System 
according to an educational C standard library implementation ( http://code.google.com/p/c-standard-library/source/browse/src/internal/_rand.c
). Hope you find it useful. you can read it from here: https://gist.github.com/qtxie/5831308
Kaj:
21-Jun-2013
A good operating system will free the memory when the process ends, 
but it's a bad idea to not do your own cleanup of memory and other 
resources
Kaj:
21-Jun-2013
The need to make variables known at the root level of the program 
is a limitation of the current Red/System compiler
DocKimbel:
21-Jun-2013
The need to make variables known at the root level of the program 
is a limitation of the current Red/System compiler

 Actually, it's not a limitation, it's a design decision based on 
 use cases like this one: https://github.com/dockimbel/Red/issues/84
Arnold:
21-Jun-2013
waarde is the dutch word for value, this is displaying the random 
generated value, it is between double quotes. In the C output I use 
something like " rval= " rval where in the Red/System I used " rval: 
" rval. This is for my convenience to tell both apart when the terminal 
windows look all the same.

It makes sense to circumvent issues like 84 by this method. Good 
to know this, thank you for explaining.
XieQ:
21-Jun-2013
One bug need to mention:

After doing mod operation, I use the result as index to access the 
array,it's OK in C, but will cause strange behavior in Red/System. 
Because mod will produce 0 and Red/System use 1-base array.
n: c + state-half-size % state-size
Then I modified the code as below to solve this issue:
n: c - 1 + state-half-size % state-size + 1
XieQ:
21-Jun-2013
I also do a benchmark. It's seems too early to do this, but I can't 
contain my curiously ;-)
Produce 99999999 random numbers

Compare to no optimizition C version, the Red/System version is about 
1.3 times slower.
Compare to an optimizition C version, it's about 2 times slower.
Not bad! :-)
More detail: https://gist.github.com/qtxie/5835643
DocKimbel:
22-Jun-2013
XieQ, indeed impressive results, I usually expects current Red/System 
to perform about 4-5 times slower than optimized C.
Arnold:
22-Jun-2013
Including a /secure that is, there are even other RNG's out there 
suitable for this purpose waiting for their transcoding to Red/System.
DocKimbel:
22-Jun-2013
Anyway, your implementation is a good hint that Red/System 2.0 should 
be able to give us general performances between unoptimized and optimized 
C code.
DocKimbel:
22-Jun-2013
BTW, Arnold's and XieQ's work, and my own recent struggling with 
1-based Red/System low-level issues are hints that I need to reconsider 
1-base vs 0-base indexing in Red/System. Low-level algorithms are 
not 1-base friendly.
Arnold:
22-Jun-2013
We, no I, limited myself to keep as close to the original as possible. 
Also because of the obfusction factor of the source. I believe much 
of the construction could be made more like in the REBOL way of doing 
things. A C program just is not a Red/System program. My goal was 
to get a working program reproducing the same result in the shortest 
time. Because I had little idea what the original program did because 
it is complicating things on purpose this was the way to do it. Now 
based on this useable program it can be made more Red/REBOL-like 
step by step.

I do feel for you, for indeed a lot of stuff out there is C or 0-based 
and it brings its problems along, but the next step in bringing Red/System 
to 0-based is having Red being 0-based as well?
DocKimbel:
22-Jun-2013
[...] the next step in bringing Red/System to 0-based is having Red 
being 0-based as well?


No, it's not directly related. Implementing low-level algorithms 
that require working with index 0 is not the common usage of Red. 
Also, the +/-1 offset required in such case has no noticeable performance 
impact in a Red program while in Red/System, in a tight nested loop, 
the impact could be significant.


The most important part in considering a 0-based indexing system 
for Red/System is mainly helping the user and avoiding common programming 
errors (even I get caught by it from time to time, but it's probably 
due to my strong C background).
Kaj:
22-Jun-2013
The problem is that there is no final solution. In practice, I have 
mixed Red and Red/System code in many places, and I'm already often 
mixed up between the two. So if you change Red/System to be 0 based, 
there will be a new class of errors where programmers think in Red 
in their Red/System code, or in Red/System in their Red code. And 
as Arnold hints at, this will create an eternal pressure from technical 
people to make Red 0 based, and then we have given up on the human 
centered goals of REBOL and are back at square one - which will then 
have to be renamed square 0
Kaj:
22-Jun-2013
Doc, I don't know if you've done other tests, but in the benchmarks 
so far Red/System was only 4 times slower than optimised C in floating 
point code. For integer code, it was around twice slower than optimised 
C, so the Mersenne Twister confirms this
Kaj:
22-Jun-2013
It's a bit confusing, but Red/System integer is as fast as unoptimised 
C (x 1 in function calling, 1.3 slower in hard integer as measured 
by XieQ), twice as slow as optimised C, and Red/System floating point 
is four times as slow as optimised C
Kaj:
22-Jun-2013
Which also means that Red/System floating point is twice as slow 
as unoptimised C
Arnold:
22-Jun-2013
Any fine examples of how to program refinements in Red(/System) I 
can use to copycat?
Kaj:
22-Jun-2013
Red/System doesn't have refinements. Refinements in Red are almost 
exactly like in REBOL
Kaj:
22-Jun-2013
As a function, you'd have to call that SEED or seed-random in Red/System
Kaj:
23-Jun-2013
I think Red/System counts as beta, as far as v1 is concerned
Andreas:
23-Jun-2013
Red/System (current master, g0c9c1bf): 2.5s
GCC 4.8.1 -O0: 1.9s
Clang 3.3 -O0: 1.6s
Clang 3.3 -O2: 0.6s
GCC 4.8.1 -O2: 0.5s
Arnold:
23-Jun-2013
We

 are a team! Yoho!! According to Frank Ruben on the Red mailinglist. 
 He has a question about interfacing a C app in Red/System.
XieQ:
24-Jun-2013
Now in Red/System, we can't pass a function as parameter to Red/System 
FUNC,
but we can pass it to external C FUNC, right?


cmp-func!: alias function! [left [byte-ptr!] rihgt [byte-ptr!] return: 
[integer!]] 
quick-sort: func [
	base	 [byte-ptr!]
	n		 [integer!]
	size	 [integer!]
	cmp-func [cmp-func!]	
][
	; can't use cmp-func in this function
]
DocKimbel:
24-Jun-2013
You should try passing the function! pointer as integer! then type-cast 
it inside the function. IIRC, function! cannot be  yet used in a 
Red/System func spec block.
XieQ:
24-Jun-2013
Red/System []


cmp-func!: alias function! [left [byte-ptr!] right [byte-ptr!] return: 
[integer!]]

cmp-int: func [
	left [byte-ptr!] right [byte-ptr!]
	return: [integer!]
	/local a b
][
	a: as int-ptr! left
	b: as int-ptr! right
	a/value - b/value
]

bar: func [
	cmp-func [cmp-func!]
][
	a: 1
	b: 2
	print cmp-func :a :b
]

bar :cmp-int
DocKimbel:
24-Jun-2013
I guess I should complete the function! support at some point before 
starting on Red/System 2.0.
Kaj:
24-Jun-2013
Red has no floating point yet, only Red/System
Pekr:
25-Jun-2013
either I have mess again on my system, or there's a compilation error 
for me, when trying to do:


do/args %red.r "-dlib -v 0 %red/bridges/java/hello.red -o %../red/bridges/java/hello" 


Script: "Red/System IA-32 code emitter" (none)
*** Compilation Error: missing argument
*** in file: %structures.reds
*** in function: exec/~java-instantiate-abstract
*** at line: 166
*** near: [jni-env/jni/NewObject]
Bo:
25-Jun-2013
Is it still true that Red/System doesn't support loading/reading 
files?
Bo:
25-Jun-2013
It sure would be nice if we had a centralized repository for Red 
and Red/System examples, like we have for Rebol at Rebol.org.
Bo:
25-Jun-2013
In Rebol, I can put a 'halt at the end of my script to be able to 
read output from my script.  Can I do a similar thing in Red/System?
DocKimbel:
26-Jun-2013
I just need to make some addition to the Red/System compiler before.
Bo:
26-Jun-2013
Are there any tutorials on how to write programs using Red?  (Not 
Red/System - I know where the documentation is for that.)
Kaj:
26-Jun-2013
Now that Red/System can read binary files, I could make a facility 
in Red, but it would have to do without a binary! type. I could return 
a handle to low level memory as an integer!
Kaj:
26-Jun-2013
However, there would currently be no facilities to access the content 
at the Red level, so you would have to pass it to Red/System functions 
to do anything with it
Arnold:
26-Jun-2013
Hey invalid Red program if I #include a reds program? Complaint about 
/System
*** Syntax Error: Invalid Red program
*** line: 1
*** at: {/System [^M
Kaj:
26-Jun-2013
Red is not Red/System, is it?
Kaj:
26-Jun-2013
To write Red/System within Red, you need to enclose it in
Kaj:
26-Jun-2013
#system-global [ ]
Kaj:
26-Jun-2013
It's usually me who uses it, and it usually #includes Red/System 
files :-)
Kaj:
26-Jun-2013
I guess Red #include could be made to inspect the type of the file, 
and add an implicit #system-global [ ] if it's Red/System
Arnold:
26-Jun-2013
That would be a nice improvement indeed as the file extension is 
reds and the header is Red/System
Bo:
26-Jun-2013
I have this bit of Red/System code that I wrote, but for some reason, 
it just closes the console window.  So I don't know if there is an 
error, and if there was, how would I debug it?

#include %../C-library/ANSI.reds

img1: as-binary 0
size1: 0
img2: as-binary 0
size2: 0

img1: read-file-binary "img1.bin" :size1

print-line img1
print-line size1

print-line as integer! img1/1

img2: read-file-binary "img2.bin" :size2

print-line img2
print-line size2

img3: as-binary size1

i: 0
until [
	i: i + 1
	img3/i: img2/i - img1/i
	i = size1
]

write-file-binary "img3.bin" img3 size1

until [no]
PeterWood:
27-Jun-2013
I am not familiar with Kaj's Libraries but I searched ANSi.reds and 
the Red/System runtime to try to find where as-binary is defined. 
I guess it must be in one of Kaj's other libraries.


I noticed the ANSI.reds includes %common/FPU-configuration.reds but 
couldn't find that in Kaj's Repo. (It doesn't sound as though it 
would include a definition of as-binary though).
DocKimbel:
27-Jun-2013
Bo, it seems you're starting Red/System programs by clicking on them? 
If that's the case, it's not the best way to debug such programs. 
You need to open a DOS window and launch the programs from there. 
The window will never close, so you'll be able to see all the messages 
and avoid doing infinite loops at the end of your code.
Arnold:
27-Jun-2013
I stumbled upon a possible bug with local variables.
flexfun-s: function [s [string!] return: [string!]][return s]
flexfun-i: function [i [integer!] return: [integer!] ][return i]

flexfun: function [n [integer! float! string!] return: [string! integer! 
logic!] /local rv uitstr uitint][
    rv: type? n

    either "string" = rv [uitstr: flexfun-s n][uitint: flexfun-i n]
]

When I do not declare the uitstr and uitint local variables, the 
compiler makes a ~local extra and notices double declaration:
Compiling to native code... 

Script: "Red/System IA-32 code emitter" (none)

*** Compilation Error: duplicate variable definition in function 
exec/f_flexfun  

*** in file: %/Users/Arnold/data/develop/red/testscripts/flextst1.red 
*** at line: 126 
*** near: [func [/local ~n ~local ~rv ~local ~uitstr ~uitint] [
        push ctx194/values
DocKimbel:
27-Jun-2013
For building an x86 system compatible apk, the following changes 
are required in the build script:


make-dir/deep bin-dir/lib/armeabi => make-dir/deep bin-dir/lib/x86
-t Android
 => "-t Android-x86"
/libRed
 => "Red"
Kaj:
27-Jun-2013
Arnold, there is not one account for red.esperconsultancy.nl. Each 
Fossil repository under there has its own account system. But you 
don't need accounts for reading; they're public repositories
Bo:
27-Jun-2013
OK.  Next enigma about Red/System that I ran into.  Consider the 
two following sets of code and output.  Why are they different?

Code 1:
	im1: as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3))

 print-line as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3))

Output 1:
...
96
99
107
111
105
104
100
99
100
98

Code 2:
	im1: as-integer ((img1/r / 3) + (img1/g / 3) + (img1/b / 3))
	print-line im1

Output 2:
...
4260192
4260451
4260203
4260207
4259945
4259944
4259940
4260451
4260196
4260194
Kaj:
27-Jun-2013
It could be a Red/System bug, or it could be a result of the code 
you're not showing. Can't tell
Kaj:
27-Jun-2013
You did upgrade your Red/System, didn't you?
Bo:
27-Jun-2013
Yes, I updated Red/System yesterday from Github.
PeterWood:
27-Jun-2013
The calculation is okay.

Code:

Red/System []

red: as byte! 240
green: as byte! 120
blue: as byte!  60


greyscale: ((as integer! red) / 3) + (as integer! green) + (as integer! 
blue)

print [greyscale lf]

OUTPUT:
-= Red/System Compiler =- 
Compiling /Users/peter/VMShare/Code/Red-System/test.reds ...
Script: "Red/System IA-32 code emitter" (none)
Script: "Red/System Mach-O format emitter" (none)

...compilation time:     122 ms
...linking time:         10 ms
...output file size:     16384 bytes
...output file name:     builds/test
260
PeterWood:
27-Jun-2013
Oops, here's the proper code and correct answer:

Red/System []

red: as byte! 240
green: as byte! 120
blue: as byte!  60


greyscale: ((as integer! red) / 3) + ((as integer! green) / 3) + 
((as integer! blue) / 3)

print [greyscale lf]

OUTPUT
...compilation time:     133 ms
...linking time:         13 ms
...output file size:     16384 bytes
...output file name:     builds/test
140
Bo:
27-Jun-2013
I'm amazed by how fast Red/System is.
PeterWood:
27-Jun-2013
Kaj do you know if Red/System generates the same code for :

	img1/value and img!/1 ?
Bo:
27-Jun-2013
There is no way for Red/System to read a directory listing, is there?
Bo:
27-Jun-2013
I'm only looping 20'000 times or so...not a lot for Red/System to 
handle. ;-)
Bo:
27-Jun-2013
Can Red/System read a directory listing?
Pekr:
28-Jun-2013
james & kaj: I have JDK installed too, you should be sure, that you 
can call java, javac from whatever dir = it is in the system lookup 
PATH. And - Rebol was downloading supporting tools, then it hang 
in console, but in fact, there was a dialog box hidden in the background, 
asking me for write permission. Unless you allow that, the tools 
are not going to be saved into requested directory ...
Arnold:
28-Jun-2013
Does the #system-global [#include %random-taocp.reds] change 
random-seed: function [seed [integer!]][
    random-taocp/ran_start seed
]
to not longer working?
Kaj:
28-Jun-2013
A Red program is very different, because it includes the entire Red 
environment and runtime, which is much larger than the Red/System 
environment
Kaj:
28-Jun-2013
How are you calling your Red/System function from Red?
Kaj:
28-Jun-2013
That can't work. You can't call Red/System functions in Red
Kaj:
28-Jun-2013
Are you making calls from Red to Red/System, or are you only including 
a #system-global []?
Arnold:
28-Jun-2013
I shared all relevant files. In my view I include using the #system-global 
in randomf.red and I make the calls also via this intermediate red 
script calling random-taocp/ran_start from the random-taocp context 
in the %random-taocp.reds script
Kaj:
28-Jun-2013
Well, there you have it. In randomf.red you're using Red/System functions 
and contexts as if they're Red code. They're simply not defined in 
Red
Kaj:
28-Jun-2013
To call Red/System code from Red, you have to write a ROUTINE to 
wrap the differences and marshall the arguments:
Bo:
28-Jun-2013
I'm diving into my first attempt at recursion in Red/System.
DocKimbel:
28-Jun-2013
Kaj: it worked fine on my Ubuntu system. Did the script download 
the binaries in builds/tools/ ? If not, can you please trace the 
reason why it didn't?
Arnold:
29-Jun-2013
You can't call Red/System functions in Red

 that almost literally made me fall of the chair. Somehow I really 
 expected that to be inherently supported. I cannot make any chocolat 
 from the routine example atm, but as I see it now, it requires me 
 to reprogram/copy my Red/system program to Red and renaming FUNCTION 
 to ROUTINE. This means double maintenance in my eyes. 

This is definitely a point to add to the wishlist if you asked me.
1001 / 574612345...910[11] 1213...5455565758