101 points · by simonpure · 3y ago · 58 comments
https://ecraven.github.io/r7rs-benchmarks/
A few years ago Racket switched to using Chez for its implementation. The lead for Racket (Matthew Flatt) seems pretty happy with the new Chez base: he and the team were able to reduce the total amount of code while at the same time improving performance. Here's the experience report from a few years ago:
https://en.m.wikipedia.org/wiki/Larceny_(Scheme_implementati...
Are you trying to make a (crime) racket/larceny pun? From what I've heard, they named it Racket because a racket is an organized group of schemers.
Anyway, would have been nice for the article to link to Chez Scheme's project page, which seems to be this one:
https://github.com/cisco/ChezScheme
Also not clear why should folks use Chez? The article barely covered the why or what successful apps have been written in Chez.
YakiHonne is a Nostr-based decentralized content media protocol, which supports free curation, creation, publishing, and reporting by various media.
https://yakihonne.com/article/naddr1qq2njnfcdpsngu3sdev4wjn3...
I was hoping to find that information on the site itself, I was looking for an about page or similar. Couldn't find it. Hence why it was confusing for a first time user. Or maybe I just missed it.
Apparently Racket Chez will merge into Cisco Chez and all will be well.
[0] https://sbcl.org
It's a cultural oddity how strongly people seem to associate them with interpreted code.
If you want native code from Scheme, using Gambit.
Chez Scheme has a few interesting features that most compilers do not have, for any language:
"A source file can also be precompiled into a stored binary form and automatically recompiled when its dependencies change. Whether compiling on the fly or precompiling, the compiler produces optimized machine code, with some optimization across separately compiled library boundaries. The compiler can also be directed to perform whole-program compilation, which does full cross-library optimization and also reduces a program and the libraries upon which it depends to a single binary."[0]: https://cons.io
It compiles to C, and from that to binary program
Minor Gerbil version as an example. (export main)
(def (fib n) (if (fx<= n 1) n (+ (fib (fx- n 1)) (fib (fx- n 2)))))
(def (main) (display (fib 47)) (newline))
Compiled with gxc -O -exe -o gerbil.fib
Similar results on x86_64
Of course if you want something really fast you let a genius who knows the target system inside and out write some hand-optimized assembly, but for a program that only needs to run once (or that has no direct or indirect connection to an end user) Chez is roughly fast enough.
Meh, my genius works at electro magnetic level. His mum works at the quantum level but she is outside our budget
On carefully-written programs on some domains with full optimization, both Chez and Gambit have been observed to produce object programs that run at speeds comparable to those of their C equivalents. This isn't new. I think it was Guy Steele who observed circa 1970 that some Maclisp programs ran faster than Fortran equivalents.
1) Clojure is secretly a compiled language. A lot of routine errors in Clojure dev are compiler errors.
2) Clojure aims for super-native performance. Immutability in practice gives weird benefits. The obvious example is copying a large object but making a small change. As a native operation in C that is very expensive. In Clojure, the cost is roughly equivalent to the cost of making the small change, because the structure of the big object can be safely reused (everything is immutable, why not?). It enables completely different styles of coding, it is a very practical benefit of Clojure.
Most operations on clojure persistent data structures are an order of magnitude less efficient than they are on the mutable equivalents, excepting a full copy which free due to it being unnecessary.
It's not really clear what you mean by "order of magnitude" here. The notation you're using suggests that you're thinking in terms of asymptotic algorithmic resource requirements, which are most often characterized by polynomial degree; an order of magnitude ("factor of 10") is invisible in those terms.
But a factor of log n, while not invisible, is nearly so. If you're thinking in terms of polynomial degree, a factor of log n is literally an infinitesimal value - it's more than 0, but less than all positive real numbers.
Also, if you care about that then you can use transients (if no one knows you mutated the data structure then it still counts as immutable) or mutable structures - both of which are pretty simple.