Rust will start edging out Go once Rust becomes easier than Go to prototype/start projects.
Rust is a great language, but right now I can start a project in Go and have someone else start a project in Go and have something up and working in a week. Rust still takes significantly longer to learn and/or find skilled developers for. Go is up there with Python in terms of "Get something out now".
Rust isn't that difficult to prototype or start projects with? What trouble do you run into? I think the hardest parts to understand are the concepts of borrowing, lifetimes, and ownership, but you don't have to know all the subtleties of that to prototype. A basic understanding is fine to get started with. Just like a developer doesn't have to understand all the subtleties of generics to get started with either, lots of devs don't know what covariant or contravariant means and use generics.
Could you explain to a junior what Box<dyn std::error::Error + Send + Sync + 'static> does and how should a person who is starting to learn Rust come up with something like this?
Second minor example. I have a configuration string like let's say timeout for a certain type of connection. What is the recommended way to have that as a string that is accessible to all functions without fighting with the borrow checker?
In Elixir, I would use @timeout in the module for example. In Rust, I am not sure. Cloning the value to every place it needs it as a workaround.
I get what you're trying to say, but disagree with the examples. If you want to prototype and start a project, you don't care what exactly that box type means. You can use it and things will not break. It's part of that particular boilerplate.
It's like people using `std::string` and not necessarily caring for years what `template<class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>> class basic_string;` means or does.
For the second example: environment variable. Once you need more, you can start researching static cells and use a ready crate for configuration loading / processing. If you want more, googling "rust mutable global configuration" brought me https://stackoverflow.com/questions/27791532/how-do-i-create... which gives a pretty good solution.
>> If you want to prototype and start a project, you don't care what exactly that box type means.
I disagree. The whole point is to get to know a language. What do you how many things can you have in your code that you do not understand? Now you put it in production and it breaks. Who is going to fix it? I do not have a particulary positive experience with Rust on Stackoverflow. As a tech decision maker I put Rust in the risky category because it is hard to understand and many of the language features are implemented in a way that it is not easy to work with. Don't get me wrong, I like what Rust could bring to the table but with this upfront complexity it is not worth it. I know many companies who will be ok to take on Rust and they are ok with the way things are.
Your answer is funny to the second one. From SO:
Non-answer answer
Avoid global state in general. Instead, construct the object somewhere early (perhaps in main), then pass mutable references to that object into the places that need it. This will usually make your code easier to reason about and doesn't require as much bending over backwards.
Why would I pass in a mutable reference when all I need is a global static immutable value? You see this get ugly very quickly. We went with the lazy_static! way, but still. I would rather avoid these things entirely.
A good related question is: what will be the "future" of software development? I would bet that WASM and Rust will become more and more dominant in a 5-10 years timeframe. But it's so hard to come up with an informed opinion, as many developers tend to become "religious" about their language of choice.
Not to mention the learning curve. For junior developers to be productive it takes forever. I can teach F# to a junior in a week, Rust maybe a month. Even for senior devs, it is hard to decipher what is the actual meaning of the code sometimes. There is a lot of noise in Rust that makes it harder to grasp what is happening.
And therefore Rust will never outcompete Go in this regard in as much as Haskell, Ocaml, ... never overtook C. Rust might draw from the better principles and get things right C, C++, D, Go, ... failed to incorporate. But in order to get things done a company has to source developers from a market and consider that developers get replaced by another, taking over.
Even in a globalized developer market a smaller developer force is a risk.
In German we have a saying "to die in beauty" (in Schönheit sterben), does that translate? Your boss wants to get things done in due time and I see Go outcompete Rust in this respect.
I'm aware. The creator occasionally pokes fun at the Rust folks for arguing that Envoy should have been written in Rust. And rightly so--Rust wasn't mature at the time Envoy was written.
If we revisit that now, C++ is the wrong language to start Envoy in today.
Go can handle 100k goroutines (green threads) without a sweat.
This is useful for p2p systems in which you are connected to thousands of peers multiplexing several p2p protocols with each concurrently. You want to be able to switch threads as fast as possible.
The concurrency model is a bit easier to reason about too.
It would be good to see how Rust and others do. Other languages excel at other things (i.e. embedded devices ).
Rust can handle the same thing though the typical model now is using async-await and scheduling tasks on a threadpool. While I won't say its conceptually as simple as go can be, Rust also has channels, mutexes, and other concurrency primitives that allow you to create a similar story. It will also end up being more performant and less work to make correct (typically) due to its small runtime and extensive compile-time checking.
The Discord team wrote an article (or a few), and I think you'd find them very interesting.Specifically about their Go implementation, porting to Rust, and then the decision to use Rust wherever it makes sense as a result.
They're very sensible about it, and advocate using the right tool for the job.
Any language that lacks a simple and stable binary interface ultimately can't be used to build reusable code. If it's not simple, only compiler hackers will be able to work with the objects produced. If it's not stable, compatibility between two binaries isn't guaranteed and people won't even try to integrate existing libraries into their own software.
A big reason why C is still widely used. A library that's written in C can be used in any other language.
Same thing that turned me off. There’d have been lots of cool and useful integrations popping up “for free” all over the place if they’d written it in a good library/integration language. Good language for a daemon, bad language for the reference (so, for anything halfway complicated, usually only) implementation of something intended to become a foundational protocol.
go-ipfs is where the majority of new development happens right now as the desktop/server implementation (compared to js-ipfs=browser & rust-ipfs=IoT) - but if you want to prove that Rust is clearly better/faster _in general_ - have at it: https://github.com/ipfs-rust/rust-ipfs ;)
I think the thing jbenet was selecting for back in 2013 was concurrency support & modularity, and golang is still a decent choice for that. Rust 1.0 didn't happen until 2015 after the go-ipfs alpha was already out - but agree it's made awesome progress since then!
I don't care about performance, exactly, it's just that with (say) a C implementation if you're even halfway popular you'll end up with modules in a dozen languages (wrapping your C lib) and an apache module and a storage backend for a few databases, maybe a Linux kernel module, and so on, in no time, and they'll all be pretty much in sync with what's
JS has a better library-integration story than Go does, since there are so many JS implementations in other languages. Go drags all its runtime threads along with it.
I used to hate JS, but honestly, it made a lot of really smart decisions for dynamic documents. Some decisions weren’t great, but somehow they didn’t go as far wrong as C++ managed to in the same era…
Rust needs to start edging out Go for new tools. Kubernetes, Envoy, IPFS, etc. would have benefitted from it.
It might not have been time four years ago, but it's time now.