17 ms·
How I went about learning Rust
- yakorevivan 4y ago
- xEnOnn 4y agoI have been thinking to myself whether I should pick up Go or Rust as a new language this year. 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?
- shiomiru 4y agoThere was a relevant discussion here just a little while ago: https://news.ycombinator.com/item?id=31976407 https://news.ycombinator.com/item?id=31976407
- azeirah 4y agoJust thinking out loud, does go compile to WASM? I often see performance critical WASM snippets written in rust, but never in Go.
- rob74 4y agoYes it does, but there are some issues, mainly the size of the compiled WASM file. But you can get around that by using TinyGo. I'm not that deep into it, but this article seems to give a good (and as far as I can see up to date) overview: https://elewis.dev/are-we-wasm-yet-part-1 https://elewis.dev/are-we-wasm-yet-part-1
- Philip-J-Fry 4y agoGo compiles to WASM but the stock compiler is pretty bad for this and your binaries are like 2MB+ in size. 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.
- doctor_eval 4y agoTinyGo is great, I used to to program microcontrollers and there wasn’t anything I really missed, though admittedly it was a very small program.
- masklinn 4y agoGo does compile to wasm, however because wasm is what it is it has to carry around the entire runtime. This is obviously a much bigger issue for delivery over the web than it is for shuffling binaries around, or even more so creating them locally: last I’d checked, the baseline (an empty main function) for a go wasm package is about 1.3M.
- pjmlp 4y agoHardly an issue when looking at the ads crap that get download in every "modern" site.
- masklinn 4y agoSure if your use case for go wasm is ads crap knock yourself out.
- pjmlp 4y agoThat wasn't my point, ads and SPA crap available almost in every "modern" site, are several MB bigger in size than Go runtime on WASM. Ergo a a WASM Go application will be much smaller than those "modern" sites. I bet even smaller than GMail and Google Docs.
- alpaca128 4y agoSure, but I think if you see the size of ad-loaded pages as a size budget or standard for your website you're already on the path towards setting your own bad example.
- yakorevivan 4y ago
- prerok 4y agoSure it can: https://golangbot.com/webassembly-using-go/ https://golangbot.com/webassembly-using-go/ Never tried it, though :)
- devnull3 4y ago> What would be a good use case of Rust than Golang If you can afford GC in your project go for Golang else Rust.
- metadat 4y agoIf you learn Rust and become proficienct, Go will be comparably trivial.
- indiv0 4y agoAs someone with extensive experience with Rust and a teensy bit of experience in Go I can tell you that I adore Rust for every use case I’ve tried it out for *except* for network services. It works ok for low level proxies and stuff like that; but Python/Flask-level easy it is not. 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
- tofuahdude 4y agoCould you please expand on this a bit? What are some example services that would be better written in go vs rust?
- Animats 4y agoYes. Rust is for what you'd otherwise have to write in C++. It's overkill for web services. You have to obsess over who owns what. The compiler will catch memory safety errors, but you still have to resolve them. It's quite possible to paint yourself into a corner and have to go back and redesign something. On the other hand, if you really need to coordinate many CPUs in a complicated way, Rust has decent facilities for that. 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.
- zozbot234 4y ago> You have to obsess over who owns what. Most of the time you can also avoid this by just copying data using .clone(). This adds a tiny bit of overhead, which is why it isn't a default - but it'll still be comparatively very efficient. Similarly, there are facilities for shared mutation (Cell/RefCell) and for multiple owners extending the lifetime of a single piece of data (Rc/Arc). It's not that hard to assess where those might be needed, even in larger programs.
- cryptos 4y agoRust is the more elegant and powerful language. Creating a new language and repeating the "billion dollar mistake" by including null (sailing under the brand name "nil" in Go) is just crazy. Error handling is another strange thing in Go. And generics have been only introduced recently, but there is hardly any support for libraries in it (now). While Go is definitely fast enough for most scenarios, it is not the best language for low level code like drivers or kernel development. 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.
- lpapez 4y agoWhile Go is definitely fast enough for most scenarios, it is not the best language for low level code like drivers or kernel development. Go was never ever intended for this purpose.
- cryptos 4y agoYes, I know (although they promoted it as a "systems language", but it was not really defined what that should mean in the beginning), but it is a restriction, you don't have in Rust. Basically, Rust can do everything Go can do, but not the other way around. That _might_ help to make a decision for a language.
- stavros 4y agoTechnically, assembly can do everything Rust can do, yet that doesn't help to make a decision for a language. Ergonomics matter.
- agumonkey 4y agoIt seems to be an idiom shift. Systems means connected parts, go concurrency does just that, connecting parts through channels. But it's not `systems` as in bare metal electronic chips systems. More like IT `system`.
- mmarq 4y ago
- mihaigalos 4y agoWhat are you looking for in the 2 languages? Here are some of my thoughts: 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-rust https://discord.com/blog/why-discord-is-switching-from-go-to...
- tofuahdude 4y agoHow "large" is the garbage collector penalty? My understanding is that the Go GC is significantly more efficient than for example JS's mark/sweep approach. Apples to oranges for sure, but I am interested in better understanding how expensive the Go GC is vs Rust performance.
- masklinn 4y agoGo’s GC is not efficient, it is responsive. That is, it trades throughput (and performances, and efficiency) for small pauses and concurrency.
- mihaigalos 4y agoCheck out the discord article I posted in the original reply. If I interpret the graphs correctly, I see: Golang: * baseline 20% cpu + spikes to 35% once the GC runs. * response times of about 1ms + spikes up to 10ms. Rust: * baseline 12% cpu + flat, no spiking. * response times of 20us + flat, no spiking (!). In terms of scaling, I interpret the results in favor of Rust. My reasoning is the more you run the GC, the bigger the penalty.
- tofuahdude 4y agoJust read that article; very informative. The TLDR is that, especially during GC, P99s and response times are notably worse in Go than Rust. Makes sense.
- nbittich 4y agoI think rust is the new haskell. After spending 7 months learning it, I can say I really enjoy the language, but there's no job in it and in my opinion, they take academic decisions that make the language way more complex than it should. Also, the community is toxic. 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.
- formerly_proven 4y ago> Also, the community is toxic. The Rust community has been the friendliest PL community I've seen so far.
- nbittich 4y agoJust like in any sect. As long as you agree everything is perfect, the community is the friendliest indeed.
- pkolaczk 4y agoNope, many times I submitted a question, got help instantly with a very long explanation telling why the thing I try to do makes sense and should work, but some things in the compiler or libraries haven't been stabilized or finished yet, and they were working on that. And then giving me some temporary workarounds. The community definitely acknowledges the limitations and sharp edges and listens to the users. Thanks to that attitude, Rust is way more friendly and easier to use than it was 5 years ago.
- Ygg2 4y agoThat's not fair to Rust. I think it's feature of community size and genuine interest/innovation in Rust.
- zozbot234 4y agoSince you're coming from a NodeJS background, you'll want to pick up an introductory textbook about C as well. Rust implicitly relies quite closely on the C machine model, and introductory books about Rust (such as "The Rust Programming Language") don't do a very good job of conveying the nitty-gritty details of that model to novice coders. This is a pretty nasty pitfall when trying to code in Rust, and it's important to address it early.
- vladvasiliu 4y agoI second this. 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.
- doctor_eval 4y agoThis is the main reason I’d recommend that a Node programmer learn Go first. 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.
- mprovost 4y agoI'm self-publishing "Rust From the Ground Up" which takes this approach: each chapter rewrites a classic Unix utility (head, cat, wc, ...) from the original BSD C source into Rust. I find for systems programming it's easier to understand how things work in C, and then teach the idiomatic way of doing it in Rust. C is pretty easy to follow along in "read-only" mode with some explanations. https://rftgu.rs/ https://rftgu.rs/
- cercatrova 4y agoInteresting, seems similar to the book Command Line Rust which also teaches you by reimplementing Unix commands, any thoughts on the differences?
- ActorNightly 4y agoLearning Rust is a good exercise in understanding memory safety. Learning it will make you understand the gotchas of what can go wrong with memory allocation, which will translate very well to coding in other languages, especially C. 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.
- usrusr 4y agoI think Go would typically be considered a possible substitute of one the "more VMy" languages, Rust a complement. 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.
- collaborative 4y agoI founf myself in your same situation a few months ago. I chose Rust and regret it 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 4y ago> Rust is a better c++ 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!
- hyperman1 4y agoI get the sentiment, but like to nuance it a bit. The compile time story of rust and C++ is comparable, if you use it the same way. If you use deep include hierarchies and no precompiled headers, if you start using template heavy code like boost, or if you do code generation, the C++ compile times will quickly spiral out of control. Rust does not have the include problem, but the specialization/templating idea is shared with C++, and the code generation problem has an equivalent in the macro mechanism as used by e.g. serde. In theory, you can get comparable compile times from both. Main difference is rust heavily emphasizes a programming strategy that depends on these 2, and it has a heavy cost in compile time. Meanwhile, a lot of the C++ code is still in the 'C-with-classes-and-every-vendor-creates-a-string-class' camp and while the abstraction level is lower, so is the compile time. For the binary size, C++ can hide a lot of stuff in libraries, while rust compiles it in and duplicates it for each executable. So you pay a higher fixed cost per application. As long as rust has no stable ABI, rust will stay behind at this point. But it gets better optimization opportunities as it can merge the standard library code with yours, and inter library calls are more costly so runs wins there too. Presumably it's early day for a stable ABI in rust, big wins are still made. Long term, I'd personally like to see some ABI stability in the rust world.
- zozbot234 4y ago
- snoopy_telex 4y agoI enjoy writing go a lot more then I enjoy rust. Rust is... dense. It's a lot harder for me to read code and understand what it's doing. 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 4y ago>That said, I feel that Rust is likely the winner long term. Interesting; why do you think so?
- woile 4y agoMost of my experience is with python and js. I feel like if you have experience with python, go resembles a lot. While if you have some experience with js, rust feels like an extension (but takes time to feel comfortable). If you like arrow functions, using map, filter, etc. You will feel amazing when using rust. Those are my 2 cents. 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
- bbojan 4y agoOne drawback of Go (in my opinion) is that it has a runtime. So it's very difficult (impossible) to use it with other languages that also have a runtime. So if you learn Go, you'll never be able to use it to interoperate with e.g. your Python program to speed it up. 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 4y ago> So if you learn Go, you'll never be able to use it to interoperate with e.g. your Python program to speed it up. Never done it myself, but: https://www.ardanlabs.com/blog/2020/07/extending-python-with-go.html https://www.ardanlabs.com/blog/2020/07/extending-python-with... https://github.com/go-python/gopy https://github.com/go-python/gopy
- int_19h 4y agoHaving a runtime does not, by itself, preclude interoperating with other languages that have their own runtime. Here's a project that does that for .NET and Python: http://pythonnet.github.io/ 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).
- olalonde 4y agoI had the same reflexion about 2 years ago. Realistically, pretty much any program written in NodeJS can be ported to Go and vice versa. But not every Rust program can be ported to NodeJS/Go. It opens up a new class of software that is not typically available to NodeJS/Go developers (e.g. systems programming, embedded, writing libraries for other languages, etc.). 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).
- ChrisRR 4y agoIf you're looking for a new language in order to get a job, then I wouldn't be looking for either of these languages and look into something much more common like C++ given your background. 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
- kif 4y agoIf you want to optimize your learning experience, then learn Go first. Rust has a very steep learning curve, whereas you can pick up Go very very quickly. I learned Go by reading The Go Programming Language. It's a bit old, but a very good book nonetheless.
- oconnor663 4y agoI second this. I'm a huge Rust fan, and not really a Go fan, but if you're thinking about leaning both, it will be much faster to learn Go first. Spend a couple weeks on that, and then you'll have another data point to compare while you learn Rust. (Go also distinguishes between pointers and values, which will be a helpful concept to have under your belt when you start Rust.)
- Cthulhu_ 4y agoI have no experience with Rust myself and a good 2-3 years with Go, so my opinion here is biased but: I think Go is more suitable for general all-purpose programming, whereas Rust is more specialized; I'd pick the latter if you need to do high-quality, close-to-the-metal software, and Go for more generic software, taking the same spot that NodeJS did for you. 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 4y agoYou might look into your database's support for JSON columns. Sometimes you can even make indices for expressions on them
- philosopher1234 4y agosqlc is very go-like, i recommend it.
- pizza234 4y ago> What would be a good use case of Rust than Golang cannot do given its extra complexity and potentially lesser monetary reward? 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 4y 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. 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.
- gg2222 4y agoWhat Rust web libraries/frameworks do you use and recommend? How long does your Rust project take to compile?
- memorable 4y agoI'm not the OP, but I liked Warp[0] the most. Actix Web is cool, but looks ugly and hard to use. Rocket doesn't even work. And Tide is lean and clean, but its examples and codes aren't as well-made as Warp. [0]: https://github.com/seanmonstar/warp https://github.com/seanmonstar/warp
- xEnOnn 4y agoI figured I should have given some context to my question on deciding to learn either Rust or Go. 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.
- mmgutz 4y agoFor someone writing node apps, Go is a better fit. Go is much simpler than Typescript and almost performs as well as Rust. The reality is most Rust apps written by average Rust programmers do not noticeably outperform Go apps. Getting Rust to outperform Go requires a high level of proficiency in Rust. The effort vs reward definitely favors Go for node type of apps.
- risyachka 4y agoFor probably 99% of cases, Go will be a better fit as it is noticeably easier to learn and will require less time to do the task. 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 4y agoI'd say it's also a question of team size and organization. Are you a singular developer, or in a large team, writing enterprise software that should be easy to pick up for someone reading the code 10 years later etc.
- Fiahil 4y ago> Coming from a NodeJS background, Rust looks a tad more complicated but it looks cooler. Here, Rust has officially climbed past NodeJS on the "cool" ladder. Let's rejoice, and welcome our fellow programmers into our communities !
- spicysugar 4y agoI personally feel rust is advertised more as safer and faster rather than as a practical yet harder alternative to C or C++. Although Go as a systems programming language is misleading, it's not something that is as heavily discussed about. 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.
- gwbas1c 4y agoI think it's worth spending a few weekends with Rust, even if it's just to expose you to some of the concepts in the language. 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.
- deleted 4y ago[deleted]
- cultofmetatron 4y agoyou'll grow more as a developer from rust. Rust will force you to think about things like memory management, safety etc. additionally, it has a rich set of abstractions. rust also has better interop with c and c++. In the long run, you're better off learning rust. You'll encounter a brutal learning curve but once you know it, you'll find yourself able to do very powerful things with ease. especially once you internalize the borrow checker. 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.
- anon291 4y agoI worked in Haskell for many years. It is an absolute myth that rare languages command less salary. Remember the more popular the language, the more supply, hence less pay.
- eyelidlessness 4y ago“How” is the stupidest word to auto-censor. Removing it completely changes the meaning of titles. It makes articles seem vapid or banal when they wouldn’t otherwise, and vice versa.
- smt88 4y agoIn this case, it changes the title so much that it's not correct English anymore.
- kybernetikos 4y agoIt could suggest a travelling rust learner in the same way that swordsmen in feudal Japan used to perfect their art by travelling around.
- simondebbarma 4y agoAn exclamation at the end would fix this, but yeah, I'm of the opinion that censoring the 'How' didn't distract from the article until I saw this thread.
- jb1991 4y agoIt is correct English without "How" but the meaning is different and the usage is not typical.
- baby 4y ago
- davidatbu 4y agoI just want to give a shout out to "Rust for Rustaceans". I'm only three chapters in, and it's definitely the most enjoyable technical reading I've ever done because you learn so much, so quickly, and so easily. Steve Klabnik (co-author of "The Rust Programming Language") says it's the book to read after going through "The Rust Programming Language", and I couldn't agree more.
- vimwizard 4y agoThe author fairly regularly live streams on youtube doing more advanced Rust programming, and is responsive to questions coming in.
- mindri0t 4y agoTo build on this, his Crust of Rust series videos are excellent deep dives targeted at the same stage of learning as the book.
- wdroz 4y agoI just finished this book. I liked it and learnt a lot, but in some chapters I felt way too far from my comfort zone. The unsafe chapter and some part under the hood of async like Pin/Unpin was difficult for me.
- davidatbu 4y agoThanks for the heads up! This is indeed worth noting. Even in the first three chapters for example, if someone isn't familiar with memory layout in C, or the stack/heap distinction, ..etc, it can seem a bit complicated I think.
- jgilias 4y ago+1 from me here! The book arrived yesterday (yes, I'm a luddite like that), and now I'm at chapter 8. For me, I'm already aware in one way or another of most things in it, but my knowledge is spotty in places, and all over the place too. So, R4R seems really great to put some framework around it, as well as get at least accustomed to the least familiar bits. I would add though that I can see how it can be a pretty challenging read depending on prior experiences. Even then I believe it makes a lot of sense to read through it to at least get exposed to some topics and be able to recall later that you've read something about it when you need it.
- Linda703 4y ago[dead]
- thejosh 4y agoI tried to pick up Rust a few years ago, but there were too many sharp edges. I thought it was a nice language, but was too early for actual use. I played with some libraries (Apache Arrow, etc) and it was nice. About 2 months ago I wanted to use Arrow within Elixir, which required me to start using Rust again (Elixir uses Rustler to safely convert from Rust <> Elixir without theoretically crashing the beam). I am amazed how far it's come, and I've actually been using it a lot over the last few months and haven't ran into any major issues. There is a fair amount of information out there, and the documentation as the OP pointed out is really fantastic. The libraries are really good now, and I've had no issues using it on Linux or on my Macbook M1. Incredibly impressive speed results. SIMD is a game changer. Major shoutouts to arrow2 and Polars, I love using it for data analysis :).
- atoav 4y agoI mean it depends. Many of aspects of Rust that are perceived as sharp edges are in fact the programmer bringing in their preferences and paradigms from other languages and trying to program that way in Rust. I was one of those and tried to do OOP in Rust. It was a pain. At some point I gave up and was like: "Okay Rust, I do it your way, I just want this to work". And it worked flawlessly and easy. I literally had to overcome my ideas of beauty in code to realize how Rust is meant to be programmed in (more data oriented, less object oriented). This was a really good lesson for me, as I had to question similar aesthetically motivated decisions I made in other languages in the past.
- zozbot234 4y agoRust actually supports most OOP features, with the main exception of implementation inheritance. And implementation inheritance is a nasty footgun in large-scale software systems (search around for: "fragile base class problem"), in a way that just doesn't apply to simple composition and pure interfaces (traits). So it's hard to fault Rust for including the latter and not the former.
- hyperman1 4y agoFor me it was the web-of-pointers strategy I had to unlearn. A child object keeping a pointer to its parent is misery in Rust. It forces you to either make the child completely independent or really prove the parent will be around until the child disappears. 90% of the time this is dumb overhead, but 10% of the time it found a bug in some edge case, so I learned to appreciate it as a tough teacher, and my designs got better for it.
- TrackerFF 4y agoA bit unrelated: Maybe I'm wrong, but I get the impression that the people who learn Rust, tend to be quite experienced programmers. I have yet to see complete beginners document their journey, starting with Rust. I've seen lots of people do that with C/C++, Java, and the other usual suspects - but Rust still seems like a language for at least intermediate programmers.
- deleted 4y ago[deleted]
- zozbot234 4y agoIt's a very new language (NLL, a key feature in Rust ergonomics, was introduced in late 2018) and people are yet to figure out how to teach it to complete novices. Existing introductions assume that you do have some programming experience.
- cinericius 4y agoI think you're right but that it's not necessarily a bad thing. Rust's truly killer features probably won't appeal to you on a visceral level until you've been on the wrong end of a thorny problem like a race condition. Otherwise you might think it's a needlessly strict C++ clone.
- deleted 4y ago[deleted]
- pornel 4y agoThere are definitely easier languages to learn for complete beginners. When someone needs to learn what a "string" is, it's not helpful to immediately require them to also learn the difference between a "heap-allocated string" and a "borrowed string". However, you don't need to be an expert to learn Rust. It even helps if you don't have too many expectations about OOP and pointers, because their Rust equivalents have different design patterns/idioms, and you may need to unlearn some things.
- zozbot234 4y ago
- the_cramer 4y agoI am currently starting with rust too. I'm coming from a C#/ASP.NET/Angular/SQL background. I really like the official documentation so far. https://doc.rust-lang.org/book/ch00-00-introduction.html https://doc.rust-lang.org/book/ch00-00-introduction.html I also really like this quick introduction. https://fasterthanli.me/articles/a-half-hour-to-learn-rust https://fasterthanli.me/articles/a-half-hour-to-learn-rust You won't "learn" rust by reading it but you get a pretty good picture of the basics in my opinion. Maybe someone more experienced can rate these as i don't have comparisons yet.
- dcminter 4y agoI liked that fasterthanlime article a lot too. The main thing it gave me was enough context to get enthusiastic enough about the language to sit down and read through the O'Reilly book¹ (which I thought was excellent). I'm still very much a Rust beginner, but I've managed to build a couple of useful tiny projects and to hack a feature I wanted into someone else's big 'ol codebase! ¹https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/ https://www.oreilly.com/library/view/programming-rust-2nd/97...
- asicsp 4y agoSee also https://loige.co/where-to-go-to-learn-rust-in-2021/ https://loige.co/where-to-go-to-learn-rust-in-2021/ (books, video courses, newsletters, podcasts, blogs, workshops, etc)
- teutat3s 4y agoHug of death? https://web.archive.org/web/20220715054007/https://eli.thegreenplace.net/2022/how-i-went-about-learning-rust/ https://web.archive.org/web/20220715054007/https://eli.thegr...
- andrew-jack 4y agoI don't personally have any experience with Rust, but I've been using Go for a good two to three years, so my opinion is biased. However, I believe that Go is better suited for general all-purpose programming, whereas Rust is more focused. I would choose Rust if you need to create high-quality, close-to-the-metal software, and use Go for more generic software, filling the role that NodeJS filled for you.
- agentbellnorm 4y agoI’m on a similar track. Web/java background and started doing some tutorials and aoc, currently working on the the same ray tracer challenge book (it’s awesome). Not sure what a next step would be, maybe that one book where you implement a web browser or some raspberry pi project. Any recommendations?
- Barrera 4y ago> Programming Rust (link to review) is the first book I read for an initial introduction to the language. This book is very much under-rated. If you've unsuccessfuly tried to learn Rust by reading "the Book" cover to cover, you might try reading Programing Rust in the same way.
- jmartin2683 4y agoI love rust. I didn’t find it difficult to learn and at this point several others I’ve introduced it to also haven’t. I’m baffled as to where that reputation comes from. I get that it makes you think about what you’re building a little more than something you can throw together like Python or Ruby but if the end goal is software that works correctly, getting there definitely isn’t harder with rust. It’s the complete opposite :/.
- nkozyra 4y ago> I’m baffled as to where that reputation comes from. It's a deep language with a mix of borrowed syntax(es) and designs. You can pick up Go or Python or Nim in an hour and have a working application, that's fairly unlikely with Rust. I'd say it took me a year to feel comfortable with Rust - to the point where I could just sit down and write applications without Googling every five minutes - which is far longer than I've spent with any other language.
- anon291 4y agoThis is good because no application of any import should be built in a language with which one has faux similarity. A lot of really nasty problems are caused by people thinking they understand what JavaScript is doing.
- arunc 4y ago> I’m baffled as to where that reputation comes from. Aside from the awesome community that rust has, don't underestimate the power of marketing. Someone should ask Mozilla how much was spent for rust development. Sun microsystems spent about $500 million in 2003 to push forward Java. https://www.theregister.com/2003/06/09/sun_preps_500m_java_brand/ https://www.theregister.com/2003/06/09/sun_preps_500m_java_b...
- mcronce 4y agoI use Rust for more or less everything these days, but I found the learning curve to be fairly tough up front. That was in 2019, though; maybe it's easier today with all the improved compiler diagnostics and new books and whatnot. > if the end goal is software that works correctly, getting there definitely isn’t harder with rust. It’s the complete opposite :/. Strongly agree with you here. It takes me a lot less time to put something that functions correctly together with Rust than it does with Python or Go. Maintenance also gets a lot easier as the codebase grows. I recently started a job at a Python shop, and the kinds of bugs/regressions we hit are super annoying because a compiler with a type system would have had them simply be build errors up front.
- synergy20 4y agoas an embedded c/c++ developer I tried Rust briefly a few times over the years, don't feel it's the right fit, due to the way it's static build by default the binary size is just too large, plus the library pool is still much small, and there is no equivalent to c++'s STL for speedy coding when I need it. yes I can trick for size etc, but overall it just did not fit well so far, for the embedded space that is, but, 'system-programming language' has many use cases in embedded field.
- pitaj 4y agoBut that's just the default, you can tell it to use dynamic linking. What libraries were you missing? I find the rust standard library is better in many ways, and it doesn't have the same performance footguns.
- synergy20 4y agoI don't feel Rust has any performance advantage to c and c++ per my own tests. yes I can dynamically link to stdlib in Rust but I don't think Rust has a versioned dynamic library released for multiple architectures(still many embedded archs are not fully supported in Rust), that leads to problems in the field at depolyment and upgrade phases. Plus the dynamic library after strip is still close to 6MB, I can have a full libstdc++ around 2MB for the embedded system(with musl it is about 1MB), for many low-range embedded systems(there are a _lot_ of them), 6MB is still quite large.
- pitaj 4y ago6MB is quite large. Makes me question if you were even building in release mode. You may want to see https://github.com/johnthagen/min-sized-rust https://github.com/johnthagen/min-sized-rust It's not difficult to get binaries down into the 50KB range. And for embedded applications, less than 10KB is totally possible.
- synergy20 4y agoYes I tried all those 'minimize rust' approaches including the above one. they worked fine if you're statically link to its stdlib. but if you have a few complex rust binaries, static link for each of them is not going to help on the overall combined size. I did use a released library and build everything for release(per those minimize projects), I can easily cut a small program from 3M to 290KB but again, it is either static link, or you need a 6MB dynamic library to go with it. the key question is, what's the smallest size for Rust shared library? so far my finding is around 6MB(after strip, otherwise it's about 11~12MB)
- rychco 4y agoI've spent some time casually learning Rust in the past few weeks, and I'd really like to start incorporating it into my serious C++ projects. Rust itself is nice, but having a reliable package manager & build system in the form of cargo is absolutely the killer feature for me. If I could use Cargo/cxx_build as my C++ build system (which I think may be possible, but I haven't seen a good example), I would fully embrace rust & start incorporating it into my professional work today.
- zabil 4y agoI was introduced to rust with https://github.com/LukeMathWalker/build-your-own-jira-with-rust https://github.com/LukeMathWalker/build-your-own-jira-with-r... at a local rust meetup. I think it's pretty good.
- cercatrova 4y agoHis book Zero to Production in Rust is also very good.
- imusmanmalik 4y agoPerhaps someone finds this useful: https://learning-rust.github.io/ https://learning-rust.github.io/
- mrbonner 4y agoSerious question: can I just use smart pointer like feature of Rc/Arc combing with Mutex or RWLock instead of fighting borrow checker? I know this practice is shunned upon by Rust purists but I like to see how practical it is in real life and project. Especially around using Rust as a safer but more performant language instead of pushing for ultimate zero-cost abstraction and top notch performance.
- munificent 4y agoProbably, yes. But note that ref counters will leak memory in the presence of cycles. You need to either ensure that your pointer graphs contain no cycles (in which case you could probably also model it using ownership) or have some strategy for discovering and breaking those cycles (in which case ref counting isn't buying you that much). In other words, if your data is naturally modeled using ref counts, then, yes, Rc is great. If not, it's not. And it's probably worth noting that most managed languages don't use ref counting, so the set of problems that are naturally modeled that way appears to be relatively small compared to tracing GC.
- oconnor663 4y agoThe main drawback of trying to do this might be that the syntax is unwieldy. If you have one big shared object, or shared objects only in a specific part of your program, it's no big deal, and it arguably helps call attention to what's going on. But if everything is using Arc<RwLock<...>>, you'll have .write().unwrap() or similar on every line, and it'll feel terrible. The sibling comment mentioned cycle leaks, and in addition to that I'll add the runtime panics or deadlocks associated with locking the same thing twice.
- mrbonner 4y agoAgree that I should not just stick Rc everywhere. The use of borrow checkers makes a lot of sense at a macro scale, i.e: libraries, APIs. But, I’m just wondering the justification for using Rc in a smaller scope, say inside my own implementation of a trait. If I am to provide external APIs then yes, sticking Rc everywhere would not be a good idea ergonomically.
- jchook 4y agoOne great thing about the Rust books and tutorial -- you can easily enjoy them offline, right out-of-the-box. I learned the basics of Rust on a long plane ride with no WiFi. What a great way to pass the time!
- nonethewiser 4y agoThis sounded interesting but I was confused by what you meant by "the book." Looks like that's how it's commonly referred to https://www.rust-lang.org/learn https://www.rust-lang.org/learn
- valbaca 4y agoThis is the "The Rust Book": https://doc.rust-lang.org/book/ https://doc.rust-lang.org/book/ Affectionally known as "the book"
- stjohnswarts 4y agoThere's a new design patterns "book" out and it's pretty nifty as well.
- valbaca 4y agooh! link?
- stjohnswarts 4y agosorry just saw this, I don't check comments but every couple of days https://rust-unofficial.github.io/patterns/ https://rust-unofficial.github.io/patterns/ . you probably already found it on google though lol
- jmholla 4y agoI don't see anything explicitly calling out what to download in nonethewiser's link. How did you end up grabbing these things for offline learning?
- bzmrgonz 4y agoYou forgot to mention prior experience, which languages if any you have under your belt.