(no title)
xEnOnn | 3 years ago
Coming from a NodeJS background, Rust looks a tad more complicated but it looks cooler. There are also more job listings looking for Golang than Rust which makes me wonder if Golang might be a more rewarding investment?
What would be a good use case of Rust than Golang cannot do given its extra complexity and potentially lesser monetary reward? Any advice on which I should pick as a new language to learn?
cryptos|3 years ago
So, depending on your goals, I think Rust is the better language in general. But if your goal is to get something done fast, then Go would probably be better, since it doesn't require that much learning effort.
mmarq|3 years ago
You forgot pointers used to represent nullables.
lpapez|3 years ago
Go was never ever intended for this purpose.
nailer|3 years ago
Can you explain? What do I set ‘score’ to when someone hasn’t sat the test yet?
indiv0|3 years ago
Meanwhile my experience with Go has been the reverse. I’ve found it acceptable for most use cases, but for network services it really stands out. Goroutines <3
Animats|3 years ago
Goroutines don't have the restrictions of async that you must never block or spend too much time computing. Goroutines are preemptable. The language has memory-safe concurrency (except for maps, which is weird) and has garbage collection. So you can have parallelism without worrying too much about race conditions or leaks.
Go comes with very solid libraries for most server-side web things, because they're libraries Google uses internally. Rust crates have the usual open source problem - they get to 95%-99% debugged, but the unusual cases may not work right. Go has actual paid QA people.
Go has limited aims. It was created so that Google could write their internal server side stuff in something safer than C++ and faster than Python. It has a limited feature set. It's a practical tool.
I write hard stuff (a multi-thread metaverse viewer) in Rust, and easy web stuff (a data logger which updates a database) in Go. Use the right tool for the job.
baby|3 years ago
unknown|3 years ago
[deleted]
cultofmetatron|3 years ago
thats hilarious, my daily driver language is elixir which is the goat for network services. I saw rust as the perfect compliment for that where I need everything else.
tofuahdude|3 years ago
Cthulhu_|3 years ago
That said, Go isn't a very "convenient" language; there's not as much magic or magic libraries that come with the language that take over big chunks of your application, and the community at large actually recommends against using libraries in favor of just using the standard library.
And after a while, I... kind of agree? My HTTP API is gorilla/mux, which is only a thin layer over the standard library's HTTP server APIs (it adds routing / path matching). I started using Ent to abstract away my database, then switched to Gorm when I got annoyed at having to write so much code just to do inserts / updates and manually having to add / remove rows, but that one falls apart as soon as you have a data structure that maps to more than one level of tables deep.
I mean part of my troubles with databases is probably a disconnect between wanting to store items like whole documents but mapping them onto a relational database.
bbkane|3 years ago
philosopher1234|3 years ago
mihaigalos|3 years ago
Golang
* Development speed: Golang wins by far. It's closer to Python in that regard, but with strong typing.
* Very nice multi-threading via Go routines and channels. Impressive semantics in simple syntax, requiring no synchronization mechanism on the user side.
* Large garbage collector penalty.
Rust
* Complete language with build system, crate, docs hosting.
* A lot more performance compared to Golang, on par with C++.
* Doctests (!).
* Slow to learn, slow to compile (probably not a deal-breaker, especially if you focus on microservices).
Concerning what would be a good usecase for Rust vs Golang, check this out:
https://discord.com/blog/why-discord-is-switching-from-go-to...
masklinn|3 years ago
Except for all the times they are required and Go doesn’t tell you: https://eng.uber.com/data-race-patterns-in-go/
Go’s fundamental semantics are standard not-safe shared-memory multi threading. It provides an mpmc queue as a built-in out of necessity (since no generics originally, which would have made for an awkward situation), but really the only thing that’s notable about it is `select`, not `go` or `chan`.
In in some ways `go` is even a downgrade from other languages: you can’t get a handle on the goroutine and thus have to muck around with side-channels to even know that a subroutine has terminated let alone get its result.
rob74|3 years ago
* Go also includes the complete build system, package management (although it wasn't there from the beginning), code documentation, testing and fuzzing. Also the standard library is much more extensive than in Rust ("batteries included").
* Doctests: since you mention them explicitly, Go has those too: https://go.dev/blog/examples
* "Large garbage collector penalty": that obviously depends on your application and what you consider acceptable. I would say that in most cases the easier development enabled by having GC is worth it, but YMMV. Here's a discussion on the Go garbage collector: https://news.ycombinator.com/item?id=12042302
Jyaif|3 years ago
In my experience it's the slowest language to compile ever, and the binaries generated are gargantuan.
I was super excited to learn Rust, but that excitement is now 100% gone.
tofuahdude|3 years ago
olalonde|3 years ago
So I went with Rust and am very happy with the decision. Despite being a systems programming language, it feels surprisingly like a high-level language and I now default to programming stuff in Rust unless there's a strong reason to use NodeJS.
PS: That said, an often understated benefit of Go is that the community and job opportunities are massive in comparison to Rust (for now, at least).
collaborative|3 years ago
Rust is a better c++. It's not appropriate for anything you wouldn't program in c++. The coding speed is slow
So if you are thinking about learning a new language to program your future apps you currently code in node, choose Go
Jyaif|3 years ago
The Rust language is a far better C++.
In practice, the compile time and binary size of Rust are out of control, which makes Rust far from being a slam dunk over C++. Crossing my fingers this will change!
bbojan|3 years ago
With Rust, you could use it to replace the most time critical parts of your high-level program piece by piece. The learning curve is then much easier, and adoption can be gradual.
prirun|3 years ago
Never done it myself, but:
https://www.ardanlabs.com/blog/2020/07/extending-python-with...
https://github.com/go-python/gopy
int_19h|3 years ago
http://pythonnet.github.io/
(Note that this is not a reimplementation of Python on top of CLR, but rather a bridge between CLR and CPython.)
The thing that makes FFI problematic in Go is green threads, which have their own stacks that nothing but Go understands. Thus, every FFI call has to arrange things to be what the callee expects, and you can't do async using goroutines across language boundaries (whereas callback-based solutions like promises work jsut fine).
ActorNightly|3 years ago
Just like learning Haskel is a good exercise in understanding functional programming and lazy evaluation, which again will translate very well to the code you write as you will be able to identify pattens where functional programming can be applied.
However, neither language is really super applicable to general development, because there are hoops you have to jump through to write basic code where the language advantages are not really need, and other languages are much simpler and faster to develop in.
Golang is much more widely used for this reason, as its compiled yet features a gc, simpler to develop in with java contains a lot of good functionality in its stdlib.
zozbot234|3 years ago
mprovost|3 years ago
https://rftgu.rs/
vladvasiliu|3 years ago
I've learned Rust after having used Python, and at first I had a few "wtf" moments, things I just couldn't understand.
Everything fell into place after discussing these with a friend who knows much more about the "nitty-gritty" than I do.
olalonde|3 years ago
doctor_eval|3 years ago
I haven’t learned Rust yet, thought I’m quite keen to do so, but I have an (ancient) background in C, C++ and 8-bit assembly. I don’t find that I really use much of that knowledge when I work in Go, even though Go is still a lot closer to the metal than Node.
pizza234|3 years ago
Anything where low-level control is required. It's not clear if there are true-Rust web apps in the wild (as opposed to web apps with some services in Rust); as far as I read, Rust web programming is ugly.
The market still offers few positions, largely dominated by crypto. I have the impression that it will still take many years before the field will move to Rust (where appropriate).
> Any advice on which I should pick as a new language to learn?
Depends on the concrete goals. If you want to make a career, Golang is the safe bet, by a very long stretch. If you want to have fun, try both, and you'll naturally find your inclination, as they have a radically different flavor.
kouteiheika|3 years ago
There are. I run one. Written in pure Rust. 160k lines of Rust code in total, serving over 3 million HTTP requests per month. Best choice I've ever made.
Rust especially shines when you need to maintain a big project over a long period of time. People often say that Go is much more productive than Rust, and in most cases that is true, but as the size of your project increases and your expertise in the language increases this relationship inverts, and Rust starts to be much more productive. Pick a right tool for the job.
risyachka|3 years ago
Unless you need those extra nanoseconds of performance or super low-level features, Go will be a much better choice.
In the end, they are just tools, and you need to choose them based on your needs, not language features.
greenmana|3 years ago
spicysugar|3 years ago
In the long run Rust's complexity will hurt newcomers(new to programming) while it will be a blessing for seasoned c and c++ devs. If all programming languages were tools, rust would be a very very specific tool which makes a lot of sense for a specific case. If nodejs and golang are tools, choosing one over another is easier as you can do same things in both easily with small effort. But you cannot rewrite all rust programs in nodejs or golang.
Finally you need to ask if rust is really worth picking over golang/nodejs for things that can be easily done in nodejs/golang. Rust is not for people who think is rust for them.
Arguments like some implementations are more elegant in some other language can always be brought up as arguments. They should only be taken into account when you run out of options to compare because they are exaggerated and subjective most of the times. For example(exaggerated) screaming why go doesn't have a borrower checker like rust makes no sense because go is garbage collected. For many people seeing such absence of features equate to lack of features in a programming language leading to more boilerplate or other downsides which is not necessarily true.
snoopy_telex|3 years ago
That said, I feel that Rust is likely the winner long term. So I'm still building my rust skills, but programming personal stuff in go.
vram22|3 years ago
Interesting; why do you think so?
usrusr|3 years ago
At first glance this looks as if Rust would be more at home with polyglotism, but the typical Rust complement would be a hot performance critical part of something much bigger, and this is already deep in the realm of strategical commitment (all the not so hot parts have to buy in). Whereas Go often enters the picture in isolated one-shots and can grow from there.
kif|3 years ago
I learned Go by reading The Go Programming Language. It's a bit old, but a very good book nonetheless.
oconnor663|3 years ago
metadat|3 years ago
mmgutz|3 years ago
ChrisRR|3 years ago
I see Rust as more for people in systems programming who want improvements over C, rather than a desktop developer looking to learn something new. There's a lot of hurdles that you only really appreciate if you've come from an unsafe/low-level background
Fiahil|3 years ago
Here, Rust has officially climbed past NodeJS on the "cool" ladder. Let's rejoice, and welcome our fellow programmers into our communities !
woile|3 years ago
And spite of some other comments, I found writing web servers in rust okay, and I think go is also fine for web services. And with go it also feels a bit like python when using other libraries, I don't know where to start. While rust with cargo is more similar to the npm experience
xEnOnn|3 years ago
One of the reasons I started thinking which language to pick is when I started diving into web3 development. It seems like there is a trend into either using Go or Rust or both in some of the ecosystems. Think Tendermint, Cosmwasm, Solana, etc. While it makes sense to just learn both languages, I don’t think I have the mental capacity to learn both together quickly. It might work better to learn the one that has the most potential in the long run based on the trend.
anon291|3 years ago
azeirah|3 years ago
Philip-J-Fry|3 years ago
TinyGo is an LLVM based compiler that targets microcontrollers but also has a WASM target and that creates considerably smaller binaries, but it doesn't fully support all of the Go standard library.
rob74|3 years ago
masklinn|3 years ago
prerok|3 years ago
Never tried it, though :)
gwbas1c|3 years ago
Beyond things like borrow-checking; the language introduces a LOT of concepts that are quite foreign. Exposing yourself to them is good; because I expect that future languages will borrow heavily from Rust.
cultofmetatron|3 years ago
Go is a great language for the short term but I don't feel like it brings Anything unique or interesting to the profession. its only real advantage is that its quick to learn but there isn't much substance. Its a great language if you're the type of person who doesn't mind copying large reams of code to change a few lines for a new purpose.
shiomiru|3 years ago
unknown|3 years ago
[deleted]
devnull3|3 years ago
If you can afford GC in your project go for Golang else Rust.
nbittich|3 years ago
For example, generics in Go were criticized by some, praised by others.
You have the feeling that you can freely share your opinion in the go community without the risk of being harassed by the rest of the community.
In the rust community, just like a sect, everybody must say that everything is just perfect.
Passive / aggressive attitude is something I've seen a lot in the rust community.
I would suggest that if your plan is to learn C/C++ next, and you never really understood memory issues && pointers, then rust is a perfect choice at first.
I'm planning to learn Go next, I don't regret learning rust, I learned lots of things with it.
tlamponi|3 years ago
That's just not true.
Rust got already adopted by lot of either big or interesting to work at players (Amazon, Microsoft, DropBox, ...?) and, while anecdotal, I myself get also paid to program rust.
> the community is toxic. > In the rust community, just like a sect, everybody must say that everything is just perfect.
I often get the opposite feeling with all the diverse and lengthy discussions about how to do things, e.g., like getting async stable a few years ago or long blog articles of core contributors that state "we can do a lot better here and there" in public blog posts that get shared on /r/rust and don't get shunned.
vladvasiliu|3 years ago
How so? I've seen the random drama crop up here and there, but it always seemed to mostly be about the "political" side of things, as opposed to the technical development.
What few interactions I've had with library maintainers and the tokio project have always been positive, and the people always seemed helpful.
formerly_proven|3 years ago
The Rust community has been the friendliest PL community I've seen so far.
gary17the|3 years ago
As of today, indeed.com lists 1,500 remote jobs mentioning Rust vs. 4,018 jobs mentioning Golang. That's not so bad. (However, there's no way to tell how many of those listings are Rust-specific as opposed to polyglot job descriptions.)
> Also, the [Rust] community is toxic.
Speaking slightly humorously, if you think Rust community is toxic, try expressing your dissatisfaction with Swift or Apple in the fanboi Swift community (controlled by Apple employees) and see what happens to you :).
boris|3 years ago
I think "somewhat dogmatic" would be a more accurate description of the Rust community, IMO.
For example, I recently had a discussion about `enum` being a poor choice for what Rust makes it to mean from a C/C++ developer's point of view (which are Rust's main "replacement target" languages). The closest I got someone to agreeing with me is a sentiment along these lines "well, `variant` would may have been a better choice but it's not very familiar to C/C++ developers and, besides, when this decision was made, Rust had a hard limit of 5 characters on keyword length".
whostolemyhat|3 years ago
I've found the complete opposite, Rust communities are the least hostile programming environments I've come across.
There's also a huge amount of irony about saying a community is toxic on this site
anon291|3 years ago