maxim_jaffe
2018-7-30 11:35:17

Can someone suggest a more in depth document/article/etc for the gui framework ?


maxim_jaffe
2018-7-30 11:35:40

I’m having trouble going through it but it looks really useful


soegaard2
2018-7-30 11:42:32

In depth tutorials on the GUI is something we lack.


soegaard2
2018-7-30 11:42:42

soegaard2
2018-7-30 11:43:23

The gui library uses classes and objects, so maybe this can be of help too:



maxim_jaffe
2018-7-30 11:44:07

yes I followed that one I actually mean the https://docs.racket-lang.org/framework/index.html?q=frame%3A



maxim_jaffe
2018-7-30 11:45:03

I’m trying some guesswork here


maxim_jaffe
2018-7-30 11:45:40

I skim through the class guide docs and until now it’s been pretty easy to follow


maxim_jaffe
2018-7-30 11:46:10

and it feels a lot cleaner then Python classes :slightly_smiling_face:


soegaard2
2018-7-30 11:47:01

If you have a frame as in (define frame (new frame% ...) then you can make menus like this:


soegaard2
2018-7-30 11:47:20

(define mb (new menu-bar% (parent frame)))


soegaard2
2018-7-30 11:47:45

(define m (new menu% (label "File") (parent mb)))


maxim_jaffe
2018-7-30 11:48:23

sure


maxim_jaffe
2018-7-30 11:48:28

I’ve a few hehe


maxim_jaffe
2018-7-30 11:49:04

a snippet


soegaard2
2018-7-30 11:49:07

In lieu of tutorials, try finding an existing gui program and see what it does.


maxim_jaffe
2018-7-30 11:49:41

I was actually trying to find the framework repository itself


maxim_jaffe
2018-7-30 11:49:49

to see if I could better understand it



maxim_jaffe
2018-7-30 11:50:25

know of any that uses framework?


maxim_jaffe
2018-7-30 11:50:37

ah it’s inside the gui!


maxim_jaffe
2018-7-30 11:50:41

go figure hehe


philip.mcgrath
2018-7-30 11:50:56

https://github.com/racket/drracket/ is the most prominent one


maxim_jaffe
2018-7-30 11:52:41

yeah I guess hehe


maxim_jaffe
2018-7-30 11:52:48

anything simpler :stuck_out_tongue:


philip.mcgrath
2018-7-30 11:52:53

https://github.com/alex-hhh/ActivityLog2/ is another big GUI app, and I think it uses at least some things from framework



maxim_jaffe
2018-7-30 11:53:34

by the way can you point me to the/a doc explaining how racket repositories are organized


philip.mcgrath
2018-7-30 11:54:16

I agree more tutorials would be helpful: I sort of stumbled into developing an internal GUI program, and I constantly wonder if I’m doing the right thing or reinventing the wheel.


maxim_jaffe
2018-7-30 11:54:28

yup found that one too yesterday, was quite helpful, thanks anyways


maxim_jaffe
2018-7-30 11:57:44

Yeah I am having the same feeling


maxim_jaffe
2018-7-30 11:59:24

cool this works nicely


maxim_jaffe
2018-7-30 12:46:48

maxim_jaffe
2018-7-30 12:46:58

A bit like glade or wxglade it seems


samth
2018-7-30 13:51:38

As a non-author on that paper, here’s what I think: 1. Betteridge’s law definitely applies. 2. It’s relatively easy to make transient gradual typing cost ~0 with a decent JIT compiler 3. Typed Racket in particular is the worst-case scenario for GT performance, because it implements gradual typing using contracts, which are a more general and harder to optimize mechanism, and implements contracts using chaperones (same), and the contract system and compiler don’t work together very well, and our compiler is not very good on chaperones. 4. Pycket demonstrates that even in that setting, we can do pretty well, and hopefully even more can be done there. 5. People who have built compilers specifically for gradual typing have already gotten better performance on challenging programs.


maxim_jaffe
2018-7-30 14:06:29

actually sort of nicer then wxglade (at least it looks a bit more modern)


maxim_jaffe
2018-7-30 14:42:46

Isn’t this supposed to scale up the bitmap?


soegaard2
2018-7-30 14:44:34

No.


soegaard2
2018-7-30 14:44:57

Scale affects the transformation from drawing coordinates to canvas coordinates.


soegaard2
2018-7-30 14:45:17

So if you now draw, say, a square of size 2 it will be larger than before.


soegaard2
2018-7-30 14:47:11

That is, scale affects the following drawing operations.


philip.mcgrath
2018-7-30 14:48:21

For most purposes, I prefer using pict than the low-level racket/draw.


lexi.lambda
2018-7-30 14:51:46

I second pict here. Using pict, the scale function will do what you want in a more intuitive (and significantly less imperative) way.


maxim_jaffe
2018-7-30 14:53:26

problem is I think it’s too heavy for what I need, I tried it with pict


maxim_jaffe
2018-7-30 14:54:05

I just need to color each “pixel” in a certain color, but I wanted the pixel to scale


maxim_jaffe
2018-7-30 14:54:38

so I can generate something like a heatmap


maxim_jaffe
2018-7-30 14:55:03

to turn a matrix or 2d array into a simple raster view


maxim_jaffe
2018-7-30 14:55:42

and these are large arrays


maxim_jaffe
2018-7-30 14:55:49

at least 1000 x 1000


maxim_jaffe
2018-7-30 14:56:19

I’d like to eventually embedded into a gui canvas


lexi.lambda
2018-7-30 14:56:26

If you want, you can use pict together with racket/draw. If you use the dc function from pict, you can use a racket/draw drawing context to produce a pict that can be subsequently used with scale. http://docs.racket-lang.org/pict/Basic_Pict_Constructors.html#%28def._%28%28lib._pict%2Fmain..rkt%29._dc%29%29


lexi.lambda
2018-7-30 14:58:35

Now, if you don’t want to deal with pict at all, you can certainly just use racket/draw directly, but as @soegaard2 mentions, scale only affects subsequent drawing operations, so you’d have to call it before you do your drawing.


lexi.lambda
2018-7-30 14:58:52

(The racket/draw API is ruthlessly imperative.)


maxim_jaffe
2018-7-30 15:00:05

hang on will show you my attempts at both


maxim_jaffe
2018-7-30 15:01:09

I didn’t enjoy using racket/draw due to the imperative style


maxim_jaffe
2018-7-30 15:01:15

but I found it way faster


maxim_jaffe
2018-7-30 15:01:32

but maybe I am doing something silly with pict


maxim_jaffe
2018-7-30 15:01:56

mind you I am using rectangle with pict while with racket/draw I am using draw-point


maxim_jaffe
2018-7-30 15:34:27

Ok hope this comparison is minimally fair


maxim_jaffe
2018-7-30 15:34:41

Welcome to DrRacket, version 6.12 [3m]. Language: racket, with debugging; memory limit: 256 MB. 10 world-draw: cpu time: 5 real time: 5 gc time: 0 10 world-pict: cpu time: 1 real time: 1 gc time: 0 100 world-draw: cpu time: 188 real time: 188 gc time: 0 100 world-pict: cpu time: 509 real time: 509 gc time: 126 200 world-draw: cpu time: 765 real time: 764 gc time: 0 200 world-pict: cpu time: 3336 real time: 3331 gc time: 428 400 world-draw: cpu time: 3028 real time: 3026 gc time: 7 400 world-pict: cpu time: 25337 real time: 25308 gc time: 3750


maxim_jaffe
2018-7-30 15:35:19

I can’t find a equivalent in pict to racket/draw draw-point


maxim_jaffe
2018-7-30 15:35:36

let me know if I missed a obvious alternative


maxim_jaffe
2018-7-30 15:36:27

I am open to suggestions on improving the pict function :slightly_smiling_face:


samth
2018-7-30 15:36:46

pin-over may be what you want


maxim_jaffe
2018-7-30 15:38:23

hum in what way? I am already using the table to join everything together


samth
2018-7-30 15:40:39

(for*/fold ([p (rectange n n)]) ([i n] [j n]) (pin-over p i j (filled-rectangle ...)))


samth
2018-7-30 15:40:55

also if you just create the filled-rectangle once it’ll be faster


maxim_jaffe
2018-7-30 15:41:11

ah yes true, I think I actually did that but forgot


maxim_jaffe
2018-7-30 15:41:26

but removed when rewriting


maxim_jaffe
2018-7-30 15:41:30

let me give that a try


maxim_jaffe
2018-7-30 15:42:44

yeah way better


maxim_jaffe
2018-7-30 15:42:51

at least they are in the same magnitude of time now


maxim_jaffe
2018-7-30 15:43:36

be creating the rectangle before hand


philip.mcgrath
2018-7-30 15:46:52

In all of your for loops, you will get better performance with in-range than just using the number.


lexi.lambda
2018-7-30 15:54:05

@maxim_jaffe For what it’s worth, I think (hline 0 0) will produce a pict that does the same thing as draw-point.


maxim_jaffe
2018-7-30 15:58:22

Thanks all, sorry for the delayed answer but running this is sucking up all my ram :laughing: (using slack mobile right now)


maxim_jaffe
2018-7-30 15:59:18

@philip.mcgrath I thought in for loops [i n] was the same as (in-range n)


philip.mcgrath
2018-7-30 16:00:59

It is the same in meaning, but in-range, in-list, and many other sequence constructors cooperate with the for family of macros to give better performance by generating specialized code when they are statically visible in a loop clause.


pnwamk
2018-7-30 16:01:31

where “meaning” means “it will produce the same values”


maxim_jaffe
2018-7-30 16:02:09

Hum ok! I actually find that ok it’s a bit like what you do in python


maxim_jaffe
2018-7-30 16:02:23

range(10)


maxim_jaffe
2018-7-30 16:02:47

for i in range(10):


maxim_jaffe
2018-7-30 16:03:06

And range in python is a generator


lexi.lambda
2018-7-30 16:03:28

fwiw I think TR can automatically specialize (for ([i n]) ...) to (for ([i (in-range n)]) ...) when n is a number, but I’m not completely sure


maxim_jaffe
2018-7-30 16:03:51

@lexi.lambda Yeah I guess a line with no length is a point hehe


maxim_jaffe
2018-7-30 16:04:10

Ah ok maybe that’s where I got that


maxim_jaffe
2018-7-30 16:04:25

I started using it on suggestion of someone here


maxim_jaffe
2018-7-30 16:04:40

Can’t remember who


philip.mcgrath
2018-7-30 16:05:04

@lexi.lambda It would be neat if for could do that in general when the sequence is a literal datum, though I don’t know how much of a pain that would be to implement.


maxim_jaffe
2018-7-30 16:05:11

Was using (range n) before but then someone explained it actually generated a list


maxim_jaffe
2018-7-30 16:05:58

And to use in-range or even [i n] but maybe that was for typed racket


pnwamk
2018-7-30 16:06:54

Typed Racket has no for-specific optimizations


lexi.lambda
2018-7-30 16:07:11

oh well


lexi.lambda
2018-7-30 16:07:49

I thought that might be the case given that it would require replacing the expansion of for with a different one, but it seemed not-impossible


pnwamk
2018-7-30 16:08:18

it’s not impossible AFAIK, it just isn’t done


lexi.lambda
2018-7-30 16:08:25

and I had thought I vaguely remembered the optimization coach telling me TR managed to specialize for loops at some point


pnwamk
2018-7-30 16:08:26

the optimizer does indeed rewrite code


pnwamk
2018-7-30 16:08:29

just not that code


lexi.lambda
2018-7-30 16:09:04

yes, it just seems like a slightly more complicated optimization than one might expect (since TR has to deal with the fully-expanded code)


maxim_jaffe
2018-7-30 16:10:04

3876mb


maxim_jaffe
2018-7-30 16:10:13

What the hell :p…


maxim_jaffe
2018-7-30 16:10:31

Why doesn’t DrRacket release the memory


maxim_jaffe
2018-7-30 16:10:50

It’s done running and I’ve been waiting for a minute now just to move my mouse


maxim_jaffe
2018-7-30 16:11:19

DrRacket


maxim_jaffe
2018-7-30 16:11:55

The memory usage is my only big complaint of DrRacket


pnwamk
2018-7-30 16:12:01

yikes, I’m digging more, perhaps TR does optimize that loop :laughing: (it’s more complicated than the optimized in-range expansions I’m used to seeing so I assumed it was not, but digging more it seems it is generating some custom iteration functions)


pnwamk
2018-7-30 16:12:34

either way… personally I would just use in-range so it’s fast no matter the #lang line :smiley:


maxim_jaffe
2018-7-30 16:13:00

Finally back to 300mb~


soegaard2
2018-7-30 16:13:08

It’s a shame range returns a list. It should have been a value representing the range instead.


maxim_jaffe
2018-7-30 16:13:30

Yeah I think most other languages do that


maxim_jaffe
2018-7-30 16:13:56

Imean in python you only get a list if you do list(range n))


