[racket] users Digest, Vol 102, Issue 31

From: geb a (geb_a at yahoo.com)
Date: Tue Feb 11 10:57:14 EST 2014

Hello,

I'm working with a student on creating a super high resolution image using racket (limited only by imagemagick's ability to paste images together).  To do this we are breaking the rendering process into many smaller images that will be rendered individually by separate machines and reassembled by a server.  Each image is processed individually as a byte string and saved to a file.  We started to use the universe package and built a server to "serve" individual zooms to clients which would then respond with a byte string which the server saved to an image file to be compiled later by imagemagick.  The problem we ran into was that the server displays the messages passed back and forth and displaying the byte strings is too slow.  Is there a way to depress the display of information in messages?  I had trouble finding it in the documentation.

Thanks in advance for your help!

Best,
Dan Anderson







On Tuesday, February 11, 2014 7:14 AM, "users-request at racket-lang.org" <users-request at racket-lang.org> wrote:
 
Send users mailing list submissions to
    users at racket-lang.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://lists.racket-lang.org/users/listinfo
or, via email, send a message with subject or body 'help' to
    users-request at racket-lang.org

You can reach the person managing the list at
    users-owner at racket-lang.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of users digest..."


[Racket Users list:
http://lists.racket-lang.org/users ]


Today's Topics:

   1. Re: Y combinator (Matthias Felleisen)
   2. Re: Y combinator (Matthias Felleisen)
   3. Re: Y combinator (Matthew Johnson)
   4. Re: Y combinator (Matthias Felleisen)
   5. Re: Is racket suitable for such a project? (Neil Van Dyke)


----------------------------------------------------------------------

Message: 1
Date: Tue, 11 Feb 2014 09:37:40 -0500
From: Matthias Felleisen <matthias at ccs.neu.edu>
To: Matthew Johnson <mcooganj at gmail.com>
Cc: "users at racket-lang.org" <users at racket-lang.org>,
    "plragde at uwaterloo.ca" <plragde at uwaterloo.ca>
Subject: Re: [racket] Y combinator
Message-ID: <FD7CBBE3-7B10-438E-A983-BB1E2CD1DB95 at ccs.neu.edu>
Content-Type: text/plain; charset=iso-8859-1


On Feb 11, 2014, at 12:48 AM, Matthew Johnson <mcooganj at gmail.com> wrote:

> I am still a little unclear.  Is this a logical result, or a result of the evaluator's rules?  Or are they the same thing? 


They are the same thing. To calculate with the Racket that you see in the book/derivation, use this rule: 

  ( (lambda (x) e) V ) ~ e with all [free] occurrences of x replaced by V

[This is the rule you learn in pre-algebra,  with the 'free' needed here because 
variables can occur at more places than in pre-algebra.] Using this rule, plus 
simple car/cdr/cons/+1 rules, you can confirm every step in the derivation. As it 
turns out, the compiler implements this rule totally faithfully BUT instead of 
copying actual code it "copies" references to code by moving things from registers
to registers. Because the two are equivalent, a programmer can use the above
rule to think about code and the compiler writer (one among 10,000s of language
users) is the only one who has to keep references, registers, and replication 
in mind (kind of). 

-- Matthias




------------------------------

Message: 2
Date: Tue, 11 Feb 2014 10:01:43 -0500
From: Matthias Felleisen <matthias at ccs.neu.edu>
To: Matthew Johnson <mcooganj at gmail.com>
Cc: "users at racket-lang.org Users" <users at racket-lang.org>
Subject: Re: [racket] Y combinator
Message-ID: <15E77E00-DE15-451B-8A3E-19F2A4F5BB73 at ccs.neu.edu>
Content-Type: text/plain; charset=iso-8859-1



Ouch, I forgot to explain V. NO, you canNOT replace x with arbitrary expressions. You may use ONLY VALUES (V for Value). In this context a value is one of: #t/#f, number, or a lambda expression. -- Matthias





On Feb 11, 2014, at 9:50 AM, Matthew Johnson <mcooganj at gmail.com> wrote:

> The general form: ( (lambda (x) e) V) ~ e with all [free] x replaced by V
> 
> In concrete terms means:  ( (lambda (x) (* x y) 2) ~ (* 2 y) ?
> 
> I figure best to be sure now.
> 
> Thanks and best regards
> 
> matt johnson
> 
> 
> On 11/02/2014, at 3:35 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> 
>> 
>> On Feb 11, 2014, at 12:48 AM, Matthew Johnson <mcooganj at gmail.com> wrote:
>> 
>>> I am still a little unclear.  Is this a logical result, or a result of the evaluator's rules?  Or are they the same thing?
>> 
>> 
>> They are the same thing. To calculate with the Racket that you see in the book/derivation, use this rule:
>> 
>> ( (lambda (x) e) V ) ~ e with all [free] occurrences of x replaced by V
>> 
>> [This is the rule you learn in pre-algebra,  with the 'free' needed here because
>> variables can occur at more places than in pre-algebra.] Using this rule, plus
>> simple car/cdr/cons/+1 rules, you can confirm every step in the derivation. As it
>> turns out, the compiler implements this rule totally faithfully BUT instead of
>> copying actual code it "copies" references to code by moving things from registers
>> to registers. Because the two are equivalent, a programmer can use the above
>> rule to think about code and the compiler writer (one among 10,000s of language
>> users) is the only one who has to keep references, registers, and replication
>> in mind (kind of).
>> 
>> -- Matthias
>> 




------------------------------

Message: 3
Date: Tue, 11 Feb 2014 16:06:03 +0100
From: Matthew Johnson <mcooganj at gmail.com>
To: Matthias Felleisen <matthias at ccs.neu.edu>
Cc: "users at racket-lang.org Users" <users at racket-lang.org>
Subject: Re: [racket] Y combinator
Message-ID: <3538474613101379763 at unknownmsgid>
Content-Type: text/plain; charset=ISO-8859-1

So in terms of my example:

We have the general form: ( (lambda (x) e) V) ~ e with all [free] x
replaced by V

And for V <-- 2  ::  ( (lambda (x) (* x y) 2) ~ (* 2 y) ?

But for V <-- z^2 :: error and NOT ~ (* (* z z) y) ?

Thanks

On 11/02/2014, at 3:59 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:

>
>
> Ouch, I forgot to explain V. NO, you canNOT replace x with arbitrary expressions. You may use ONLY VALUES (V for Value). In this context a value is one of: #t/#f, number, or a lambda expression. -- Matthias
>
>
>
>
>
> On Feb 11, 2014, at 9:50 AM, Matthew Johnson <mcooganj at gmail.com> wrote:
>
>> The general form: ( (lambda (x) e) V) ~ e with all [free] x replaced by V
>>
>> In concrete terms means:  ( (lambda (x) (* x y) 2) ~ (* 2 y) ?
>>
>> I figure best to be sure now.
>>
>> Thanks and best regards
>>
>> matt johnson
>>
>>
>> On 11/02/2014, at 3:35 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>>
>>>
>>> On Feb 11, 2014, at 12:48 AM, Matthew Johnson <mcooganj at gmail.com> wrote:
>>>
>>>> I am still a little unclear.  Is this a logical result, or a result of the evaluator's rules?  Or are they the same thing?
>>>
>>>
>>> They are the same thing. To calculate with the Racket that you see in the book/derivation, use this rule:
>>>
>>> ( (lambda (x) e) V ) ~ e with all [free] occurrences of x replaced by V
>>>
>>> [This is the rule you learn in pre-algebra,  with the 'free' needed here because
>>> variables can occur at more places than in pre-algebra.] Using this rule, plus
>>> simple car/cdr/cons/+1 rules, you can confirm every step in the derivation. As it
>>> turns out, the compiler implements this rule totally faithfully BUT instead of
>>> copying actual code it "copies" references to code by moving things from registers
>>> to registers. Because the two are equivalent, a programmer can use the above
>>> rule to think about code and the compiler writer (one among 10,000s of language
>>> users) is the only one who has to keep references, registers, and replication
>>> in mind (kind of).
>>>
>>> -- Matthias
>


------------------------------

Message: 4
Date: Tue, 11 Feb 2014 10:09:44 -0500
From: Matthias Felleisen <matthias at ccs.neu.edu>
To: Matthew Johnson <mcooganj at gmail.com>
Cc: "users at racket-lang.org Users" <users at racket-lang.org>
Subject: Re: [racket] Y combinator
Message-ID: <EC4AB567-A8E4-4520-A924-5E2647AF6FCA at ccs.neu.edu>
Content-Type: text/plain; charset=iso-8859-1


On Feb 11, 2014, at 10:06 AM, Matthew Johnson <mcooganj at gmail.com> wrote:

> So in terms of my example:
> 
> We have the general form: ( (lambda (x) e) V) ~ e with all [free] x
> replaced by V
> 
> And for V <-- 2  ::  ( (lambda (x) (* x y) 2) ~ (* 2 y) ?
> 
> But for V <-- z^2 :: error and NOT ~ (* (* z z) y) ?

Not error. It just doesn't reduce. But usually this doesn't happen, z will have been replaced with a value. 



> 
> Thanks
> 
> On 11/02/2014, at 3:59 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> 
>> 
>> 
>> Ouch, I forgot to explain V. NO, you canNOT replace x with arbitrary expressions. You may use ONLY VALUES (V for Value). In this context a value is one of: #t/#f, number, or a lambda expression. -- Matthias
>> 
>> 
>> 
>> 
>> 
>> On Feb 11, 2014, at 9:50 AM, Matthew Johnson <mcooganj at gmail.com> wrote:
>> 
>>> The general form: ( (lambda (x) e) V) ~ e with all [free] x replaced by V
>>> 
>>> In concrete terms means:  ( (lambda (x) (* x y) 2) ~ (* 2 y) ?
>>> 
>>> I figure best to be sure now.
>>> 
>>> Thanks and best regards
>>> 
>>> matt johnson
>>> 
>>> 
>>> On 11/02/2014, at 3:35 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>>> 
>>>> 
>>>> On Feb 11, 2014, at 12:48 AM, Matthew Johnson <mcooganj at gmail.com> wrote:
>>>> 
>>>>> I am still a little unclear.  Is this a logical result, or a result of the evaluator's rules?  Or are they the same thing?
>>>> 
>>>> 
>>>> They are the same thing. To calculate with the Racket that you see in the book/derivation, use this rule:
>>>> 
>>>> ( (lambda (x) e) V ) ~ e with all [free] occurrences of x replaced by V
>>>> 
>>>> [This is the rule you learn in pre-algebra,  with the 'free' needed here because
>>>> variables can occur at more places than in pre-algebra.] Using this rule, plus
>>>> simple car/cdr/cons/+1 rules, you can confirm every step in the derivation. As it
>>>> turns out, the compiler implements this rule totally faithfully BUT instead of
>>>> copying actual code it "copies" references to code by moving things from registers
>>>> to registers. Because the two are equivalent, a programmer can use the above
>>>> rule to think about code and the compiler writer (one among 10,000s of language
>>>> users) is the only one who has to keep references, registers, and replication
>>>> in mind (kind of).
>>>> 
>>>> -- Matthias
>> 




------------------------------

Message: 5
Date: Tue, 11 Feb 2014 10:11:59 -0500
From: Neil Van Dyke <neil at neilvandyke.org>
To: Yuhao Dong <ithisa at outlook.com>
Cc: users at lists.racket-lang.org
Subject: Re: [racket] Is racket suitable for such a project?
Message-ID: <52FA3DBF.6000405 at neilvandyke.org>
Content-Type: text/plain; charset=UTF-8; format=flowed

I can't answer the question in the Subject header off-the-cuff, but I 
can comment on some of the details...

For an onion router that has to handle lots of traffic at high speed, my 
first guess would be C or maybe C++ (not Go or Java), though I can 
appreciate wanting a higher-level language for this task.

I might also look at Erlang.

I would consider Python only if the project involves huge numbers of 
people running onion nodes, and you want them to be able to inspect the 
software themselves.  Python is far from perfect for this task, but it 
would be good in that large numbers of people can read it, and a better 
overall fit than JS.

If you want to do it in Racket, also take a look at Gambit C, which is 
my Scheme-y backup if I ever need lots of threads.

If you want to get creative, you might see whether you build this from 
domain-specific languages in Racket, but have Racket target C code.  
Like Pre-Scheme with DSLs.  (Also, going to a hardware description 
language from DSLs.)

"#lang racket" is for demos, IMHO; I *always* use "#lang racket/base" 
for any code that's not a demo.

A tree-shaker like you suggest might still be appropriate even with 
"racket/base", mainly if one wants to put this on a low-space device 
like OpenWRT hardware.  (Just last night, I was trying to decide whether 
I wanted to fit the Linux kernel plus Racket and an app in the 256MB RAM 
of the Kindle 3.)

If you want to spread your Racket threads across CPUs/cores, then, yes, 
I would look at Racket places as well as homebrew worker threads.

The Racket VM startup time is longer than it used to be, and I no longer 
use it often as a quick command-line calculator.  (If filesystem and 
libraries aren't in Linux caches, it's almost 4 seconds before REPL 
prompt on my workstation.)  That might not have to be a problem for an 
onion-router, however, even if you're starting up lots of processes 
(since you might be able to start worker processes before they're needed).

If you're finding Racket run time (not startup time) sometimes slower 
than Python, it's possible, but I'm wondering whether the respective 
implementations of your code have been hand-optimized.

Good luck with your project.

Neil V,

Yuhao Dong wrote at 02/10/2014 06:49 PM:
> Hi,
>
> I'm trying to decide between Racket and Go on writing my onion-routing
> system inspired by Tor. Basically, a network server, involving lots of
> long-lived connections that often pass large amounts of data. The thing
> needs to be super scalable; I often find that these servers, although
> network servers, often become CPU-bound doing encryption and
> encapsulation of protocols, so I do have experience that this is not
> "premature optimization"!
>
> Go seems to be the go-to (pun intended) for scalable network things. It
> has super cheap threads, is statically compiled (easy to deploy to lots
> of machines), and apparently uses little memory and runs fast. However,
> after writing some low-level transports in Go, I found a few things I
> gripe about but seem to be unsolvable:
>
>   - Go doesn't have exceptions. This means checking errors over and over.
>   - Go uses lightweight user threads like Racket ("goroutines"), but
> isn't fully non-blocking under the hood for I/O. Thus some I/O
> operations actually spawn a kernel thread, and then kill it when the
> operation is done. This is unacceptable for my use case.
>   - Go isn't as fast as I imagined. My program is still CPU-bound at
> around 40 MB/s, and that's just counting pushing zeroes through the
> lowest-level transport protocol.
>   - Go's garbage collector is naive stop-the-world mark-and-sweep. My
> program keeps a large amount of state, and constantly pushes data and
> accepts connections. The mark-and-sweep process can take as much as 20
> seconds on large heaps, severly impacting user experience. Since the GC
> is nonmoving, heap fragmentation is also an issue. I searched around a
> bit, and it seems that "buffer reuse" is a thing in Go. Ugh.
>
> So I decided to take Racket, namely Typed Racket, a spin. I like it a
> lot, it's my favorite language after all, and especially I like the fact
> that I can use macros to simplify verbose patterns of code. DrRacket's
> REPL is also very helpful. I also find that Racket is much more
> performant than I imagined (I used to think of it as a Python-type slow
> scripting language). However, there are a few gripes I have, but seeing
> how flexible Racket is, I think they might be solvable:
>
>   - Racket threads don't seem to be able to utilize multiple CPU cores.
> Is there an idiomatic way to, say, form a pool of places and push
> threads to them? I imagine sharing data is very messy?
>   - The Racket VM is huuuuuuge, both on disk and in memory.
> Infuriatingly, using #lang racket seems to import every single #lang
> racket library into the memory space, and when I raco dist my program,
> every single library gets packaged. I know this sounds like whining, but
> why can't some sort of analysis phase be applied where only the
> libraries actually required for the program to run are loaded?
>   - Racket doesn't seem to be able to call raw C code or machine code in
> static libraries, instead requiring the code be compiled into a library.
> Is this related to the fact that Racket is run in a VM rather than
> compiled to machine code?
>   - Some things in racket are pathologically slow. As an example, try
> implementing a cipher with loops and array indices and bytestrings. It
> will end up orders of magnitude slower than, say, C or Go or Java, or
> sometimes even Python.
>
> Are there solutions to these problems? These aren't showstoppers by any
> means, but could finally end my endless dilemma between the two langs :)
>
> Thanks!
> Yuhao Dong
>    
>    


End of users Digest, Vol 102, Issue 31
**************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140211/4347c9c5/attachment-0001.html>

Posted on the users mailing list.