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

World: r4wp

[#Red] Red language group

Kaj
2-Jul-2013
[9252]
R2
Bo
2-Jul-2013
[9253x3]
R2 couldn't do it nearly fast enough on the Pi.
However, it was fast enough on a powerful workstation.
R2 could even handle several cameras simultaneously on a powerful 
workstation (maybe 4 cameras at 1.3 megapixels @ 8fps).
Kaj
2-Jul-2013
[9256]
Not bad, but not available on ARM
Bo
2-Jul-2013
[9257]
Right.
Kaj
2-Jul-2013
[9258]
So can you do without the Broadcom specs now?
Bo
2-Jul-2013
[9259x2]
I've found a way around it for now, but I've had to make some concessions 
that I'm not very happy with.  My goal is to still get my hands on 
those Broadcom specs so I can get better performance and flexibility.
My motion detection executable on the Pi is 30KB.  The same executable 
compiled for Windows is 15KB (50% the size).
Kaj
2-Jul-2013
[9261]
Yes, the ARM instruction set is optimised for speed at the expense 
of size
Bo
2-Jul-2013
[9262x3]
I've got plenty of room on the Pi, but not a lot of processing power.
So I'm thankful for that.
Another thing I've never tried in Red/System and can't seem to get 
to work:

	min-pixel-area-text: make-c-string 16

 min-pixel-area-text: read-file "config/motion-trigger-min-pixel-area.txt"
	print-line ["Minimum Pixel Area = " min-pixel-area-text]
	min-pixel-area: as-integer min-pixel-area-text
	print-line ["Minimum Pixel Area = " min-pixel-area]

Output:

	Minimum Pixel Area = 1
	Minimum Pixel Area = 3358672
XieQ
2-Jul-2013
[9265]
@Bo 'read-file' will call 'fread' in libc, so it will return the 
total amount of bytes read.  I think 'Minimum Pixel Area = 3358672' 
is the number of bytes read from your file, but I have no idea why 
it print a '1'  in the first output.
Bo
2-Jul-2013
[9266]
Thanks for the suggestion.   I had the number "40" in the file before, 
and it printed "40", but gave me the same long number in the second 
'print-line.  So I don't think that is it.
Pekr
3-Jul-2013
[9267x2]
I am with Arnold here, but I admit that it might be a psychological 
aspect, nothing more. Simply put - we have some low level stuff available, 
and I fear bulding higher (Rebol level) commands will be waste of 
time, as Doc will most probably rewrite it differently?
Let's take e.g. 'read function. Where will it be created? Red/System 
level? Red level? Both? E.g. Red/System does not allow refinements, 
so I expect some "natives" code will be done using R/S, and higher 
abstraction via routines in Red level?
DocKimbel
3-Jul-2013
[9269]
Bo, congrats! Hope you'll demo it at the devcon.
Pekr
3-Jul-2013
[9270]
btw - my brother ordered 3x Arduino kit for our friends, and for 
me he ordered BeagleBone Black. So I will see, if I can get Red programs 
running on it :-)
DocKimbel
3-Jul-2013
[9271x2]
Red should run just fine on the BB Black.
My motion detection executable on the Pi is 30KB.  The same executable 
compiled for Windows is 15KB (50% the size).


Red currently emits only the standard ARM opcodes, so 32-bit per 
instruction. We'll add support in the future for Thumb mode (more 
compact instruction set). In the meantime, you can try to activate 
the literal pools by adding the following option to the Linux-ARM 
config block (in %config.r):

literal-pool?:	 yes


That should both reduce final binary size and give you a little speed 
improvement. But be sure to test is well as this mode has not been 
much used yet. Also, it might fail to compile if you use very big 
functions, or a lot of code in global context.
Kaj
3-Jul-2013
[9273x8]
Bo, your make-c-string leaks memory. read-file will allocate memory 
of the size to fit the file contents
Xie, read-file is a Red/System function that does much more than 
fread. It returns the file content itself as a string, not the number 
of bytes read
fread is mapped directly to read-array
Bo, your file must contain "1". The second number is the address 
where it is read into memory
Remember that a c-string! is a pointer to a memory address. Much 
like a string! in REBOL is a reference to the storage of a series 
value that can be referenced by multiple string!s, each with their 
own index
If you want to convert the content of your text file to an integer, 
my C library binding provides to-integer, just like in REBOL
Petr, the Red/System READ functions and the higher Red abstractions 
on top of it are already here. As I said yesterday, Doc is free to 
use parts of it when he makes a more elaborate I/O framework in Red
You're not wasting any time on them, are you (except by talking about 
them)? I need them now, and so do others
Bo
3-Jul-2013
[9281]
Thanks for the advice and comments, everyone!  I'm feeling really 
good about Red/System and the greater Red ecosystem now that I have 
a project under my belt.  Kaj's been an immense help and I thank 
others also for their input!
Arnold
3-Jul-2013
[9282]
No console input command yet for Red or Red/System
prin "Number of sweets:" number-of-sweets: input
number-of-kids: ask "How many kids?"

Is the support planned? Will work nice with the kids sharing candy 
storyline making their program better.
Kaj
3-Jul-2013
[9283]
Yes, there is, in my I/O binding and interpreter builds. The basic 
console has very little
Bo
3-Jul-2013
[9284]
Kaj, you said that 'read-file in Red/System automatically defines 
a large enough memory space for the file.  How about 'read-file-binary? 
 That one has a 'size parameter.  How can one determine how big to 
make that 'size parameter before reading the file?
Kaj
3-Jul-2013
[9285x3]
You don't make it any size. It works the same as read-file and the 
READ function in REBOL: it allocates the storage for you
In the case of read-string you get a c-string!, so you can get the 
size with LENGTH?. For read-file-binary that's not possible, so you 
pass a pointer to an integer! to be informed about the read size
Sorry, read-file
Bo
3-Jul-2013
[9288]
Thanks for that.  Another detail I wasn't understanding correctly.
Paul
3-Jul-2013
[9289]
Where is RED at these days in comparison to R3?
Kaj
3-Jul-2013
[9290x2]
Glass half full, half empty :-)
What are you interested in?
Paul
3-Jul-2013
[9292]
I guess more or less what is the major usuability items that are 
still lacking in each.  Maybe you can answer that towards what RED 
still lacks as a major need.
Kaj
3-Jul-2013
[9293]
Garbage collector, error trapping, objects, floating point, PARSE, 
other complex datatypes
Paul
3-Jul-2013
[9294]
Some major ones there.
Kaj
3-Jul-2013
[9295]
Yep, that's the glass half empty
Paul
3-Jul-2013
[9296x2]
Thanks Kaj.
There a timeline on those?
Kaj
3-Jul-2013
[9298]
More like an order than an ETA, but you'd have to ask Doc
Paul
3-Jul-2013
[9299x2]
ok
Good info - thanks.
DocKimbel
3-Jul-2013
[9301]
Hi Paul, we have some Windows drivers issues for you to solve, up 
to the challenge? ;-)