Re: [racket-users] `divides?` from math/number-theory slow?
The above is of course supposed to say that `divides?` needed a few seconds more than the modulo example even in Typed Racket. Both were of course typed when running with TR. On Mon, Aug 24, 2015 at 3:38 PM, Rickard Andersson rickard.m.anders...@gmail.com wrote: Yes, that indeed seems to be the problem. However, even after managing to wrap the types properly, using `divides?` still ended up being a bit slower. Not dramatically slower, but still noticably and unexpectedly. As I'm not at all comfortable with Typed Racket I would appreciate if someone could show how one would annotate the example minimally to give the optimizer enough information to surpass Racket. As of this moment I haven't really managed to see any improvement from using Typed Racket. It cut down the time `divides?` needed to a few seconds more than Racket. Otherwise, it had no effect (on the other example either). As a point of curiosity; I had to work around the fact that apparently there were not enough type annotations by wrapping the `for`s in functions and typing them accordingly. Is there a better way to do this? I'm currently trying to compare some performance between OCaml, C and Racket and I'm currently using the aforementioned example. Here are some timings: | time racket divides.rkt; time ./divides_c; time ./divides_ocaml 416658333 racket divides.rkt 7.32s user 0.02s system 100% cpu 7.336 total 416658333 ./divides_c 0.49s user 0.00s system 99% cpu 0.488 total 416658333 ./divides_ocaml 0.75s user 0.00s system 99% cpu The idea is to see how fast one can make the following: #lang racket/base (define (divisible-by? x d) (= (modulo x d) 0)) (module+ main (for/sum ([x (in-range 3 5)]) (if (x . divisible-by? . 3) x 0)) ) On Mon, 24 Aug 2015, Pierpaolo Bernardi wrote: On Mon, Aug 24, 2015 at 1:25 PM, Jens Axel Søgaard jensa...@soegaard.net wrote: It looks very odd to me. Maybe this is due to calling TR functions from plain Racket? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
It looks to me like the slowdown isn't entirely explained by contract checking, or perhaps TR isn't generating the contracts I would have guessed. With the program below, I see this output cpu time: 1228 real time: 1228 gc time: 133 cpu time: 658 real time: 658 gc time: 18 cpu time: 80 real time: 81 gc time: 0 but would have expected the first two lines to be nearly the same. Robby #lang racket (require (only-in math/number-theory divides?)) (define (divisible-by? x d) (= (modulo x d) 0)) (module d racket/base (require racket/contract/base) (define (divisible-by? x d) (= (modulo x d) 0)) (provide (contract-out [divisible-by? (- exact-integer? exact-integer? boolean?)]))) (require (prefix-in c: (submod . d))) (module+ main (time (for ([x (in-range 3 500)]) (if (3 . divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . c:divisible-by? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (x . divisible-by? . 3) x 0 -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
The difference in performance between the two functions when there are no contracts (ie, when there are no types anywhere, or when everything is typed) seems to be just from the extra `zero?` check in `divides?`. Adding that to your program produced something that runs in about the same time as your `divisible-by?` (I ran them all in both untyped and typed Racket). Sam On Mon, Aug 24, 2015 at 8:40 AM Rickard Andersson rickard.m.anders...@gmail.com wrote: Yes, that indeed seems to be the problem. However, even after managing to wrap the types properly, using `divides?` still ended up being a bit slower. Not dramatically slower, but still noticably and unexpectedly. As I'm not at all comfortable with Typed Racket I would appreciate if someone could show how one would annotate the example minimally to give the optimizer enough information to surpass Racket. As of this moment I haven't really managed to see any improvement from using Typed Racket. It cut down the time `divides?` needed to a few seconds more than Racket. Otherwise, it had no effect (on the other example either). As a point of curiosity; I had to work around the fact that apparently there were not enough type annotations by wrapping the `for`s in functions and typing them accordingly. Is there a better way to do this? I'm currently trying to compare some performance between OCaml, C and Racket and I'm currently using the aforementioned example. Here are some timings: | time racket divides.rkt; time ./divides_c; time ./divides_ocaml 416658333 racket divides.rkt 7.32s user 0.02s system 100% cpu 7.336 total 416658333 ./divides_c 0.49s user 0.00s system 99% cpu 0.488 total 416658333 ./divides_ocaml 0.75s user 0.00s system 99% cpu The idea is to see how fast one can make the following: #lang racket/base (define (divisible-by? x d) (= (modulo x d) 0)) (module+ main (for/sum ([x (in-range 3 5)]) (if (x . divisible-by? . 3) x 0)) ) On Mon, 24 Aug 2015, Pierpaolo Bernardi wrote: On Mon, Aug 24, 2015 at 1:25 PM, Jens Axel Søgaard jensa...@soegaard.net wrote: It looks very odd to me. Maybe this is due to calling TR functions from plain Racket? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
My message below is not doing the right test. This is the right test and it produces the expected result, namely that the TR version runs a bit faster (presumably because of type-based optimizations that TR does). Robby #lang racket (module t typed/racket/base (: divides? : Integer Integer - Boolean) (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide divides?)) (module c racket/base (require racket/contract/base) (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide (contract-out [divides? (- exact-integer? exact-integer? boolean?)]))) (require (prefix-in c: (submod . c))) (require (prefix-in t: (submod . t))) (time (for ([x (in-range 3 500)]) (if (3 . c:divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . t:divides? . x) x 0))) On Mon, Aug 24, 2015 at 8:18 AM, Robby Findler ro...@eecs.northwestern.edu wrote: It looks to me like the slowdown isn't entirely explained by contract checking, or perhaps TR isn't generating the contracts I would have guessed. With the program below, I see this output cpu time: 1228 real time: 1228 gc time: 133 cpu time: 658 real time: 658 gc time: 18 cpu time: 80 real time: 81 gc time: 0 but would have expected the first two lines to be nearly the same. Robby #lang racket (require (only-in math/number-theory divides?)) (define (divisible-by? x d) (= (modulo x d) 0)) (module d racket/base (require racket/contract/base) (define (divisible-by? x d) (= (modulo x d) 0)) (provide (contract-out [divisible-by? (- exact-integer? exact-integer? boolean?)]))) (require (prefix-in c: (submod . d))) (module+ main (time (for ([x (in-range 3 500)]) (if (3 . divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . c:divisible-by? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (x . divisible-by? . 3) x 0 -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
With regards to the measurements; as is obvious from this mailchain, I know about and use the `time` form. It hasn't skewed the results. Using the optimizing coach in DrRacket has yielded no results, really. I tried using it and there wasn't any advice on what to do for speedups (unless that advice isn't very discoverable, I don't know.). The only meaningful difference I discovered for TR was using 6.1.1, as apparently there was an optimization that'd been borked for 6.2.0 and onwards. I'm still curious about speed-ups with TR. I had expected it to perform better than Racket, but I guess the big win is that you get contracts with better performance instead of much faster, brittle code? On Mon, 24 Aug 2015, Vincent St-Amour wrote: On Mon, 24 Aug 2015 08:38:46 -0400, Rickard Andersson wrote: Yes, that indeed seems to be the problem. However, even after managing to wrap the types properly, using `divides?` still ended up being a bit slower. Not dramatically slower, but still noticably and unexpectedly. As I'm not at all comfortable with Typed Racket I would appreciate if someone could show how one would annotate the example minimally to give the optimizer enough information to surpass Racket. As of this moment I haven't really managed to see any improvement from using Typed Racket. It cut down the time `divides?` needed to a few seconds more than Racket. Otherwise, it had no effect (on the other example either). In general, if you want to ensure that your code plays nice with the Typed Racket optimizer, I recommend you try the optimization coach, in DrRacket. There should be a button in the toolbar when you're working in Typed Racket. The coach points out portions of your programs where additional optimizations could apply if you were to change your program a bit, and give you advice on how to change it. The Typed Racket guide also has some general performance advice: http://docs.racket-lang.org/ts-guide/optimization.html As a point of curiosity; I had to work around the fact that apparently there were not enough type annotations by wrapping the `for`s in functions and typing them accordingly. Is there a better way to do this? Have you tried adding annotations to the `for` forms directly? The docs show the syntax: http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._for%29%29 I'm currently trying to compare some performance between OCaml, C and Racket and I'm currently using the aforementioned example. Here are some timings: | time racket divides.rkt; time ./divides_c; time ./divides_ocaml 416658333 racket divides.rkt 7.32s user 0.02s system 100% cpu 7.336 total 416658333 ./divides_c 0.49s user 0.00s system 99% cpu 0.488 total 416658333 ./divides_ocaml 0.75s user 0.00s system 99% cpu The idea is to see how fast one can make the following: #lang racket/base (define (divisible-by? x d) (= (modulo x d) 0)) (module+ main (for/sum ([x (in-range 3 5)]) (if (x . divisible-by? . 3) x 0)) ) In this particular example, you may get speedups by using Typed Racket's sub-`Integer` types, such as `Index` or `Fixnum`. These can guarantee to the typechecker that your code will not generate bignums, which will allow TR to optimize accordingly. A note on your particular measurement methodology. When you use unix's `time` command on `racket x.rkt`, this measures not only the actual execution time, but also compilation to bytecode and, in the case of Typed Racket programs, typechecking time as well (which can be significant). If you run `raco make x.rkt` before measuring, you avoid measuring that extra overhead. If you also want to avoid measuring the startup overhead of the Racket VM (which only really matters for short scripts), you should use the `time` form in Racket, instead of the unix `time` command. Vincent -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
On Mon, 24 Aug 2015 08:38:46 -0400, Rickard Andersson wrote: Yes, that indeed seems to be the problem. However, even after managing to wrap the types properly, using `divides?` still ended up being a bit slower. Not dramatically slower, but still noticably and unexpectedly. As I'm not at all comfortable with Typed Racket I would appreciate if someone could show how one would annotate the example minimally to give the optimizer enough information to surpass Racket. As of this moment I haven't really managed to see any improvement from using Typed Racket. It cut down the time `divides?` needed to a few seconds more than Racket. Otherwise, it had no effect (on the other example either). In general, if you want to ensure that your code plays nice with the Typed Racket optimizer, I recommend you try the optimization coach, in DrRacket. There should be a button in the toolbar when you're working in Typed Racket. The coach points out portions of your programs where additional optimizations could apply if you were to change your program a bit, and give you advice on how to change it. The Typed Racket guide also has some general performance advice: http://docs.racket-lang.org/ts-guide/optimization.html As a point of curiosity; I had to work around the fact that apparently there were not enough type annotations by wrapping the `for`s in functions and typing them accordingly. Is there a better way to do this? Have you tried adding annotations to the `for` forms directly? The docs show the syntax: http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._for%29%29 I'm currently trying to compare some performance between OCaml, C and Racket and I'm currently using the aforementioned example. Here are some timings: | time racket divides.rkt; time ./divides_c; time ./divides_ocaml 416658333 racket divides.rkt 7.32s user 0.02s system 100% cpu 7.336 total 416658333 ./divides_c 0.49s user 0.00s system 99% cpu 0.488 total 416658333 ./divides_ocaml 0.75s user 0.00s system 99% cpu The idea is to see how fast one can make the following: #lang racket/base (define (divisible-by? x d) (= (modulo x d) 0)) (module+ main (for/sum ([x (in-range 3 5)]) (if (x . divisible-by? . 3) x 0)) ) In this particular example, you may get speedups by using Typed Racket's sub-`Integer` types, such as `Index` or `Fixnum`. These can guarantee to the typechecker that your code will not generate bignums, which will allow TR to optimize accordingly. A note on your particular measurement methodology. When you use unix's `time` command on `racket x.rkt`, this measures not only the actual execution time, but also compilation to bytecode and, in the case of Typed Racket programs, typechecking time as well (which can be significant). If you run `raco make x.rkt` before measuring, you avoid measuring that extra overhead. If you also want to avoid measuring the startup overhead of the Racket VM (which only really matters for short scripts), you should use the `time` form in Racket, instead of the unix `time` command. Vincent -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
I was very curious about what you were talking about, as I saw wildly different numbers (in line with what I'd seen before). However, I did the following test: | ~/tools/racket/6.1.1/bin/racket typed_divide.rkt cpu time: 536 real time: 537 gc time: 27 cpu time: 347 real time: 347 gc time: 4 cpu time: 87 real time: 84 gc time: 0 | ~/tools/racket/6.2.0/bin/racket typed_divide.rkt cpu time: 567 real time: 565 gc time: 10 cpu time: 960 real time: 958 gc time: 13 cpu time: 83 real time: 84 gc time: 0 | ~/tools/racket/6.2.1/bin/racket typed_divide.rkt cpu time: 600 real time: 601 gc time: 70 cpu time: 970 real time: 974 gc time: 23 cpu time: 86 real time: 85 gc time: 0 The below program is what's being run: #lang racket/base (module t typed/racket/base (: divides? : Integer Integer - Boolean) (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide divides?)) (module c racket/base (require racket/contract/base) (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide (contract-out [divides? (- exact-integer? exact-integer? boolean?)]))) (module no-contract racket/base (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide divides?)) (require (prefix-in with-contract: (submod . c))) (require (prefix-in typed: (submod . t))) (require (prefix-in no-contract: (submod . no-contract))) (time (for ([x (in-range 3 500)]) (if (3 . with-contract:divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . typed:divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . no-contract:divides? . x) x 0))) On Mon, 24 Aug 2015, Robby Findler wrote: My message below is not doing the right test. This is the right test and it produces the expected result, namely that the TR version runs a bit faster (presumably because of type-based optimizations that TR does). Robby #lang racket (module t typed/racket/base (: divides? : Integer Integer - Boolean) (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide divides?)) (module c racket/base (require racket/contract/base) (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) (provide (contract-out [divides? (- exact-integer? exact-integer? boolean?)]))) (require (prefix-in c: (submod . c))) (require (prefix-in t: (submod . t))) (time (for ([x (in-range 3 500)]) (if (3 . c:divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . t:divides? . x) x 0))) On Mon, Aug 24, 2015 at 8:18 AM, Robby Findler ro...@eecs.northwestern.edu wrote: It looks to me like the slowdown isn't entirely explained by contract checking, or perhaps TR isn't generating the contracts I would have guessed. With the program below, I see this output cpu time: 1228 real time: 1228 gc time: 133 cpu time: 658 real time: 658 gc time: 18 cpu time: 80 real time: 81 gc time: 0 but would have expected the first two lines to be nearly the same. Robby #lang racket (require (only-in math/number-theory divides?)) (define (divisible-by? x d) (= (modulo x d) 0)) (module d racket/base (require racket/contract/base) (define (divisible-by? x d) (= (modulo x d) 0)) (provide (contract-out [divisible-by? (- exact-integer? exact-integer? boolean?)]))) (require (prefix-in c: (submod . d))) (module+ main (time (for ([x (in-range 3 500)]) (if (3 . divides? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (3 . c:divisible-by? . x) x 0))) (time (for ([x (in-range 3 500)]) (if (x . divisible-by? . 3) x 0 -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Re: DrRacket Scribbles OK, but can't build docs with raco
I have tracked it down finally to a very stupid error. Some uses of @examples or @interaction-eval were not given quoted expressions and this was the problem. It's actually surprising that it works in DrRacket, which was very misleading. Deren On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com wrote: I have a scribble document with several examples. When I view the scribble html output by using DrRacket, all the examples are fine, the output is correct, and I see no errors. Then I go to the directory, use raco pkg install, and I get a major text dump which starts with cannot instantiate 'racket/gui/base' a second time in the same process. But I didn't even try to instantiate it the first time. There's no use of gui at all in any part of the collection. I only create one evaluator for scribble examples: @(define this-eval (let ([eval (make-base-eval)]) (eval '(begin (require racket/math main.rkt))) eval)) What could I be doing wrong? Thanks, Deren -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Re: DrRacket Scribbles OK, but can't build docs with raco
Actually quoting it was the wrong thing to do, as I found out when I finally looked at the docs. The docs are not very complicated, if someone could take a look at the cf-manual.scrbl and see if something obvious is going wrong I'd appreciate it. https://github.com/derend/continued-fractions/blob/master/continued-fractions/cf-manual.scrbl Deren On Mon, Aug 24, 2015 at 11:40 AM, Deren Dohoda deren.doh...@gmail.com wrote: I have tracked it down finally to a very stupid error. Some uses of @examples or @interaction-eval were not given quoted expressions and this was the problem. It's actually surprising that it works in DrRacket, which was very misleading. Deren On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com wrote: I have a scribble document with several examples. When I view the scribble html output by using DrRacket, all the examples are fine, the output is correct, and I see no errors. Then I go to the directory, use raco pkg install, and I get a major text dump which starts with cannot instantiate 'racket/gui/base' a second time in the same process. But I didn't even try to instantiate it the first time. There's no use of gui at all in any part of the collection. I only create one evaluator for scribble examples: @(define this-eval (let ([eval (make-base-eval)]) (eval '(begin (require racket/math main.rkt))) eval)) What could I be doing wrong? Thanks, Deren -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] My son's game in Racket
We released my 10 year old son's game that was done in Racket: www.1k3c.comhttp://www.1k3c.com I'm still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can't recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don't know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a real project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I'm a big booster of functional programming, but I'm not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I'm not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of Why is the screen all black? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
RE: [racket-users] My son's game in Racket
The performance problems were related to the larger scrolling worlds. The H2DP versions got slower the more clouds were in the maps. As an aside, what drove the 20-something fps tic rate for H2DP, versus 30 for an every-other-vsync update? He is already through Algebra 2, so he gets functions. He didn't have any difficulty applying the functional image model, but when you have 20 lines of text drawing composed together, it really looks like you are just drawing things one after another, but backwards. The cases where it has value, like building a character up out of multiple things, then placing it somewhere in the world, tend to be the minority of operations compared to just drawing independent elements on the screen. My wife managed programmers for years, and she has opinions about pragmatic developers, which usually involve Java or C++. I tend to think that worrying about our 10 year old's future career prospects is a bit premature, and want to focus on developing abstract programming skills. :-) Unity/C# can be incredibly rewarding, but the entire ecosystem almost drives you away from programming as a beginner -- find the right script on the asset store and figure out how to configure it in the editor, rather than reinventing the wheel and writing it yourself. One of the non-obvious things that I think is beneficial with DrRacket is that it has an approachable complexity level. Dropping a newbie into Eclipse or MonoDevelop makes them feel like they are walking around in a byzantine museum, afraid to touch things, while DrRacket feels closer to old-school personal computers where you felt like you were in command of the machine. -Original Message- From: Matthias Felleisen [mailto:matth...@ccs.neu.edu] Sent: Monday, August 24, 2015 12:18 PM To: John Carmack Cc: Racket Users Subject: Re: [racket-users] My son's game in Racket Thanks for sharing. You can let Ryan know that he has his first grandma user, and in that mode, I managed to get a few extra lives. A couple of comments: -- In the past, some teachers have shared similar 'world/universe' games with me with similar performance. -- If your son is in middle school, he should see pre-algebra soon, and you may wish to revisit the initial drafts of the game then. You can show directly how pre-algebra applies and how the game is basically written in pre-algebra. -- Learning FP and the connection to math may work better if you actually use the design recipe from HtDP [2e]. I know of a child who worked through this book between the ages of 8 and 12 and had a grand time with math and programming then. -- And finally, I am curious about your wife's comment. What's so objectionable to learning fundamentals first and commercial things when you need to go professional? Your son used C#/Unity last year. Was it much easier? I have acknowledged the lack of a growth path from 'world' to a performant model in the past, and I will continue to admit the problem. -- Matthias -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Sync on Distributed Place Channels
I'm trying to receive messages from a place. Receiving the messages with `place-channel-get` works fine, but using `sync` blocks indefinitely. I want to use `sync` instead of `place-channel-get` to check multiple channels simultaneously for messages. Below is an example that demonstrates the problem. What am I doing wrong? Am I using `sync` incorrectly? Does `sync` not work with channels? (module hello-world racket (require racket/place/distributed racket/place) (provide world) (define (world ch) (define s (place-channel-get ch)) (place-channel-put ch (string-append s World!\n))) (module+ main (define nd (create-place-node localhost #:listen-port 1234)) (define ch (dynamic-place #:at nd (quote-module-path ..) 'world)) (place-channel-put ch Hello ) ; (define rs (place-channel-get ch)); works (define rs (sync ch)) ; block indefinitely (write-string rs))) -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
On Aug 24, 2015, at 12:27 PM, John Carmack jo...@oculus.com wrote: We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” Thanks for sharing. You can let Ryan know that he has his first grandma user, and in that mode, I managed to get a few extra lives. A couple of comments: -- In the past, some teachers have shared similar 'world/universe' games with me with similar performance. -- If your son is in middle school, he should see pre-algebra soon, and you may wish to revisit the initial drafts of the game then. You can show directly how pre-algebra applies and how the game is basically written in pre-algebra. -- Learning FP and the connection to math may work better if you actually use the design recipe from HtDP [2e]. I know of a child who worked through this book between the ages of 8 and 12 and had a grand time with math and programming then. -- And finally, I am curious about your wife's comment. What's so objectionable to learning fundamentals first and commercial things when you need to go professional? Your son used C#/Unity last year. Was it much easier? I have acknowledged the lack of a growth path from 'world' to a performant model in the past, and I will continue to admit the problem. -- Matthias -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
2015-08-24 18:27 GMT+02:00 John Carmack jo...@oculus.com: We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com Tell him, he has done a great job. It has the right game feel. I liked both how the levels progressed slowly in difficulty and that there were so many of them. /Jens Axel -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Re: My son's game in Racket
On Monday, August 24, 2015 at 12:28:07 PM UTC-4, John Carmack wrote: We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” Not clear what was meant both times you wrote backwards are you referring to the lisp-style function call? Something that could be alleviated by say F#'s pipe forward operator? let (|) a f = f a or Clojure's - macro? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
FYI, I think the Mac version is out of date. Dropbox says the mac installer file is two weeks old, and the windows version is a few hours old. On Mon, Aug 24, 2015 at 12:27 PM, John Carmack jo...@oculus.com wrote: We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
On Mon, 24 Aug 2015 11:24:33 -0400, Rickard Andersson wrote: With regards to the measurements; as is obvious from this mailchain, I know about and use the `time` form. It hasn't skewed the results. Using the optimizing coach in DrRacket has yielded no results, really. I tried using it and there wasn't any advice on what to do for speedups (unless that advice isn't very discoverable, I don't know.). The only meaningful difference I discovered for TR was using 6.1.1, as apparently there was an optimization that'd been borked for 6.2.0 and onwards. I'm still curious about speed-ups with TR. I had expected it to perform better than Racket, but I guess the big win is that you get contracts with better performance instead of much faster, brittle code? TR can perform better than plain Racket, but not always. TR mostly performs local optimizations that remove dispatch / checks in various operations, so only programs using these operations will see any improvements. Areas where you can expect wins are float- and complex-number-intensive computations, as well as some data structure accesses. Vincent -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
Or something like this, with the rackjure package: (require rackjure/threading 2htdp/image) (~ background-img (place-image image-1 x y) ; the background-img will be inserted as the last argument, because that's what ~ does (place-image image-2 x y) ; the background + image-1 will be inserted as the last argument (place-image image-3 x y) ; and so on ...) Or if you don't want to use rackjure, then with let* it would be: (let* ([img background-img] [img (place-image image-1 x y img)] [img (place-image image-2 x y img)] [img (place-image image-3 x y img)] ...) img) On Aug 24, 2015, at 2:40 PM, Joel McCracken mccracken.j...@gmail.com wrote: This would be where I would reach for a let* to handle intermediate results, because code like this is very awkward. On Mon, Aug 24, 2015 at 2:32 PM, John Carmack jo...@oculus.com wrote: The idea that you functionally compose images like this: (place-image image-1 x y (place-image image-2 x y (place-image image-3 x y))) Which draws image1 on top of image2 on top of image 3, which is backwards from the painters order that would draw image 3, then image 2, then image 1. This imperative, side-effect-ing code is a little less clear to a beginner with the OOP and DC concepts, but It better represents what actually happens, and it is much easier to modify the code without worrying about the nesting. (send dc draw-bitmap imag3 x y) (send dc draw-bitmap imag2 x y) (send dc draw-bitmap imag1 x y) -Original Message- From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of David Grenier Sent: Monday, August 24, 2015 1:14 PM To: Racket Users Cc: John Carmack Subject: [racket-users] Re: My son's game in Racket On Monday, August 24, 2015 at 12:28:07 PM UTC-4, John Carmack wrote: We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” Not clear what was meant both times you wrote backwards are you referring to the lisp-style function call? Something that could be alleviated by say F#'s pipe forward operator? let (|) a f = f a or Clojure's - macro? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://urldefense.proofpoint.com/v1/url?u=https://groups.google.com/d/optoutk=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0Ar=Kjg6LltY9QjkipKooaVldA%3D%3D%0Am=HArZE0M9OqU4wspKLzQzG6N5gO9ncSxPP9qVzkUgoVU%3D%0As=b451faca736dc42c554f148983e7279865ef32be9ddf2df75f5c88c15dd34a73. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com.
RE: [racket-users] Re: My son's game in Racket
I don't know how much you involve yourself in the actual making of things (it might be a principle of yours to leave everything practical to your son and to only help with concepts), but couldn't it be useful to simply make a macro like a `(place-images* ([imag1 x y] ...))` or the like? Maybe it's one of those now you have two problems! type of situations and not suitable for the context, I don't know. On Mon, 24 Aug 2015, John Carmack wrote: The idea that you functionally compose images like this: (place-image image-1 x y (place-image image-2 x y (place-image image-3 x y))) Which draws image1 on top of image2 on top of image 3, which is backwards from the painters order that would draw image 3, then image 2, then image 1. This imperative, side-effect-ing code is a little less clear to a beginner with the OOP and DC concepts, but It better represents what actually happens, and it is much easier to modify the code without worrying about the nesting. (send dc draw-bitmap imag3 x y) (send dc draw-bitmap imag2 x y) (send dc draw-bitmap imag1 x y) -Original Message- From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of David Grenier Sent: Monday, August 24, 2015 1:14 PM To: Racket Users Cc: John Carmack Subject: [racket-users] Re: My son's game in Racket On Monday, August 24, 2015 at 12:28:07 PM UTC-4, John Carmack wrote: We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” Not clear what was meant both times you wrote backwards are you referring to the lisp-style function call? Something that could be alleviated by say F#'s pipe forward operator? let (|) a f = f a or Clojure's - macro? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://urldefense.proofpoint.com/v1/url?u=https://groups.google.com/d/optoutk=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0Ar=Kjg6LltY9QjkipKooaVldA%3D%3D%0Am=HArZE0M9OqU4wspKLzQzG6N5gO9ncSxPP9qVzkUgoVU%3D%0As=b451faca736dc42c554f148983e7279865ef32be9ddf2df75f5c88c15dd34a73. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Literate programming and submodules
On 08/08/2015 16:59, Matthew Flatt wrote: The problem here is the same as in https://groups.google.com/d/msg/racket-users/H7vilh3KcD4/pGZif3F3dEkJ Indeed, adding that require line fixes the problem. Thanks! I still haven't thought about it enough to fine better solution than putting `require (only-in racket/base #%module-begin))` before the submodule declaration. I'll profit from this situation for a feature request that looks somehow related: it would be nice if I could specify somewhere the bindings for my module as something other than racket/base. For example racket or lazy. In fact, if I write (require racket) instead of (require (only-in racket/base #%module-begin)), I gain in two ways: - I get all the bindings I expect. - It looks much less like a kludge. It would then make sense to have something like @bindings[racket] at the top of my scribble/lp2 module to put this information in a more prominent place. Konrad. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] `divides?` from math/number-theory slow?
Hi, I noticed that the `divides?` function from math/number-theory seems to be a huge bottleneck for whatever reason. This seems strange to me, but I figured I'd write to the list to see if maybe there are trade-offs made that make sense mostly for big integers or something. Example with (time): #lang racket/base (require (only-in math/number-theory divides?)) (define (divisible-by? x d) (= (modulo x d) 0)) (module+ main (time (for/sum ([x (in-range 3 5)]) (if (3 . divides? . x) x 0))) ; cpu time: 96257 real time: 96166 gc time: 128 (time (for/sum ([x (in-range 3 5)]) (if (x . divisible-by? . 3) x 0))) ; cpu time: 7277 real time: 7266 gc time: 0 ) -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] `divides?` from math/number-theory slow?
I hope someone has solution. It looks very odd to me. The function divides? is defined in https://raw.githubusercontent.com/racket/math/master/math-lib/math/private/number-theory/divisibility.rkt #lang typed/racket/base (provide divides? coprime? pairwise-coprime? bezout) ;;; ;;; DIVISIBILITY ;;; (: divides? : Integer Integer - Boolean) ; a divides b = exists unique k s.t. a*k=b (define (divides? a b) (cond [(zero? a) #f] [else (= (remainder b a) 0)])) 2015-08-24 12:41 GMT+02:00 Rickard Andersson rickard.m.anders...@gmail.com : Hi, I noticed that the `divides?` function from math/number-theory seems to be a huge bottleneck for whatever reason. This seems strange to me, but I figured I'd write to the list to see if maybe there are trade-offs made that make sense mostly for big integers or something. Example with (time): #lang racket/base (require (only-in math/number-theory divides?)) (define (divisible-by? x d) (= (modulo x d) 0)) (module+ main (time (for/sum ([x (in-range 3 5)]) (if (3 . divides? . x) x 0))) ; cpu time: 96257 real time: 96166 gc time: 128 (time (for/sum ([x (in-range 3 5)]) (if (x . divisible-by? . 3) x 0))) ; cpu time: 7277 real time: 7266 gc time: 0 ) -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- -- Jens Axel Søgaard -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
On Aug 24, 2015, at 11:32 AM, John Carmack jo...@oculus.com wrote: The idea that you functionally compose images like this: (place-image image-1 x y (place-image image-2 x y (place-image image-3 x y))) Which draws image1 on top of image2 on top of image 3, which is backwards from the painters order that would draw image 3, then image 2, then image 1. This imperative, side-effect-ing code is a little less clear to a beginner with the OOP and DC concepts, but It better represents what actually happens, and it is much easier to modify the code without worrying about the nesting. (send dc draw-bitmap imag3 x y) (send dc draw-bitmap imag2 x y) (send dc draw-bitmap imag1 x y) Working with my children and first-year students I see this problem all the time; probably at least half of the kids I work with feel this way. After thinking about it a bit, though, I see that the fundamental problem here isn’t functional vs. imperative; it has to do with operator order. So, for instance, I claim that my students would be (relatively) happy if they got to write ((image3 place-image x y image2) place-image x y image1) I don’t have a good answer here—many people have tried to build infix syntax for Scheme Racket, and none of them has yet caught on. Perhaps Alex Knauth’s macro is the right thing, but what’s really needed (it seems to me) is a solution with widespread acceptance. John -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] web-server: generating HTML with styles
Hi John, On 8/24/2015 4:31 PM, John Clements wrote: On Aug 24, 2015, at 12:35 PM, George Neuner gneun...@comcast.net wrote: I'm trying to generate some very simple web pages - basically success/failure status for URLs followed from an email. However, I can't seem to figure out how to apply styles - other than predefined headings h1, etc. - to the document. Can you explain in more detail what you mean by “styles”? It sounds like you want to take a plain-looking HTML page and change the way it looks—colors, fonts, etc. If I’m right about this, then most of what you want will likely be accomplished by associating a CSS file with your page. That's exactly what I want, but I would like to avoid having separate files associated with this. I would like to generate the HTML in Racket because I need to dynamically insert information into it. E.g., (send/back (response/xexpr `(html (body (list (p Hello (b ,username)) (p (style color:red ; - how to do this? An error occurred processing your request.)) : as in the web-server documentation (sans the style clause). There are examples of reading HTML from a string ... and I suppose I could do that ... but not of generating styled content directly. There is a style struct and a style function in the HTML module, and it seems like many of the generating functions permit attributes to be attached to their document nodes, but there don't seem to be any examples, and I am unable to figure it out from the documentation (which seems quite cryptic in relation to most Racket documentation). George -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
On Monday, August 24, 2015 at 5:43:38 PM UTC, John Carmack wrote: He didn't have any difficulty applying the functional image model, but when you have 20 lines of text drawing composed together, it really looks like you are just drawing things one after another, but backwards. (define (pipe . d) (apply compose (reverse d))) ;-) -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Re: My son's game in Racket
Le lundi 24 août 2015 12:28:07 UTC-4, John Carmack a écrit : We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” Hello John, Thanks for sharing. Played a few levels and had fun :) I have a 10 year old daughter. Did your son show interest in programming or did you initiate him yourself? I remember I started when I was 10 years old as well. I'd like to introduce my daughter to programming too, and was wondering when the right time would be. I tried Logo last year, but after 5 minutes, she didn't see any interest in it. Have a great day! François Beausoleil -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] RE: My son's game in Racket
I would love it if he found it endlessly fascinating and spent all day programming on his own, but he does need a bit of a push from mom and dad. He enjoys it, but given the choice, he would still rather play games than make them :-) He reacted very positively to the initial intro to racket with pictures, which was a contributing factor to settling on Racket. Java / C# work seemed to feel more like homework, but changing numbers and colors in the REPL had him smiling and excited. -Original Message- From: François Beausoleil [mailto:francois.beausol...@gmail.com] Sent: Monday, August 24, 2015 2:41 PM To: Racket Users Cc: John Carmack Subject: Re: My son's game in Racket Le lundi 24 août 2015 12:28:07 UTC-4, John Carmack a écrit : We “released” my 10 year old son’s game that was done in Racket: www.1k3c.com I’m still taking a little heat from my wife for using an obscure language instead of something mainstream that is broadly used in industry, but I have nothing but good things to say about using Racket and DrRacket for a beginning programmer, and highly recommend it. I can’t recommend 2htdp/universe for this sort of thing, though. I had to drop to the native GUI bitmaps for performance reasons, hack around the lifecycle to support a separate editor window, and I still don’t know how to make the Quit menu item actually exit the app on the Mac version. I completely understand the reasoning for the way 2htdp/universe is built, and saying that a “real” project should use the grown-up APIs is fine, but the evolution from making a little animation to controlling it somehow to fleshing it out into a game is so natural that recommending a fairly big rewrite is unfortunate. I’m a big booster of functional programming, but I’m not sure that the functional drawing paradigm ever really sank in while my son was working with it, rather it felt like you just drew everything backwards with missing parenthesis at the end. I suspect that using the standard imperative GUI drawing code will make perfect sense to him. I’m not sure yet if we are going to migrate to the regular GUI code for upcoming work, or jump all the way to OpenGL so he can learn the joys of “Why is the screen all black?” Hello John, Thanks for sharing. Played a few levels and had fun :) I have a 10 year old daughter. Did your son show interest in programming or did you initiate him yourself? I remember I started when I was 10 years old as well. I'd like to introduce my daughter to programming too, and was wondering when the right time would be. I tried Logo last year, but after 5 minutes, she didn't see any interest in it. Have a great day! François Beausoleil -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] (set-implements? (mutable-set) 'set-add)
It seems to me that (set-implements? (mutable-set) 'set-add) should return #f, and in 6.1.1 (and I think 6.2), that's true. But in the latest snapshots, it produces #t. It seems like it's implemented as an error message instead of not implemented at all, and `set-implements?` can't tell the difference between implemented with an error message and actually implemented. Is this a choice with reasons behind it, or should this be a bug? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] web-server: generating HTML with styles
Hi George, There is no feature of the Web server that you need. All you need to do is generate a different HTML page. For instance, if you are currently generating htmlbodypYo!/p/body/html with `(html (body (p Yo!))) And you want to add a stylesheet, so that you get the output htmlheadlink rel=stylesheet type=text/css href=theme.css/headbodypYo!/p/body/html then write `(html (head (link ([rel stylesheet] [type text/css] [href theme.css]))) (body (p Yo!))) And if you want to add style attributes on a single element, like the p: htmlbodyp style=color: puce;Yo!/p/body/html Then write `(html (body (p ([style color: puce;]) Yo!))) Jay On Mon, Aug 24, 2015 at 3:35 PM, George Neuner gneun...@comcast.net wrote: Hi all, I'm trying to generate some very simple web pages - basically success/failure status for URLs followed from an email. However, I can't seem to figure out how to apply styles - other than predefined headings h1, etc. - to the document. Are there any extended examples of generating HTML with styling or of attaching attributes to document nodes? I've been looking through the documentation all day, but I have found only the list of functions and struct types available: e.g., (style v ...) → procedure? v : outputable/c Not terribly informative as to what is expected as input. I have discovered include-template, but AFAICT it seems to be meant for compile-time use ... I need to insert information into the pages dynamically at run-time. Obviously, I could read/process HTML files from disk, but I need to create several pages and having separate files seems like a good way for the code and the page templates to get out of sync. Thanks, George -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy http://jeapostrophe.github.io Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great. - DC 64:33 -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] My son's game in Racket
On Aug 24, 2015, at 3:40 PM, François Beausoleil francois.beausol...@gmail.com wrote: Le lundi 24 août 2015 12:28:07 UTC-4, John Carmack a écrit : ... Hello John, Thanks for sharing. Played a few levels and had fun :) I have a 10 year old daughter. Did your son show interest in programming or did you initiate him yourself? I remember I started when I was 10 years old as well. I'd like to introduce my daughter to programming too, and was wondering when the right time would be. I tried Logo last year, but after 5 minutes, she didn't see any interest in it. Have a great day! François Beausoleil -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. Francois, since you are on the Racket mailing list, may I recommend the Bootstrap material? It is a restricted version of the Universe approach as John calls it, tailored to 10-12 year olds who are just finding out about expressions and functions (in the US. Does not apply to my experience with European schools.) You can play with this in DrRacket off-line or if you prefer you can use WeScheme as an on-line tool with this approach. The point is to reinforce math (a traditional school topic) with programming and to use this kind of programming as a gateway for real programming (in a mostly functional style. None of us are purists; we are American pragmatists.) See bootstrap-world.org -- Matthias -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: DrRacket Scribbles OK, but can't build docs with raco
Oh wow I thought I had deleted that long ago. Thank you, that was the problem. On Aug 24, 2015 4:11 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I think you need to remove the local-require in the definition of to-file in continued-fractions.rkt. This counts as a real require for dependency purposes; it just makes the imports scoped locally. dynamic-require is the way to get a require that happens only at runtime (but in this case, if you decide to keep that function there, you probably want to use the racket/gui/dynamic library). hth, Robby On Mon, Aug 24, 2015 at 11:48 AM, Deren Dohoda deren.doh...@gmail.com wrote: Actually quoting it was the wrong thing to do, as I found out when I finally looked at the docs. The docs are not very complicated, if someone could take a look at the cf-manual.scrbl and see if something obvious is going wrong I'd appreciate it. https://github.com/derend/continued-fractions/blob/master/continued-fractions/cf-manual.scrbl Deren On Mon, Aug 24, 2015 at 11:40 AM, Deren Dohoda deren.doh...@gmail.com wrote: I have tracked it down finally to a very stupid error. Some uses of @examples or @interaction-eval were not given quoted expressions and this was the problem. It's actually surprising that it works in DrRacket, which was very misleading. Deren On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com wrote: I have a scribble document with several examples. When I view the scribble html output by using DrRacket, all the examples are fine, the output is correct, and I see no errors. Then I go to the directory, use raco pkg install, and I get a major text dump which starts with cannot instantiate 'racket/gui/base' a second time in the same process. But I didn't even try to instantiate it the first time. There's no use of gui at all in any part of the collection. I only create one evaluator for scribble examples: @(define this-eval (let ([eval (make-base-eval)]) (eval '(begin (require racket/math main.rkt))) eval)) What could I be doing wrong? Thanks, Deren -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: My son's game in Racket
On Aug 24, 2015, at 2:32 PM, John Carmack jo...@oculus.com wrote: The idea that you functionally compose images like this: (place-image image-1 x y (place-image image-2 x y (place-image image-3 x y))) Which draws image1 on top of image2 on top of image 3, which is backwards from the painters order that would draw image 3, then image 2, then image 1. This imperative, side-effect-ing code is a little less clear to a beginner with the OOP and DC concepts, but It better represents what actually happens, and it is much easier to modify the code without worrying about the nesting. (send dc draw-bitmap imag3 x y) (send dc draw-bitmap imag2 x y) (send dc draw-bitmap imag1 x y) This is a serious wart, but I didn't expect that when I read backwards. In HtDP/ISL, I use [1] You can develop s0 ... s3 at the top-level, when you like them you esc-k, ctrl-y place them into a local: (define (render.v1 w) (local ((define s0 (empty-scene 100 100)) (define s1 (place-image (circle 30 'solid 'yellow) 5 20 s0)) (define s2 (place-image (rectangle 10 20 'solid 'blue) 90 90 s1)) (define s3 (place-image (triangle 100 'solid 'red) 90 10 s2))) s3)) [2] Or you can use let* as someone else pointed out (define (render.v2 w) (let* ((s (empty-scene 100 100)) (s (place-image (circle 30 'solid 'yellow) 5 20 s)) (s (place-image (rectangle 10 20 'solid 'blue) 90 90 s)) (s (place-image (triangle 100 'solid 'red) 90 10 s))) s)) [3} But my favorite is this, when i try to explain kids abstraction and the advantage of having values around instead of effects: (define (render.v3 w) (foldr (lambda (x s) (apply place-image- s x)) background pieces)) [4] We do need a for/image so that #lang racket programmers can do even better. ;; --- somewhere else: (define background (empty-scene 100 100)) (define pieces `((,(circle 30 'solid 'yellow) ,(rectangle 10 20 'solid 'blue) ,(triangle 100 'solid 'red -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] (set-implements? (mutable-set) 'set-add)
Was it this commit here? https://github.com/plt/racket/commit/606a94621253391536e9c89c573dc70fd28efbe6 On Aug 24, 2015, at 5:50 PM, Alexander D. Knauth alexan...@knauth.org wrote: It seems to me that (set-implements? (mutable-set) 'set-add) should return #f, and in 6.1.1 (and I think 6.2), that's true. But in the latest snapshots, it produces #t. It seems like it's implemented as an error message instead of not implemented at all, and `set-implements?` can't tell the difference between implemented with an error message and actually implemented. Is this a choice with reasons behind it, or should this be a bug? -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: DrRacket Scribbles OK, but can't build docs with raco
I think you need to remove the local-require in the definition of to-file in continued-fractions.rkt. This counts as a real require for dependency purposes; it just makes the imports scoped locally. dynamic-require is the way to get a require that happens only at runtime (but in this case, if you decide to keep that function there, you probably want to use the racket/gui/dynamic library). hth, Robby On Mon, Aug 24, 2015 at 11:48 AM, Deren Dohoda deren.doh...@gmail.com wrote: Actually quoting it was the wrong thing to do, as I found out when I finally looked at the docs. The docs are not very complicated, if someone could take a look at the cf-manual.scrbl and see if something obvious is going wrong I'd appreciate it. https://github.com/derend/continued-fractions/blob/master/continued-fractions/cf-manual.scrbl Deren On Mon, Aug 24, 2015 at 11:40 AM, Deren Dohoda deren.doh...@gmail.com wrote: I have tracked it down finally to a very stupid error. Some uses of @examples or @interaction-eval were not given quoted expressions and this was the problem. It's actually surprising that it works in DrRacket, which was very misleading. Deren On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com wrote: I have a scribble document with several examples. When I view the scribble html output by using DrRacket, all the examples are fine, the output is correct, and I see no errors. Then I go to the directory, use raco pkg install, and I get a major text dump which starts with cannot instantiate 'racket/gui/base' a second time in the same process. But I didn't even try to instantiate it the first time. There's no use of gui at all in any part of the collection. I only create one evaluator for scribble examples: @(define this-eval (let ([eval (make-base-eval)]) (eval '(begin (require racket/math main.rkt))) eval)) What could I be doing wrong? Thanks, Deren -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] web-server: generating HTML with styles
Hi Matthew, Jay beat you to the answer 8-) [though the list apparently bounced my reply to him] I do appreciate your detailed explanation. I knew that I did not need the html module to use response/xexpr in the web-server, but I was looking for some syntax to add styling to the content, and I was searching through every html related link in the documentation. I really wish I could have figured it out on my own. Thanks, George On 8/24/2015 6:13 PM, Matthew Butterick wrote: I haven't used the HTML module (though it is, AFAICT, intended for parsing HTML, not writing it). But the examples in the webserver docs (e.g., `send/back`) don't use that module. Instead, they construct responses out of X-expressions. Judging from your example, perhaps you are mixing up the two? (Or maybe three — the documentation snippet you cited for `style` was from `scribble/html/html`, which is yet another thing.) For example, the quasiquoting on this expression makes it an X-expression, so the tag names (html, body, p) are just quoted symbols, not structs or functions from another module. So as you've written it, it won't work. `(html (body (list (p Hello (b ,username)) (p (style color:red ; - how to do this? An error occurred processing your request.)) There's no `list` necessary in an X-expression, and the attributes are separated. So the correct X-expression syntax would be: `(html (body (p Hello (b ,username)) (p ((style color:red)) An error occurred processing your request.))) For styling, you have three choices. 1) Apply the styling directly to the tag as an attribute. As shown above. 2) Apply the styling indirectly through an external CSS file, as John Clements suggested. To do this, you'd need to give your target a 'class' or 'id', and then it would take on whatever styling was defined in the CSS file, e.g., `(html (body (p Hello (b ,username)) (p ((class error)) An error occurred processing your request.))) 3) Or, since you don't want an external file, you can apply the styling indirectly with inline CSS. You'd still need to give your target a 'class' or 'id', but then the style sheet itself can live inside the X-expression: `(html (style ((type text/css)) .error {color: red;}) (body (p Hello (b ,username)) (p ((class error)) An error occurred processing your request.))) Again, none of these options use external functions. They're just X-expressions and you can generate them however you like. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] web-server: generating HTML with styles
On 8/24/2015 4:49 PM, Jay McCarthy wrote: And if you want to add style attributes on a single element, like the p: htmlbodyp style=color: puce;Yo!/p/body/html Then write `(html (body (p ([style color: puce;]) Yo!))) Thanks Jay! That's exactly what I needed. George -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.