Re:Chicken Scheme
by rosetremiere on Friday September 03, 2021 @04:42AM
(#28401804)
Would having (optional) type annotation, or even a relatively coercitive type system help much in the way of performance?
Admittedly, this wouldn't be scheme anymore, but are there example of this done in the wild with profitable impact? E.g. even as an extension to RXRS.
I'd guess if you're sure your `fib` function handles only integers, you should get a lot of easy inlining/specialization at your disposition.
Re:Chicken Scheme
by arc-in-space on Friday September 03, 2021 @05:09AM
(#28401968)
It helps. Chicken seems to support exactly that: https://wiki.call-cc.org/man/5/Types
Chez instead provides typed/unchecked arithmetic functions, like fx+, flround and so on. In my experience, those sometimes make a big impact on performance(though realistically in some of those cases it would be better to ask C to do it for you).
Racket similarly makes it possible to do either.
I would say the reason it beats Chicken and Gambit is that it has a Scheme-specific compiler to machine code that has been worked on for a long time with performance in mind.
Dybvig's talk on Macro Writers' Bill of Rights explains some of the optimizations Chez does: https://www.youtube.com/watch?v=LIEX3tUliHw (Why macro writers? Because the compiler will handle superfluous generated code so macros doesn't have to)
See also The Development of Chez Scheme for the history of it: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72....