I think it would be good if one dabbles a bit with both and pick one which one feels resonance with. That being said probably one need to give a bit longer time for Rust to be comfortable with it.
Ouch, OOP in Go is just asking for a trouble. "Inheritance" by embedding anonymous struct/interface should be rarely used. Playing with a magic dependency injection, reflection mocking often do not leads to anything good too.
> In addition in Go I find the project setup and settings like GOPATH, GOBIN quite confusing.
I guess you work on Linux :) Yeah, it is weird, I am glad they have improved that flow by guessing empty GOPATH will be equal to $USER/go/ directory. GOBIN is actually not needed, only if you have used dep dependency manager, which for many years is deprecated.
Well here I am to deny it. I personally find Go super hard to write anything that is not a few lines of glue code (and in that case I just reach for Node).
Rust made me lazy. It's just so easy to be guided by the compiler and the architecture that emerges naturally is just so beautiful and easy to navigate.
I don't like Rust for its safety guarantees, I just find it pleasurable to write and even better to read. Safety is just a plus.
I'm not saying this is a universal truth though, Rust just fits my mental model. It isn't even a matter of past experience: I code frontend JS for a living (though I've been exposed to all kinds of code throughout the years) and I actually enjoy JS.
I tried really hard to like Go. I just couldn't.
> I tried really hard to like Go. I just couldn't.
I would expect something opposite for most of programmers. Especially, because Rust support in VSCode/JetBrains IDEs was not very good for many years. However, during talks with various people, I have noticed the Go was natural choice for many former Python or Ruby devs, while Node/Java guys had problem with adapting to it.
Personally, when I take a look at the Rust code it feels like some ECMA Script in a compiled world.
Swift's Codable is doing code gen under the hood, so it also has a binary size and compile time cost.
Swift also doesn't scale that well with core size like many other languages do, so your compile time is not easily fixable with large thread ripper style workstations.
Do you have similar issues with golang and rust? At least golang was designed to be compiled fast.
Compile times are definitely a pain point in Rust, but from what I've heard the Rust compiler is pretty good at scaling to multiple cores (my machine only has 2, so personally that doesn't help much).
“Needs” is a bit strong but “may find some things familiar and therefore easier” is a common refrain.
fn foo() -> &str {
&String::from("foo")
}
Does not work. Whereas coming from C or C++, you will appreciate the safety guarantees the borrow checker is giving you.Learning Rust coming from an OO background is also hard, as you have to adapt to the more functional approach of the Rust type system.
As for your example, even C and C++ devs would squint a bit at why that code doesn't compile: you're allocating a string on the heap, so why can't you return a pointer to it? Also, I think str vs. String is usually confusing at first, regardless of your background.
I would say that the relationship between str and String was what most surprised me. I at first assumed the underlying primitive would be String since str is what you get when you borrow from a String, but it isn't. str is a built-in, whereas String is just a type defined in the (optional, this is a systems language) standard library.
If your environment can't afford memory allocation, you can't have Strings but you can use str just fine, that's a built-in. Since you lack allocators obviously you won't be going around minting new strings but str is perfectly fine for stuff like substring operations or comparisons.
Yes, of course. Rust has some new concepts that will be confusing at first, regardless of your background. You still have to understand Rust's destructors to understand that example. I didn't mean to say that it is impossible for Rubyists to learn Rust, or that C++ devs would understand Rust immediately.
Perhaps a better example:
fn foo() -> &usize {
let x = 50;
&x
}
You don’t need to know much more than Python/Ruby to get something done in Go, whereas Rust needs a C++ or Scala or Haskell or whatever background.
Rust places too much mental workload on a programmer to make the compiler happy.
The Go compiler is much more human friendly.
Swift is a nice mix of all worlds, IMHO. Would be nice to see that get more server-side use.
At our Scala-centric company, Go gets used a lot more for one off tasks and microservices.
We rebuilt one Go service in Rust just to get familiar with it and no one has written more Rust since.