maxim_jaffe
2018-7-30 16:14:24

And I vaguely remember Haskell and Scala being similar


maxim_jaffe
2018-7-30 16:15:37

But I might be wrong


lexi.lambda
2018-7-30 16:16:10

The relationship between Racket’s range and in-range are similar (but not identical to) the relationship between Python 2.x’s range and xrange, but I think @soegaard2 is asking for something different, namely having range construct a value that keeps track of only the beginning and ending values (plus the value of each step) of the range rather than producing a sequence at all.


maxim_jaffe
2018-7-30 16:16:42

Well I think that’s what python does


maxim_jaffe
2018-7-30 16:17:15

Python 3.6.6 (default, Jun 27 2018, 13:11:40) [GCC 8.1.1 20180531] on linux Type "help", "copyright", "credits" or "license" for more information. >>> range(10) range(0, 10)


lexi.lambda
2018-7-30 16:17:48

Even in Python 3, range just produces a sequence. I don’t believe there’s a way to get the start and end values of a sequence produced by range without iterating through it.


maxim_jaffe
2018-7-30 16:18:48

>>> range(0, 10).start 0 >>> range(0, 10).stop 10 >>>


lexi.lambda
2018-7-30 16:18:58

Ah! I am incorrect, then.


maxim_jaffe
2018-7-30 16:19:16

