3 ms·
Anywhere you see "C/C++", treated as if a single language, you know that you will be not getting good information. It is common to claim "almost as fast as C",
by ncmncm 5y ago
Anywhere you see "C/C++", treated as if a single language, you know that you will be not getting good information. It is common to claim "almost as fast as C", when it is known that C is now a low bar. For speed, nowadays, you use C++. (Or Rust, for identical reasons.)
The most characteristic quality of any publication about the performance of Lisp, as for anything like it, is exaggeration. In particular, indirect costs of garbage collection are invariably concealed.
- User23 5y agoGarbage collection is not part of the Common Lisp standard. DISASSEMBLE is magic and practically speaking it’s easier to write machine language performant code in CL than any other language. Yes of course you can look at =as= output in your favored language, but it drops you out of your flow.
- ludston 5y ago> Garbage collection is not part of the Common Lisp standard. Every important implementation of Common Lisp (Allegro, LispWorks, SBCL, CCL, ABCL, ECL, CLisp and Clasp to name a few) all have garbage collection.
- User23 5y agoSure, but the standard doesn't say anything about it, leaving implementers rather a lot of freedom. LispWorks even claims to have a real-time GC![1] [1] http://www.lispworks.com/products/myths_and_legends.html http://www.lispworks.com/products/myths_and_legends.html
- Jach 5y agoI agree that "C/C++" isn't a good sign, though it was more forgivable when C++ just meant C++98... For speed, nowadays, you use X. That is, many languages can be fast, especially if they have access to intrinsics, the real question is how much special knowledge and herculean effort do you have to spend? It's still true that for many problems idiomatic modern C++ will give a very nice result that may be hard to beat (though be careful if you forgot cin.sync_with_stdio(false) or you may be slower than Python!). But it's also true that C, Rust, Java, Common Lisp, and even JS all do very well out of the box these days, while languages like Python and Ruby have lagged. For this problem, the author had to spend quite a bit of effort in a followup post to get Rust to match some 20 year old unoptimized CL. If one wanted to optimize Lisp, a simple place to start is with some type declarations, at least with the SBCL implementation. It can even be kind of fun to have the compiler yell at you because e.g. it couldn't infer a type somewhere and was forced to do a generic add, so you tell it some things are fixnums, see the message go away, and verify if you want with DISASSEMBLE that it's now using LEA instead of a CALL. For an example of going to quite a bit of trouble (relatively) with adding inline hints, removing unneeded array bounds checks, and SIMD instructions, see https://github.com/telekons/42nd-at-threadmill https://github.com/telekons/42nd-at-threadmill which I believe is quite a bit faster than a similar "blazing fast" Rust project featured on HN not long ago. But my point again isn't so much that CL is the fastest or has some fast projects, just that it can be made as fast as you're probably going to want. This applies to a lot of other languages too, though CL still feels pretty unique in supporting both high level and low level constructs. Your GC comment is weird, since any publications looking at total performance invariable include the GC overhead, nothing is hidden. The TIME macro for micro-benchmarking even typically reports on allocated memory, which can be a proxy for estimating GC pressure, and both SBCL and CCL report the actual time (if any) spent in GC. Why not complain that C++ benchmarks hide the indirect costs of memory fragmentation, which is a real bane for long-running C++ programs like application servers? But I'll admit that the GC can be a big weakness and it's no fun to be forced to code around its limitations, and historically some GCs used by some Lisps were really bad (that is, huge pause times). I've been looking at the herculean GC work being done in the Java ecosystem for years with a jealous eye, and even the newer Nim with its swappable GCs when you want to make certain tradeoffs without having to code them in.