6 ms·
Chez Scheme: Lisp with native code speed
- SomeoneFromCA 3y agoChez if fast, but certainly not native fast.
- tmtvl 3y agoIt does pretty well considering the obstacles holding it back, garbage collection and implicit typing are rather hefty lodestones to work around, but Chez has a quite sophisticated compiler which can do some impressive optimizations. Of course certain Common Lisp implementations like SBCL still outshine Chez, but for a Scheme implementation it's rather impressive. 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.
- medo-bear 3y ago> 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 Meh, my genius works at electro magnetic level. His mum works at the quantum level but she is outside our budget
- vincent-manis 3y agoNeither is Java. 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.
- moomin 3y agoIIRC, Idris 2 uses Chez Scheme for its backend.
- threatofrain 3y agoAlso Racket.
- bPspGiJT8Y 3y agoThere's also a Chez backend in development for PureScript.
- packetlost 3y agoAnother "post-modern" natively compiling Scheme is Gerbil Scheme [0]. It's seeing a lot of attention/enhancements lately, including some bounties to implement features. [0]: https://cons.io https://cons.io
- codetrotter 3y agoAnd chicken scheme https://www.call-cc.org/ https://www.call-cc.org/ It compiles to C, and from that to binary program
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- matrix12 3y agoAnd is faster than SBCL.
- schemescape 3y agoSource? (A quick search turned up nothing for me)
- matrix12 3y agohttps://github.com/drujensen/fib https://github.com/drujensen/fib sbcl on my mac m1 gets 21s Gerbil gets 16s 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
- phoe-krk 3y agoTangential: if we're talking Lisp and native code speed, Steel Bank Common Lisp (by default) compiles everything to machine code. [0] https://sbcl.org https://sbcl.org
- ska 3y agoCompiled lisps have been a thing for nearly as long as lisps have. IIRC the first one was in early 1960s. It's a cultural oddity how strongly people seem to associate them with interpreted code.
- Zambyte 3y agoI think it's because people (rightfully) associate interactive programming with Lisp, and (wrongfully) associate interpreting with interactive programing, since loading compiled machine code into a running program is foreign to most people who do not use Lisp.
- sitkack 3y ago(not (eq? 'lisp 'scheme)) If you want native code from Scheme, using Gambit.
- JasonFruit 3y agoFrom the title: "Lisp with native code speed".
- uxcolumbo 3y agoWhat is yakihonne? Another blogging platform? Rather confusing to use. 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 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.
- binarycrusader 3y agoI found this (not an endorsement, I have no affiliation, and I don't use it): YakiHonne is a Nostr-based decentralized content media protocol, which supports free curation, creation, publishing, and reporting by various media. https://yakihonne.com/article/naddr1qq2njnfcdpsngu3sdev4wjn30fnys3mh244xxq3qheel7zfyzkknjs47cdnxd5avzjhsngy0mdkgq92cwq8g3jznn0hqxpqqqp65ws70x5q https://yakihonne.com/article/naddr1qq2njnfcdpsngu3sdev4wjn3...
- uxcolumbo 3y agoThanks - worthwhile features for sure and being decentralized. 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.
- no_wizard 3y agoI've always been interested in how Cisco uses ChezScheme. What does it power for them that they are willing to put money into this project?
- kristianp 3y agoIt may have been an acquihire of R. Kent Dybvig. I always wondered what he worked on there.
- ashton314 3y agoHere are the results of running several Scheme implementations on a set of common benchmarks: https://ecraven.github.io/r7rs-benchmarks/ 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://users.cs.utah.edu/~mflatt/tmp/rkt-on-chez.pdf https://users.cs.utah.edu/~mflatt/tmp/rkt-on-chez.pdf
- hedgehog0 3y agomflatt FTW!
- jojohohanon 3y agoI always assumed racket was built on twobit/larceny. https://en.m.wikipedia.org/wiki/Larceny_(Scheme_implementation) https://en.m.wikipedia.org/wiki/Larceny_(Scheme_implementati...
- ashton314 3y agoIt never was. 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.
- jojohohanon 3y agoNo I’m referencing the fact that both had pretty strong teams overlapping in Northeastern University.
- clircle 3y agoPretty sure emacs lisp compiles to native code now
- binary132 3y agoIt uses gccjit
- roenxi 3y agoIf we're mentioning Clojure: 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.
- ludston 3y agoTo drill down into this, adding or removing from a vector or hashset in clojure is O(logn). This also means that random access is also O(logn). 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.
- freshhawk 3y agoUseful to specify that it is log32N, not log2N since that makes an enormous different in practice. 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.
- thaumasiotes 3y ago> Most operations on clojure persistent data structures are an order of magnitude less efficient than they are on the mutable equivalents 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.
- sitkack 3y agoThere are two Houses of Chez, the one from Cisco and the one in Racket. Racket has additional backends for RISC-V and Arm64. Apparently Racket Chez will merge into Cisco Chez and all will be well.
- mnming 3y agoI am under the impression that Racket using Chez to implement the interpreter instead of compiler. Is this the case?
- bmitc 3y agoThere's a few blog posts you can search for by Matthew Flatt that explain a lot of detail. As far as I know, Racket has their own fork of Chez Scheme.
- soegaard 3y agoNo, everything is compiled.
- mnming 3y agoHmm, when I search racket compilation, the top option is to compile to bytecode. Since the term "bytecode" is used, I thought that was different from Chez's machine code generation?
- gmatejka 3y agoWhen I was creating https://github.com/GrantMatejka/rasm https://github.com/GrantMatejka/rasm I initially wanted to add a Wasm target to the Chez Scheme backend for Racket. Ultimately didn’t work out, but the paper goes over the process a bit
- paines 3y agoWhy is R6RS Compliance labled as a core feature while elsewhere (e.g. Sketchy Scheme) labels R6RS as the death of Scheme?