hehe well I know my Python tricks :laughing:


lexi.lambda
2018-7-30 16:19:34

It probably wouldn’t actually be that hard to change Racket’s in-range to do the same thing in a backwards-compatible way.


maxim_jaffe
2018-7-30 16:19:41

I only “gave up” on Python after extensive digging around


maxim_jaffe
2018-7-30 16:19:57

and feeling unfullfilled


maxim_jaffe
2018-7-30 16:19:59

hehe


maxim_jaffe
2018-7-30 16:20:46

Python 2.7.15 (default, Jun 27 2018, 13:05:28) [GCC 8.1.1 20180531] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> range(0, 10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> range(0, 10).start Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'start' >>> range(0, 10).stop Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'stop' >>>


maxim_jaffe
2018-7-30 16:21:10

but it’s a Python 3 thing


maxim_jaffe
2018-7-30 16:21:36

Python 3 has a lot of nice tricks you don’t get in Python 2


maxim_jaffe
2018-7-30 16:21:45

was one of the reasons why I did eventually go for it


maxim_jaffe
2018-7-30 16:23:07

Oddly enough >>> xrange(1, 10, 2).start Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'xrange' object has no attribute 'start' >>>


maxim_jaffe
2018-7-30 16:23:18

Go figure.


Bot messages not yet supported
leif
2018-7-30 19:36:33

@greg Wait, isn’t the :kidney: emoji the one I added as a joke? :smile:


leif
2018-7-30 19:37:35

Anyway….


leif
2018-7-30 19:38:35

@robby Is there any way to a drracket:module-language-tools:add-online-expansion-monitor, that module languages have to subscribe to (rather than having it applied globally).


leif
2018-7-30 19:39:05

Similarly to how drracket:module-language-tools:add-opt-in-toolbar-button seems allow module languages to subscribe to them?


robby
2018-7-30 19:41:07

not currently


leif
2018-7-30 19:42:12

Okay. Any sense of how hard it would be to add it? (To be clear, I’m not asking you to do it, I’m just looking at how hard it would be to make a new background expander for a particular module language.)


leif
2018-7-30 19:43:59

And so far the two ways that seem to exist are either:

  1. Use the online-expansion-monitor, and try to determine the current language from the #lang line.

  2. Use the 'definitions-text-surrogate protocol, and extend the on-change method to try to do it in another place.


leif
2018-7-30 19:44:06

Although maybe there’s a third option that I’ve missed?


zenspider
2018-7-30 20:15:29

Following up… according to (current-directory) in drracket, It’s my home directory.

I think for package upgrades/work tho, paths should probably be absolute so you can copy/paste into any terminal if something goes wrong.


zenspider
2018-7-30 20:26:27

New 7.0 drracket is eating up 60% of a CPU just sitting there idle. It also won’t hide in osx (cmd-h). It disappears and then immediately pops back up.


soegaard2
2018-7-30 20:29:18

’(a b c) ’(1 2 3)


soegaard2
2018-7-30 20:29:43

Just noticed that 1 2 3 are colored green in DrRacket, but a b c aren’t.


soegaard2
2018-7-30 20:30:21

Since both expressions are datums, I would prefer both to be green.


zenspider
2018-7-30 20:34:38

is today some special nerd day?


zenspider
2018-7-30 20:35:17

(startup screen)


soegaard2
2018-7-30 20:35:38

Eli’s birthday


zenspider
2018-7-30 20:36:05

@soegaard2 same is true for non-list datums. by themselves, 1 and '1 are both green and 'a is blue


zenspider
2018-7-30 20:40:01
Call graph:
    2400 Thread_5132106: Main Thread   DispatchQueue_<multiple>
    + 2380 scheme_thread_w_details  (in Racket) + 321  [0x1002dc5a1]
    + ! 2380 make_subprocess  (in Racket) + 759  [0x1002dcdb7]
    + !   2380 ???  (in <unknown binary>)  [0x1005b213b]
    + !     2380 start_child  (in Racket) + 1153  [0x1002dc291]
    + !       2380 scheme_top_level_do_worker  (in Racket) + 1599  [0x10007259f]
    + !         2380 apply_k  (in Racket) + 210  [0x100072ff2]
    + !           2380 scheme_do_eval  (in Racket) + 5779  [0x100049e53]
    + !             2380 ???  (in <unknown binary>)  [0x1005a93db]
    + !               2380 _scheme_apply_multi_from_native  (in Racket) + 437  [0x10004c5e5]
    + !                 2380 scheme_do_eval  (in Racket) + 5779  [0x100049e53]
    + !                   1304 ???  (in <unknown binary>)  [0x1005b6f85]

(first real drop-off)

This appears reproducible… Fire it up. I don’t know if it needs anything in the editor, but I’ve had little things (eg the drawing code from #beginners) in it. Let it sit in the background. After a little bit, it starts to burn half a core consistently.


zenspider
2018-7-30 20:40:50

more than half a core really…. or it is evenly distributed across cores:


zenspider
2018-7-30 20:41:03

zenspider
2018-7-30 20:41:09

githree
2018-7-30 20:52:57

@zenspider I wonder if the start up screen could have anything to do with higher consumption by DrRacket ?


leif
2018-7-30 20:57:44

@githree @zenspider I doubt it.


leif
2018-7-30 20:57:57

From my experience, the start up screen just slows down start up….


leif
2018-7-30 20:58:16

(Like, a noticeably slower startup.)


leif
2018-7-30 21:00:00

And while Racket 7 seems to be significantly slower to me than Racket 6.12 (or even previous build of 6.99.x), its not thad bad on my machine. I wonder if this is the background expander in some kind of loop.


leif
2018-7-30 21:08:41

@shu—hung and @yfefyf nice ^.^


leif
2018-7-30 21:08:59

@greg Looking at the files on my machine, it was indeed the kidneys I added. ^.^


shu--hung
2018-7-30 21:11:12

As errortrace (transitively) depends on racket/contract, is it impossible to have errortrace annotate racket/contract?


tsouchlarakis
2018-7-30 21:14:58

@tsouchlarakis has joined the channel


shu--hung
2018-7-30 21:23:32

ahh solved it using (make-errortrace-compile-handler)


jtittsler
2018-7-31 04:32:57

@jtittsler has joined the channel