[racket] Fundamentals
I mean no disrespext but I'm not sure that this message is correct in
the details. What is the point being made here?
Robby
On Wednesday, October 13, 2010, synx <plt at synx.us.to> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 10/13/2010 05:36 PM, Mathew Kurian wrote:
>
>> Racket as a language built on top of another base language (i.e.
>> Assembly or C)
>
> No, racket is not built on top of another base language.
>
>> or is it directly connected to the processor language?
>
> The language racket does not directly translate to the processor
> 'language'. The racket program reads that language in, and based on what
> it reads, sends a sequence of instructions to one, or more processors.
> These sequences are optimized "in time" so that they will only always
> work at the time they are executed, so you couldn't save them to a file
> and replay them 10 minutes later, hoping the computer would do the same
> thing.
>
> The following example for instance:
>
> (module example racket/base
>
> (let sum ((i (random 5)))
> (if (<= i 0) 0
> (+ i (sum (- i 1))))))
>
> The assembly language directives racket might produce when evaluating
> that program could be as follows: first it produces the assembly needed
> to get a random number between 0 and 5. Then it produces the assembly to
> add 1 and 0 (the innermost recursion), then 2 and 1, then 3 and 2, then
> 5 and 4. Then it produces the assembly to print out the number 9. The
> racket program can and will analyze such loops, and unroll them so that
> the assembler never sees a single jump instruction, even if the amount
> of times the loop is executed is only determined the moment of the
> code's evaluation. Or maybe it won't. But the point is that if you saved
> the instructions it produced, that is
>
> < random number 0 to 5 ... >
> < add 1 and 0 >
> < add 2 and 1 >
> < add 3 and 2 >
> < add 4 and 5 >
> < display 9 to stdout >
>
> And then you blindly executed those instructions again, it would
> calculate that random number, then ignore it, add up 0 to 4, then ignore
> that result, then display 9 to standard output every time. But if you
> ran racket on that program again, it would produce varying amounts of
> "add" instructions, and in fact sometimes it would provide a single add
> instruction followed by a jump-if-zero loop, if the amount of iterations
> is deemed too high by the optimizing compiler to unroll.
>
> You can convert racket to a byte code format (using raco make) but
> that's as far as you can go before the resulting programs may change
> unpredictably between two executions of the same code. Any further and
> you will most certainly lose vital state information, like trying to
> optimize the construction of your roller coaster by removing the track.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJMtmW2AAoJECC/cKf8E7UIz+gH/j3i9s2y0/8pYb9wOuPO6xkW
> wozUwEKTg9vcV7jf9AR7obepReTsJalljahd7q2yfsldH4KwpvklWr7mAvEHw56Z
> 35g23gbTW3MVmSmkEinJ0PhV11JUyD3bUIrQUTNmk4XNR88+7A0k2ye7osDB7Uef
> PViJyrr1JG2DrMaCpNGvWOE735keda12Hr7B5YeEI6+ECd/inHOkC2HP34OpL+Qd
> Skth1MWAvR+khZAAwhEdKyu/cL9ebEI4y/aReJ98Z/7EnP84RcDT0GCbPLnGtahC
> JTw3VoHggJ1wmLP9IIutKW3s5c944Yr6jrA1HrEPOHVaBSGHlG2YE32pN8qlrJ0=
> =bF85
> -----END PGP SIGNATURE-----
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>