Can someone suggest a more in depth document/article/etc for the gui framework ?
I’m having trouble going through it but it looks really useful
In depth tutorials on the GUI is something we lack.
There is a small example in the docs: http://docs.racket-lang.org/gui/windowing-overview.html#%28part._.Creating_.Windows%29
The gui library uses classes and objects, so maybe this can be of help too:
yes I followed that one I actually mean the https://docs.racket-lang.org/framework/index.html?q=frame%3A
It seems to have some useful things like https://docs.racket-lang.org/framework/Frame.html?q=standard-menus%25#%28def._%28%28lib._framework%2Fmain..rkt%29._frame~3astandard-menus~25%29%29 but it has no doc at all
I’m trying some guesswork here
I skim through the class guide docs and until now it’s been pretty easy to follow
and it feels a lot cleaner then Python classes :slightly_smiling_face:
If you have a frame as in (define frame (new frame% ...)
then you can make menus like this:
(define mb (new menu-bar% (parent frame)))
(define m (new menu% (label "File") (parent mb)))
sure
I’ve a few hehe
a snippet
In lieu of tutorials, try finding an existing gui program and see what it does.
I was actually trying to find the framework repository itself
to see if I could better understand it
know of any that uses framework?
ah it’s inside the gui!
go figure hehe
yeah I guess hehe
anything simpler :stuck_out_tongue:
https://github.com/alex-hhh/ActivityLog2/ is another big GUI app, and I think it uses at least some things from framework
by the way can you point me to the/a doc explaining how racket repositories are organized
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.
yup found that one too yesterday, was quite helpful, thanks anyways
Yeah I am having the same feeling
cool this works nicely
A bit like glade or wxglade it seems
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.
actually sort of nicer then wxglade (at least it looks a bit more modern)
Isn’t this supposed to scale up the bitmap?
No.
Scale affects the transformation from drawing coordinates to canvas coordinates.
So if you now draw, say, a square of size 2 it will be larger than before.
That is, scale affects the following drawing operations.
For most purposes, I prefer using pict
than the low-level racket/draw
.
I second pict
here. Using pict
, the scale
function will do what you want in a more intuitive (and significantly less imperative) way.
problem is I think it’s too heavy for what I need, I tried it with pict
I just need to color each “pixel” in a certain color, but I wanted the pixel to scale
so I can generate something like a heatmap
to turn a matrix or 2d array into a simple raster view
and these are large arrays
at least 1000 x 1000
I’d like to eventually embedded into a gui canvas
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
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.
(The racket/draw
API is ruthlessly imperative.)
hang on will show you my attempts at both
I didn’t enjoy using racket/draw due to the imperative style
but I found it way faster
but maybe I am doing something silly with pict
mind you I am using rectangle with pict while with racket/draw I am using draw-point
Ok hope this comparison is minimally fair
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
I can’t find a equivalent in pict to racket/draw draw-point
let me know if I missed a obvious alternative
I am open to suggestions on improving the pict function :slightly_smiling_face:
pin-over
may be what you want
hum in what way? I am already using the table to join everything together
(for*/fold ([p (rectange n n)]) ([i n] [j n]) (pin-over p i j (filled-rectangle ...)))
also if you just create the filled-rectangle
once it’ll be faster
ah yes true, I think I actually did that but forgot
but removed when rewriting
let me give that a try
yeah way better
at least they are in the same magnitude of time now
be creating the rectangle before hand
In all of your for loops, you will get better performance with in-range
than just using the number.
@maxim_jaffe For what it’s worth, I think (hline 0 0)
will produce a pict that does the same thing as draw-point
.
Thanks all, sorry for the delayed answer but running this is sucking up all my ram :laughing: (using slack mobile right now)
@philip.mcgrath I thought in for loops [i n] was the same as (in-range n)
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.
where “meaning” means “it will produce the same values”
Hum ok! I actually find that ok it’s a bit like what you do in python
range(10)
for i in range(10):
And range in python is a generator
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
@lexi.lambda Yeah I guess a line with no length is a point hehe
Ah ok maybe that’s where I got that
I started using it on suggestion of someone here
Can’t remember who
@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.
Was using (range n) before but then someone explained it actually generated a list
And to use in-range or even [i n] but maybe that was for typed racket
Typed Racket has no for-specific optimizations
oh well
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
it’s not impossible AFAIK, it just isn’t done
and I had thought I vaguely remembered the optimization coach telling me TR managed to specialize for loops at some point
the optimizer does indeed rewrite code
just not that code
yes, it just seems like a slightly more complicated optimization than one might expect (since TR has to deal with the fully-expanded code)
3876mb
What the hell :p…
Why doesn’t DrRacket release the memory
It’s done running and I’ve been waiting for a minute now just to move my mouse
DrRacket
The memory usage is my only big complaint of DrRacket
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)
either way… personally I would just use in-range
so it’s fast no matter the #lang
line :smiley:
Finally back to 300mb~
It’s a shame range
returns a list. It should have been a value representing the range instead.
Yeah I think most other languages do that
Imean in python you only get a list if you do list(range n))
And I vaguely remember Haskell and Scala being similar
But I might be wrong
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.
Well I think that’s what python does
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)
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.
>>> range(0, 10).start
0
>>> range(0, 10).stop
10
>>>
Ah! I am incorrect, then.
hehe well I know my Python tricks :laughing:
It probably wouldn’t actually be that hard to change Racket’s in-range
to do the same thing in a backwards-compatible way.
I only “gave up” on Python after extensive digging around
and feeling unfullfilled
hehe
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'
>>>
but it’s a Python 3 thing
Python 3 has a lot of nice tricks you don’t get in Python 2
was one of the reasons why I did eventually go for it
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'
>>>
Go figure.
@greg Wait, isn’t the :kidney: emoji the one I added as a joke? :smile:
Anyway….
@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).
Similarly to how drracket:module-language-tools:add-opt-in-toolbar-button
seems allow module languages to subscribe to them?
not currently
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.)
And so far the two ways that seem to exist are either:
Use the
online-expansion-monitor
, and try to determine the current language from the #lang line.Use the
'definitions-text-surrogate
protocol, and extend theon-change
method to try to do it in another place.
Although maybe there’s a third option that I’ve missed?
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.
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.
’(a b c) ’(1 2 3)
Just noticed that 1 2 3 are colored green in DrRacket, but a b c aren’t.
Since both expressions are datums, I would prefer both to be green.
is today some special nerd day?
(startup screen)
Eli’s birthday
@soegaard2 same is true for non-list datums. by themselves, 1
and '1
are both green and 'a
is blue
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.
more than half a core really…. or it is evenly distributed across cores:
@zenspider I wonder if the start up screen could have anything to do with higher consumption by DrRacket ?
@githree @zenspider I doubt it.
From my experience, the start up screen just slows down start up….
(Like, a noticeably slower startup.)
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.
@shu—hung and @yfefyf nice ^.^
@greg Looking at the files on my machine, it was indeed the kidneys I added. ^.^
As errortrace (transitively) depends on racket/contract, is it impossible to have errortrace annotate racket/contract?
@tsouchlarakis has joined the channel
ahh solved it using (make-errortrace-compile-handler)
@jtittsler has joined the channel