You're Allowed to Write Slow Rust Code
blog.jonstodle.com
blog.jonstodle.com
I've ran into situations when displaying text on the screen was lagging - and that in several different programs, on various (modern) computers. Not saying GC was a problem there, but I guess this has something to do with the generally accepted culture of "only 2% of programs need high performance".
There is difference between GC overhead, VM overhead, interpreter overhead, and programmer not understanding basic concepts and doing stupid shit.
Go is GC language and tools written in Go often approach C/C++ speeds, despite lacking an optimizer like LLVM and lack of some performance oriented features. Another example is OCaml.
As you said, it's usually not a GC issue. Many of these ridiculously slow programs you talk about are written in C++.
Summarising - using a GCed language instead of dropping a few occasional clone calls in the code is bad advice, unless the program is really a one-off fire and forget thing (but these are not 98% of software).
However I agree the idea only a few software need to run fast is bullcrap.
The considerations can be very complex though, e.g. what's the effort required for reaching this performance profile? is it consistent across all the types of project? etc.etc.
It is often easier to get decent performance in tiny projects or micro-benchmarks, simply because you can spend so much more time on optimization vs all other tasks. That's probably why I often see Java benchmarks claiming close-to-C performance (only ~2x slower) levels, but I fail to see it in real big applications.
If the hard deadlines are still met, it doesn't matter that another solution is 50% faster when it takes 150% more money to develop and doesn't bring anything to the table (hard deadlines were accomplished).
This is what people keep forgetting when arguing my language is faster than yours.
What I care is about project costs, meeting deadlines and acceptance criteria.
Are you sure you're on the right website? :D
First, programs coded in Rust are typically nowhere near 50% faster than the ones coded in managed languages - I observe 500% to 5000% differences. And it is not just faster but also uses an order of magnitude less memory. In cloud based software this translates to savings on TCO users of the software I write do care about.
Second, as for 150% more development cost - this is also not my experience. There is some upfront cost related to learning a new language, but then later this pays off on maintenance and bug finding (lack of data races or relying on fragile runtime reflection are big ones). Plus Rust is more expressive than Java/C#/Go and many common programming problems are actually surprisingly faster to code. E.g serialization / deserialization of object graphs.
Java is too extreme with GC, not all languages are like that. In .NET it's only moderately hard to avoid GC when you want to. It has value types, real stack, and other relevant features. Here's an example of non-trivial code written in that style for performance reasons: https://github.com/Const-me/Vrmac/tree/master/VrmacVideo
2 - Those languages offer C++ like features for memory management if one bothers to actually learn to use them
3 - Java is also getting them via projects Panama and Valhalla
So it is more a matter to actually bother to learn the tools one has at their disposition.
2 - Not really. The fact they allow to allocate/deallocate manually is not enough. Dealing with non-GCed memory in Java or C# is much more error-prone and less ergonomic than even in C++. E.g. no automatic reference counting nor RAII.
3 - It is 5 years in development now and as far as the specs goes value types will be limited to immutable objects only, so it is inefficient by design and it solves only half of the problem. Similarly high hopes were associated with escape analysis which turned out to be totally ineffective.
2 - automatic reference counting is slower than tracing GC. Strange to prefer something with less performance. RAII is possible in C# via IDispose (alongside Roslyn compiler errors for not using it properly) and FP patterns similar to -with in Common Lisp.
3 - It is a major engineering feat to design a feature that will work out of the box with 25 years old compiled jars without playing a Python 2 in the Java world. Naturally it takes its time to get right. Just like it took 10 years to get modules and concepts and they are still not available across all major C++ compilers. Good engineering takes time.
2 - I've seen this repeated on the Internet many times, but there is little scientific evidence, and the one available is quite contradictory. I recall a paper where authors argued that replacing the old-gen collector with reference counting actually improved performance. So this is definitely not universally true, and depends on many factors such as imposed constraints on memory overhead and usage patterns. It is easy to make GC good when you only create short-lived objects and allow it to use 10x more memory than needed. But things get pretty hairy when you also want low-pauses and low memory overhead and objects live longer (e.g. cache-like use cases). Also the number of reference counted objects in C++/Rust programs is typically orders of magnitude lower than the number of GCed objects in GCed languages, so even if ref-counting was less efficient per-object lifetime, it is not globally less efficient.
3 - Agree, but "value types" have been present in C/C++/Rust/Swift/D/C# and dozens of other languages for ages, so, unless you're forced to work on a legacy Java project, why wait? You can become productive in Rust in less time than they will be able to ship Valhalla.
2 - Really? Here is one to start with, https://github.com/ixy-languages/ixy-languages. Enjoy the RC high performance from Swift. Additional SIGPLAN and ACM papers can be provided. The fact is that when RC gets fine tuned for performance, it is a tracing GC in disguise, with its background threads for deferred releases, like C++/WinRT is currently doing with COM/UWP.
3 - It takes some time to catch up with 25 years of libraries, OS and IDE support
3 - Mature doesn't mean all of it is always better. Take Cargo vs Maven/Gradle. Or libraries for async programming. Also not everything needs to be written from scratch.
The point of my link was about Swift RC performance, Rust and C aren't using it.
Yeah, but they'll ship Valhalla before you rewrite your existing 4M LOC Java application.
https://ruudvanasseldonk.com/2015/10/06/neither-necessary-no...
Ownership model seems hard for people to internalize, but once learned feels very natural, leads to programs that are better structured and frees programmer from "manually managing resources".
Other than Python's `with` and alikes, wrapping in a closure, `defer`/`scope` (Go/D), what else is there? What am I missing? None of these work if the lifetime of a resource is not a simple "this scope".
Idris2 and now Haskell have linear types.
But it's a good advice. For some reason people tend to forget that copying stuff is super cheap, and most lifetime issues can be entirely avoided with a `.clone()`.
I remember years ago coming across a highly optimised md5 calculation function in a legacy codebase that I inherited. Much care have been put into writing it, with comments highlighting how many clock cycles on an Athlon processor were required to run it. This was clever stuff, but the firm wasn't using Athlon processors, and hadn't for years. A quick comparison with boost showed that boost was faster (on the processors of the time), so it got chopped out.
The more you use one tech (especially out of the usual zone) the more you learn. And maybe you learn to avoid that language.
Also I like being able to come back and pick up small tools in my 'main' languages without rewriting them. So for me it's java for GUIs or highly dynamic runtime-y stuff (introspection, code gen, AOP) or 'throwable' stuff, and Ada for 'serious real-time must run 2 years without crash' stuff.
Too many times I end up maintaining python scripts that have overgrown the 'script' phase and are full fledged business-critical tools and... It's then often too late to back off.
All there is just bunch of subjective experiences in specific circumstances.