soegaard2
2021-6-14 07:01:37

I suppose one cold write !++ and ++! to indicate pre- and post-increment respectively.

I think, I’ll try to find some coding guide lines for Java to see whether they recommend against using ++ in expressions.


alexharsanyi
2021-6-14 09:33:32

Will lazy-require speed up application startup when the application is built as an executable?

I am trying to speed up the startup of my application by using lazy-require for modules which are not needed for the initial window to be displayed (e.g. the module which implements the “Help/About” frame does not need to be loaded until the user selects “help/about” from the menu). While there is an improvement to startup speed when the application is started using racket (e.g. “racket run.rkt”), there does not seem to be any improvement once an executable is built and the executable is run.

Since there is a significant amount of effort to switch to using lazy-require , and my initial tests are not promising, I just wanted to check if this is a valid approach or not…


mflatt
2021-6-14 12:59:24

I think you’re probably right that lazy-require is less effective for reducing startup in an executable created by raco exe. When lazy-require saves time, it’s by not loading module declarations and instead consulting module files on demand; an executable needs all module declarations up front. If instantiating a declared module takes significant time, then lazy-require can still help, but instantiation is not usually the expensive part.


haasis_noah
2021-6-14 13:56:07

@haasis_noah has joined the channel


kykim
2021-6-14 14:16:13

samth
2021-6-14 14:19:12

Unfortunate. @jsyeo do you know what happened?


samdphillips
2021-6-14 14:41:09

Is there a way to get the value of the largest fixnum?


massung
2021-6-14 14:48:45

I’m sure someone will reply with a simple constant that exists, but assuming that fix/flo-nums are just tagged, this should at least get you the value on your system if you need it to make forward progress:

(define (max-fixnum) (letrec ([try (λ (n) (let ([m (sub1 (expt 2 n))]) (if (fixnum? m) m (try (sub1 n)))))]) (try 64)))


massung
2021-6-14 14:49:26

For my (64-bit) it looks like 4-bits for tagging, which makes sense for aligning the pointers to 16-byte boundaries, so 60-bit fixnums.


mflatt
2021-6-14 14:50:33

I keep almost adding a function, but then my use case shifts and I avoid the distraction (in that context) after all.


mflatt
2021-6-14 14:53:10

Here’s code from the current “fixnum.rktl” test suite. I think it would be better to have core functions to report this information, though.

(define 64-bit? (= (system-type 'word) 64)) (define (fixnum-width) (if (eq? 'racket (system-type 'vm)) (if 64-bit? 63 31) (if 64-bit? 61 30))) (define (least-fixnum) (- (expt 2 (sub1 (fixnum-width))))) (define (greatest-fixnum) (sub1 (expt 2 (sub1 (fixnum-width)))))


yfangzhe
2021-6-14 16:42:25

Aha, I’m also working on a “Racket version of Processing”! But I want to make those programs more in the Racket’s idioms instead of the Processing’s.


soegaard2
2021-6-14 16:43:57

Great minds think alike :slightly_smiling_face:


soegaard2
2021-6-14 16:44:58

Well, I guess including ++ is more about being “feature complete”, rather than expecting it to be used.


soegaard2
2021-6-14 16:48:31

I got inspired by the Coding Train videos by Daniel Schiffman. Have you seen some of them?


soegaard2
2021-6-14 18:49:31

Is there a standard round function in Racket? (One that doesn’t round to even).


soegaard2
2021-6-14 18:55:27

A round-up would be a good thing - as far as I can tell, in most other languages round refers to round to nearest integer and round up on ties.


yfangzhe
2021-6-14 19:22:19

Seen a lot years before. They are my creative coding 101.


joel
2021-6-14 20:00:26

Late response — thanks! Doing this as a full-on parser might actually be the way to go.