15 ms·
> It's a pain to get working, it sucks to program in, it requires so much though, it's just a bloody fucking fuck What sucks about programming in Rust? What
by tomjakubowski 10y ago
> It's a pain to get working, it sucks to program in, it requires so much though, it's just a bloody fucking fuck
What sucks about programming in Rust? What makes it a bloody fucking fuck? I disagree on both these points:
* Rust enums and move semantics make writing state machines a pure joy. Far nicer than in C++ or Go.
* Pattern matching (both fallible + infallible) is very developer friendly.
* Option<T> and Result<T,E> are totally brilliant.
* It's trivial to add and version-fix a dependency on an external library with Cargo.
* Rust's ownership and move semantics help you to write cleaner, easier to understand code.
- bmurphy1976 10y agoHow does move semantics make writing state machines better? I can understand powerful enums, but I'm not familiar enough with move semantics to envision what you are referring to. Do you know of an example available somewhere?
- bjz_ 10y agoIt ensures that you consume a state at most once. You can kind of visualize state 'moving' through your functions - going in through the arguments and out through the returned value.
- sinhpham 10y agoExample: http://insanitybit.github.io/2016/05/30/beyond-memory-safety-with-types http://insanitybit.github.io/2016/05/30/beyond-memory-safety... TL;DR: compile time checking that your state machine transition is correct.
- bmurphy1976 10y agoThanks, I'll take a look.
- lordnaikon 10y agoI wrote you a little example but i think you need to know rust to really understand it :( https://is.gd/FlBCJ0 https://is.gd/FlBCJ0 you cannot uncomment the comments in the main function and use it wrong, the compiler prevents you to compile this code. these two sections from the book may help understad this https://doc.rust-lang.org/book/ownership.html https://doc.rust-lang.org/book/ownership.html https://doc.rust-lang.org/book/references-and-borrowing.html https://doc.rust-lang.org/book/references-and-borrowing.html if you're more into videos this may help http://intorust.com/tutorial/ownership/ http://intorust.com/tutorial/ownership/ http://intorust.com/tutorial/shared-borrows/ http://intorust.com/tutorial/shared-borrows/
- Anderkent 10y agoThis is really cool, thanks!
- saosebastiao 10y agoCan you explain the purpose of your '_unconstructable'?
- icen 10y agoIf a struct is public, and all its members are public, you can just create a new instance of the struct with braces (in that case, it would be `OpenSocket { data: 12 }` - or whatever value you like), not what is necessarily correct. By having a hidden zero sized struct member, you need to use the library's api to construct them.
- lordnaikon 10y agoSure. It is a private field(no pub) preventing you from constructing that type with a literal. It is of type "unit" '()' so it does not add up space for the type. "unit" has only one value that makes it "zero-sized". because i did not supply an "constructor" to that type it is not constructable outside the module and can only created by types in the scope of the enclosing module. Its more or less a private constructor known in C++/Java ... etc. Steve Klabnik has a more complete write up regarding this http://words.steveklabnik.com/structure-literals-vs-constructors-in-rust http://words.steveklabnik.com/structure-literals-vs-construc...
- EugeneOZ 10y agoSeriously, you are arguing with emotions, not arguments. It's pointless.
- tiglionabbit 10y agoNo, he's listing useful features.
- rntz 10y agoGP meant to say GGP is arguing against emotions, not arguing using emotions. He's accusing GGP's detractors of emotionality, not GGP.
- lhnz 10y agoAll but the last point will make your code easier to understand and program with. It's not an appeal to emotions at all - those are exactly the features I liked about Rust, and wish more programming languages had.
- EugeneOZ 10y agoI don't talk about his points at all. I'm talking about shit like "it's just fucking fuck" - it's emotion, not an argument.
- astine 10y agoHe was quoting the parent comment.
- StevePerkins 10y agoI would say that "it's a pure joy!" is the same thing in reverse. The parent and grandparent are both simply comparing subjective emotions.
- mevile 10y agoPeople who say Rust is hard are probably skipping on reading the really well written Rust book. I'm not a genius in any shape or form, but I am able to write decent Rust apps just fine. I've written an IRC bot in Rust and am working on a file utility now. It took me longer than 4 days (almost two weeks) to just read the rust book (part time), so yes you're not going to get from 0 to 100 in just four days. If that's your benchmark, how fast you can get going, then you're right Rust isn't for you. But nobody would expect anyone to get up to speed with C++ in just four days. Rust is a systems programming language with a focus on security and performance, not a play toy for people looking to write small scripts.
- enraged_camel 10y ago>>People who say Rust is hard are probably skipping on reading the really well written Rust book. Do you need to read a really good Go book to be productive in Go? If not, I think the OP's point stands, no?
- jacobwcarlson 10y agoI believe he's saying that the Rust book[0] is very good (and completely free). [0]: https://doc.rust-lang.org/stable/book/ https://doc.rust-lang.org/stable/book/
- Someone1234 10y agoI'm not sure that's fair. There are certain languages which are different enough from traditional semantics to need an explanation. While others are similar enough to be "obvious" if you've used a semantically similar language before. To give a specific example, Powershell. It is semantically a very different scripting language from almost anything else in the market. Extremely well designed and powerful, but you'll want to sit down and read an actual book on how it works to get to handle on it because you won't have the mental map already to do so. Overall this is why the programming language market is so predisposed for new languages looking and feeling like old languages. People just aren't comfortable stepping too far outside of their comfort zone semantically (even if they'll happily do so for a few new language features and libraries).
- tedunangst 10y agoWell, let's see. I was following rust's development for a while, but waited until 1.0 when it seemed it might be kind of stable. All that trivial and obviously correct code turned out to be a kind of wrestling match with the compiler. Far from a pure joy, it was rather frustrating. Set it aside for a while, but then came back recently figuring maybe I'd take another look but instead of starting from scratch I'd pick an existing project and poke around with it. First project I looked at had a requirement that one use the nightly compiler check out, but not just any nightly, specifically the one from last Tuesday. Then I looked at another project, and this also required nightly, but this time it was the one from the Thursday before last. Fuck. This. Noise. I'm not learning a language where every project requires a separate compiler.
- ajmurmann 10y agoI'm totally fine learning the borrow checker. It's a investment I see value in. Even if it's just in me learning about solid rules for sharing variables. But that nightly shit you describe is scary as fuck and makes me very concerned about the future of the language. Post 1.0 this shouldn't be an issue!
- pimeys 10y agoI consider libraries using a nightly Rust to be proofs of concept, not actually usable tools. This might be possible in the future, let's push these features to the stable Rust and maybe we could have this kind of libraries in the future. I always use stable compiler. Never had a need for nightly.
- tatterdemalion 10y agoThe main blocker on stable was a feature called "custom derive" or "macros 1.1" which will be stabilized in the 1.15 release in February. At this point any library tied to a specific nightly is using some extremely cutting edge features.
- burntsushi 10y agoThere are a couple of fairly popular libraries that were nicer to use on nightly Rust (serde and diesel), but could otherwise work on Rust stable. The "nicer to use on nightly" is going away with the next stable release of Rust. Other than that, the vast majority of the ecosystem is on Rust stable.
- orclev 10y agoThe biggest hurdle people seem to have with Rust is that it makes you very aware of the difference between stack and heap allocated data. For someone coming from a garbage collected language (or even in some cases C) that's a pretty big hurdle to get used to. I've found Rust to be amazing to work with, but it does feel like a struggle sometimes when all I want to do is allocate some structs without having to faff about with Box types. Honestly I feel like peoples biggest issue with Rust is that they're trying to write things in Rust that don't actually need Rust. They want the ease of use that you get with a garbage collected language and then get annoyed when Rust forces them to worry about allocations and cleaning up after themselves. C++ should have the same issue but its been around long enough that most of those details have safely been wrapped behind STL and other abstractions to the point where most people don't need to worry about them. Perhaps in time Rust will reach that point as well and everyone will be using the equivalent of Boost that abstracts worrying about whether something is a Box<ARC<Foo>> behind a nonthreatening layer of macros.
- weberc2 10y agoGo has the same distinction (stack vs heap), but the GC means you don't need to care about the lifetime of the data. To your other point, it saddens me that Rust isn't well-suited to higher level applications. You need very strict performance requirements before it makes sense to pick Rust over Go (you can squeeze a lot of performance out of Go, and even optimizing Go is friendlier than writing naive Rust IMHO).
- kernelbandwidth 10y agoI think this might depend a lot on how you approach Rust. I find the functional/procedural mixture to work nicely, and find I'm much more productive in Rust than Go (or Python or Java, modulo available libraries). I'm writing web services and code generators, so not particularly low-level code. I've written a decent bit of Go, and I understand why a lot of people like it, but I don't think it's inherently better for application development.
- weberc2 10y ago
- shanemhansen 10y agoI'm learning rust now, this isn't even my first attempt. I know Go really well and C reasonably well and I can say Rust is much harder. If you want specifics: I can tell you that I've found changing a type from HashMap<String, u64> to HashMap<T: Hash+Eq, u64> within one of my projects to be extremely hard. I've read the rust documentation, and had to resort to reddit several times. I'm stuck dealing with mutable/immutable borrow issues to accomplish relatively simple tasks like searching for entries and removing them. In go these issues don't exist. I'm sure I'll figure them out eventually, and I'm a fan of rust, but it's a confusing frustrating grind. My understanding is that the rust team has put 2 priorities ahead of everything else: zero cost abstraction and safety. Given those constraints they've done a fantastic job in the area of ergonomics, but I don't know if it will ever be easy. Maybe rust is as easy to use as it can be.
- bluejekyll 10y agoHave a link to your code? > HashMap<T: Hash+Eq, u64> I can take a wild guess that T is a generic type defined on either the method, struct or impl in which this HashMap is declared. It's on the method/struct/impl. You don't necessarily need the type bound on the struct, but you do on the impl declaration: struct MyStruct<T: Hash+Eq> { map: HashMap<T, u64> } impl<T: Hash+Eq> MyStruct<T> { pub fn insert_something(&mut self, my_key: T, my_int: u64) { self.map.insert(my_key, my_int); } } try it here: https://is.gd/RwUpQx https://is.gd/RwUpQx
- moosingin3space 10y agoPlease don't hesitate to ask for help on #rust-beginners. I was in your situation last May, and hanging out on IRC was an excellent experience. Rustaceans, generally speaking, will bend over backwards to help you work on your project.