330 points · by steveklabnik · 11y ago · 183 comments
1) I have no idea what to do with it. I'm primarily a web developer, and I really want to get into systems programming, but I have no idea what to do with it or where to start. I wound up implementing about 50 different Rosetta Code things in Rust 0.9 and 0.10, but I still never came up with a really solid use-case that I could start and finish.
That said, I've been really impressed by rust-doom (https://github.com/cristicbz/rust-doom) and the new Iota editor (https://github.com/gchp/iota), and I wish I had the know-how to even start down that path.
2) Given that the last time I touched systems programming was in college (15 years ago), I've found it difficult to wrap my head around some of the concepts (ownership in particular). I actually hung out in the IRC chat room for awhile, but I felt more than a few times that people were treating me like an idiot because of my questions ("Ha! You did X? Why in the world would you do that??"), so I wound up not really going back. I'm sure it was all my imagination and that I'm just being sensitive, but I think it would be very helpful to have more people interested in getting new people on board -- specifically people like me, with over a decade of programming experience in higher-level languages.
I guess the TLDR of this is: I love Rust, but I don't know what to do with it.
Congrats to the Rust team, though. 1.0 is a huge milestone. Good job!
> I actually hung out in the IRC chat room for awhile,
> but I felt more than a few times that people were
> treating me like an idiot because of my questions ("Ha!
> You did X? Why in the world would you do that??")
Unacceptable. I'm an op in #rust (bstrie), so feel free to PM me their nicks and I'll see to it that they treat new users better in the future.But that's not really the point. I think the point is that there's a need for a sort of onboarding process for people who have never had to deal with some of these basic concepts. For instance, in web development, there's not a lot of need to know much about ownership or memory. The popular languages (Java, PHP, Python) kinda handle those things for you. So when you dig into Rust, you spend a lot of time thinking things like "wtf is a pointer?" and "wtf is a reference?" instead of actually building something useful.
That's a really frustrating part for me. I can build anything I want in PHP or Python or Java. I know those languages like the back of my hand, and if you give me a problem, I can solve it.
But then I start with a language like Rust, which concerns itself with all kinds of things I've only vaguely heard of, and then I'm completely lost. Super, super, super frustrating. It's a struggle to do a basic blackjack game -- something I could do in my sleep with Python!
So you don't know these concepts, which is already frustrating, and then you go into chat and you say "WTF is a pointer?" and hopefully people say "Oh, dude, it's so easy, imagine. you have this..." instead of "That's basic computer science, man. RTFM."
To be fair, I think Rust's documentation back at 0.9 was great. I'm positive it's way better now. But back at 0.9, it didn't answer the questions I had, which is why I had to go to chat in the first place.
But yes, most people were very, very helpful and I really did learn a lot. :)
For 1, it's true that it's not clear Rust is going to be great for web development. http://arewewebyet.com sums things up. That said, Rust does run the backend of Crates.io, and I've been toying around with it as an Ember backend, so we'll see :)
2) I'd love to hear your thoughts on my new ownership guide, which landed last weekish: http://doc.rust-lang.org/guide-ownership.html thoughts very welcome, either here, email, or on the issue tracker.
Ownership is the one concept in Rust that hasn't really existed at the language level before, so it's the most unusual thing to grok.
> I felt more than a few times that people were treating me like an idiot because of my questions
Sorry to hear that. :/ We try to keep it 100% welcoming, but sometimes, people slip through the cracks.
Care to divulge some of your experiences so far? Like others here, I'm a webdev searching for a point of entry in Rust, and seeing that there's web frameworks out already I thought they'd might work. I want to start a side project with a Backbone/Marionette front but have been wondering whether to use Rails (day job), Node, or now even Rust. Thanks.
Just saw your rustforrubyists...definitely going to follow that!
Even better, you can just look at it: https://github.com/steveklabnik/rustmvc
I haven't had the time to make it great, just hacking away.
> Just saw your rustforrubyists...
I appreciate the sentiment, but you probably shouldn't bother. Once I started working on the Guide, I stopped doing more than minimal upkeep on R4R. I consider it deprecated at this point. :)
I don't necessarily need web-based ideas, but I don't know enough about the systems programming ecosystem to have an idea of where to start! A text editor? A game? A virtual planetarium? Machine learning? I have no idea! (Like I said, not your/Rust's problem...)
1) Large and complex systems that are slow to evolve due to being written in languages that are unsafe or are relatively poor in abstraction (in addition to the immense domain complexity). Examples: SQL and/or distributed databases, Paxos-ish systems, Operating Systems, IDEs, GIS, etc.
2) Extremely high performance systems on the fringe of research. Examples: MIP/LP/CP/SAT Solvers, Theorem Provers, Formal Verification tools, Rete-based Rule Engines, Machine Learning algorithms and frameworks, Statistical Samplers for MCMC, etc.
Unfortunately (maybe, I don't really know if it will turn out well or not), most of the hype for rust comes from back-end web developers. That is fine...I'm sure there is some performance to eek out there...but it is also trying to compete in an area where garbage collection has its greatest competitive advantages (namely, long running server processes). The comparative benefit is relatively small.
> most of the hype for rust comes from back-end web
> developers
It may seem that way because 1) most of the hype for anything programming-related these days comes from back-end web developers, and 2) because back-end web developers are the primary audience of HN. At Rust meetups that I've attended I've seen interest in people doing video games, robotics, AI, numerical work, databases... they just don't have as public and excitable a forum as this. :)I thought it was the opposite that was true. A garbage collector can/will leak memory over time (days) and will use up to 6-8 times more memory and can have performance problems etc. All long running server processes I know of (database, mail, http servers) manage their own memory. Exceptions are VM based systems and it is not unheard of to have a trivial Tomcat app use up to 1GB of memory.
Usually that is a consequence of not optimizing the applications.
Using Java as an example, I still meet people that don't know about VisualVM, Mission Control, Eclipse MAT and many other similar tools.
It is possible to write applications that exhibit a flat GC line after they are warmed up, but many don't bother until someone complains about.
I know of many client side libraries that are in C++ because it works everywhere(tm). Being able to maintain them in something like rust would be far nicer.
Right now they are failing to build due to a recent breaking change, which made structs not implement Copy by default any more. The library is in active development, so that should be fixed soon enough.
Its pretty fun, but im looking forware to stability too.
Hmmm, I've been wanting to learn Rust, but I always need a project to learn a language, and I haven't written a Lisp "in a week" yet ^_^. Yeah, thanks for the idea.
Do you have a public repository for a curious fellow hacker?
https://github.com/clojit/clojit-vm
Sadly its not working currently, I started a new job and Im moving so I had very little time the last 2 weeks and I didn't manage to keep up with the changes in rust.
You're a web developer, and you don't know what to do (in terms of how to spend your time) with a language geared toward systems.
That makes a lot of sense! At a certain scale, they're different types of work. It's like saying, "I'm a race car driver with a fighter jet. I've always admired them, but I'm just not sure where to fly!"
These types of languages, and more broadly any compiled language like C or C++, are very well suited to solve problems that your dynamic or scripted language can't solve at scale. Say, for example, as a web developer you built a website on Ruby on Rails that converts user-uploaded photos to morph, based on some algorithm, into a cute, unique photo of a kitten.
You have several concerns here: - Processing the image, hopefully in the background so it's non-blocking and you can control resource needs. - Storage. Is it on a local disk? S3? Something close by but on the network? If you have a performance bottleneck, is I/O an issue? - Memory/CPU. How many resources are needed for n- jobs? Is it starving resources from serving additional web requests (really a separate concern, when you think about it!)
I would say for these types of problems (and this is admittedly a contrived example), Rails + some Gem or even pure Ruby might just absolutely suck and eat it.
These specialized languages can be a super useful tool for figuring out "simple problems with complicated solutions." They also offer the comfort of compiling down to a binary that might have no external dependencies (so, very portable depending on the compiler/runtime, and probably very reliable).
Is that the right thing for a pure web developer to play? Depends on the developer, but it's not surprising you're not quite sure what to do with it. It's possible you just don't have the right type of problem to solve yet.
That being said, Rust or Go are still fun to play with! Good for you for exploring.
I wrote an LZW compressor in Rust 0.9 way back when, and it sucked pretty badly, but I wouldn't even know how to open a JPG or PNG, much less the mystical art of resizing it!
Gotta start somewhere, I guess. :)
I would suggest perusing materials of a computer graphics course.
For instance, this course from Brown seems to have lecture notes online: http://cs.brown.edu/courses/cs123/lectures.html
http://cs.brown.edu/courses/cs123/lectures/CS123.08_Image_Pr...
I'm thinking profiling some stuff and writing native accelerators, in Rust instead of C. More of an excuse than a need, but hey.
> I've found it difficult to wrap my had around some of
> the concepts (ownership in particular).
Have you tried reading the Ownership Guide (http://doc.rust-lang.org/guide-ownership.html)? I actually haven't read this particular guide myself (it didn't exist when I got started with Rust), but it sounds relevant :)For example, the current build system is functionally equivalent to #including a bunch of C files in your C project and only passing one file to cc. I brought this up and had a long discussion about it and how it might be improved with the community, but then when core contributors showed up, the discussion was shut down with the justification that "1.0 comes in a month". I've heard other stories about poor management of the project and I'm just not as excited about Rust as I used to be.
Also, on the subject of the build system, while I too found it a bit confusing, only passing in the "main" file and having the compiler automatically compile and link all dependencies, over time I've come to love that feature. Especially coming from a (admittedly amateurish) C background, where I had to explicitly compile all of my source files into object code before linking them together, having the compiler manage everything for me cuts down on a lot of mental overhead (in my opinion, anyway). I wish the process was explained a little bit better in The Guide, but that's a documentation problem and not an implementation problem, which is much more easy to fix.
To make sure I'm understanding, you mean the process of only compiling the crate root?
Multi-crate stuff has historically been a pretty weak area of the docs, but we do have a whole guide on it now: http://doc.rust-lang.org/guide-crates.html
Please feel free to open up issues on the repository any time you feel the documentation is lacking, I'd love to fix any problems.
> I brought this up and had a long discussion about it and
> how it might be improved with the community, but then
> when core contributors showed up, the discussion was shut
> down with the justification that "1.0 comes in a month"
Can you cite a source? If it was on IRC, I'm willing to sift through logs to find it for you if you give me your IRC nick. > I've heard other stories about poor management of the
> project
What stories are those? We have our fair share of people who like to spread FUD, so I'm curious which one you ran into. :)I'm "SirCmpwn", and the chat took place a few days ago in #rust on irc.mozilla.org.
> What stories are those? We have our fair share of people who like to spread FUD, so I'm curious which one you ran into. :)
I'm not really willing to name people who criticised Rust's project management here.
At no point in there is anyone that you're engaging with a part of the core team (which is to say: eddyb, zwarich, kmc, kimundi are all community members). So I still don't see how you can argue that the devs have shut you down with the 1.0 argument.
I also see that your proposal seems to be to add header files to Rust. What everyone there failed to mention is that Rust did use to have header files (called crate files, with a .rc extension), and we removed them to a great chorus of rejoicing. Rust is unlikely to tread that path again, after having discarded it once.
Where was this discussion held?
1: http://doc.rust-lang.org/std/macro.include_str!.html is what I'm thinking of here.
mod mod_name;
With: #include "path/to/mod_name"
and then run it through the C preprocessor and it'd work exactly the same.The discussion was held on IRC.
That sounds like the perfect example of something that can be imporoved later and is totally orthogonal to the language design.
Semantics and syntax are what they need to get right pre 1.0, not the build system.
At least that's what I've encountered before. May be now is better. The thing for community contributors is that we all have other jobs to do. After spent huge amount of effort in development and exhaustive testing and the review process went nowhere, I just didn't care to bother about it anymore.
As someone who works with Rust on a daily basis to implement a browser engine, I can confidently say that Rust is not a solution in search of a problem for our domain. As an example, I implemented CSS "letter-spacing" the other day, and it worked first try after compiling. The layout code I write has a remarkable resilience to crashes; in the rare cases that it panics, it aborts safely. And I get parallelism "for free" as I implement more layout features, because the compiler stops me if I'm about to do something non-thread-safe. None of this applies to C or C++, and the end result is that we can move faster and write cleaner code.
Either he has a need to a "better/safer etc" C, or he doesn't. If he doesn't, then Rust isn't for him.
And it's not like anybody tries to market Rust to people who don't need it ("so we're told").
Since the agent runs inside of a Ruby program, our only good choices are Ruby itself or a language without a garbage collector (embedding a language with a GC inside a language with GC is asking for trouble -- take a look at the bug tracker for TheRubyRacer for some color). Our initial version of the agent was written in Ruby, but carefully controlling memory usage or performance in Ruby isn't really feasible.
We prototyped a new version of the agent in C++, but I personally didn't feel comfortable shipping a binary that would run in thousands of customers' Rails apps in a language that could segfault if you're not careful. We took Rust very seriously last November, even thought it was still very young, because it gave us a language with direct control over memory with compiler-verified guarantees that our program wouldn't segfault.
TLDR: Rust is a very good choice for writing performance or memory-critical code that will be embedded in a high-level-language.
Also, because it offers compile-time guarantees about safety, I expect it to expand the number of cases where people feel justified in embedding a low-level language for performance-critical problems.
C programs doing what I'm doing have traditionally had security issues. Since our code often runs in privileged locations, that's an unacceptable risk. Plus, Rust is vastly more expressive than C and not messed up like C++. And abstractions are cheaper, too. For instance, we use Generics + Traits as a way to keep flexibility and a plugin model per frame, while keeping the performance of static dispatch. C wouldn't be able to do that in an easy way.
When you mention you are a C programmer or like coding in C, they begin to blabber about C being legacy, Rust this, and Go that (languages they think are more like Python). All in an effort to cope with the insecure feelings they have because the C programming language and C++ (read: pointers) intimidate them.
You have to know pointers and manual memory management to program in Rust. Rust isn't there to save you from having to learn about pointers. Rust is instead a reaction to the empirically observed fact that nobody [1] has ever written a multi-million-line program with a large team in C or C++ without accidentally making dangerous memory-management-related mistakes, and "just program better" is an approach that has been tried, and failed, again and again and again.
[1]: OK, maybe the Mars rover and the like are counterexamples, but the extreme amount of verification required means that this approach is far too costly to be practical for most software development.
I loathe C++, think it's way too dangerous, and C is obviously dangerous. I really want something safer to do systems programming in, that's successful (pretty much every prior alternative has failed in one way or another). Maybe Rust will be that.
I think Rust is awesome.
Wanna say something stupid? Do it with your real nickname.
The time is soon. I as much as anyone want error handling to be flawless, but I don't think that's enough of a reason to hold back the rest of the language. If we have to evolve our approach to error handling a ways down the road, so be it. Other languages have endured similar paradigm shifts.
However, this issue will be inherently subjective... all I can say for sure is, if nobody at all were saying "no, it's too early!", it would certainly be too late. :)
Ultimately I do appreciate reaching 1.0 is a difficult set of tradeoffs and everyone has their pet feature they're sad isn't going to make it in. Bring on 2.0!
> while the same is not necessarily true for HKT
By far the biggest demand for HKT is from people who are requesting Haskell-like do-notation for error handling. HKT would affect everything! Given this, I absolutely agree with the notion that HKT is a 2.0 feature rather than a 1.0 feature.It's possible that we will add at least the `?` notation to replace `try!` before 1.0 final; it remains to be seen.
I wouldn't really consider a language without a standard library "complete", and a good standard library is important to me in a language. (As it's going to help you get stuff done.)
¹Python, for example, doesn't specify iterator invalidation rules AFAICT; you just have to look at what CPython does. And in CPython, there are ways to make an iterator return a sequence of items that does not make any sense. (e.g., the same item twice, or skipping items…) In C++, invalidation is well-specified, but the compiler doesn't really help catch errors.
You shouldn't read much into the "experimental" tags right now; they're part of an API stability tracking system that is heavily in flux at the moment. In particular, for most of the modules you mentioned, only the module name itself has not been marked "stable", while the contents have been. For example, if you look at the Vec type itself:
http://static.rust-lang.org/doc/master/std/vec/struct.Vec.ht...
you'll see that most methods are unstable or stable, rather than experimental. (The "experimental" status is currently the default, to help us keep track of API "stabilization" progress.)
This stability tracking is part of our general story about API compatibility; you can read more at
http://blog.rust-lang.org/2014/10/30/Stability.html
These markers won't take on their full meaning until we ship 1.0.
For 1.0, all of the APIs you mentioned will be "stable", and indeed most of their internals already are. Over the next few weeks, we'll be updating stability markers to reflect the API scrutiny and design work that we've been doing.
More generally, for all but a couple of the modules listed at
http://static.rust-lang.org/doc/master/std/index.html?search...
we have already performed a detailed scrutiny of the API, and have either landed changes needed for 1.0 or will do so very soon. Most truly experimental APIs have already been deprecated or removed.
For IO in particular, you can read a very recent RFC that proposes the final set of API changes for 1.0:
https://github.com/rust-lang/rfcs/pull/517
Hope that helps!
2) this means Rust will have a small standard library. But we already have Cargo. So you end up getting lots of packages, they just aren't built-in: they require adding one line to a config file instead.
3) iterator invalidation is a compile-time error in Rust. Rust relies on Iterators quite heavily.
> I haven't seen any confidence that HKT can be implemented
> in a backwards compatible way
Because nobody has ever managed to propose a design for HKT. How can you possibly future-proof against a feature with no clear idea as to its shape?For example, see https://github.com/rust-lang/rfcs/pull/213#issuecomment-6575...
Then "nothing" happens. The default, correct, behaviour for "unhandled" errors is to abort the program. Rust apparently thinks it doesn't need this, because "poisoning". Which is a great thing, except it still doesn't excuse silently swallowing errors. It's one way to end up with a half-dead process. And considering Rust's overall strict handling of errors, it seems bizarrely counter-intuitive to go with the silent route here.
The .NET team went through the exact same process and ended up taking a breaking change in v2 to fix their handling of background exceptions (so now they crash the app unless you opt-in to handling them).
I described it here: https://github.com/rust-lang/rust/issues/19610
But it's closed pending writing an RFC and I haven't had time to figure that out yet.
Edit: I added the RFC: https://github.com/rust-lang/rfcs/pull/519
Rust has been going as a project for five years.
There are many, many people who have been waiting literally years for Rust to stabilize to start using it. (Just look at the comments in any other HN thread about Rust.)
Rough edges in the macro system (which can be fixed post-1.0 and doesn't need to be completely rewritten) and error handling changes aren't enough reason to force them to keep waiting. It would take years to get every single feature in that people want and it'd be doing a disservice to our community to force that huge group of people to wait even longer. And I feel it too—as someone who uses Rust every day, the issues that keep coming up are minor annoyances compared to the major pain caused by lack of stability.
https://stackoverflow.com/questions/26329231/returning-a-sim...
``` core::iter::Zip<core::iter::FilterMap<'_, (&std::collections::hash::set::HashSet<attr::Attribute>, &attr::Attribute), &attr::Attribute, core::iter::Zip<core::iter::Repeat<&std::collections::hash::set::HashSet<attr::Attribute>>, core::iter::Map<'_, (&attr::Attribute, &()), &attr::Attribute, std::collections::hash::map::Entries<'_, attr::Attribute, ()>>>>, core::iter::FilterMap<'_, (&std::collections::hash::set::HashSet<attr::Attribute>, &attr::Attribute), &attr::Attribute, core::iter::Zip<core::iter::Repeat<&std::collections::hash::set::HashSet<attr::Attribute>>, core::iter::Map<'_, (&attr::Attribute, &()), &attr::Attribute, std::collections::hash::map::Entries<'_, attr::Attribute, ()>>>>> ``
And who knows, it might happen for 1.0 if enough people push on the design and are willing to put in the legwork of implementing it.
In particular, the biggest pain point for the lack of anonymized return types won't be the use case mentioned in that SO thread (which is heinously ugly and leaks implementation details, but at least it's possible), but will rather be the fact that without anonymized return types it will be impossible for a function to construct a closure and then return that closure without stuffing it into a box (though note that it will still be possible for functions to return unboxed closures if it accepted that closure as a parameter to the function).
Open issues start a discussion, and then morph to a more formal proposal.
This is incredibly exciting in that it means that you won't need to do any ceremony to link in Rust libraries from other languages (previously you had to opt out of the stdlib and reimplement lang items as needed). But it also means that static libs should be much smaller, due to no runtime being necessary (which should also make LTO more able to strip unused symbols, shrinking binary size further).
The smallest known Rust binary is 151 bytes: http://www.reddit.com/r/rust/comments/2iwtjh/151byte_static_...
My sibling also has great info.
My question sounds obvious but depending on the project 1.0 can mean very different things.
What's a Rust development workflow look like at the moment, from editor, to reference materials, to debugging? I tend to be an IDE person (which obviously doesn't and won't exist for some time) so I'm pretty eager to hear how other people have been doing it.
This is the biggest lie of all. Programmers have spent untold billions of man-years writing about code, how to write it faster, better, prettier, etc. and at the end of the day, it's not that significant. Code is ephemeral and has no real intrinsic value. The algorithms certainly do, sure. But the code itself isn't worth all this time (and shelf space! – have you seen how many books there are on UML diagrams?). The code, the performance and the features hinge on one thing – the data. Bad data equals slow and crappy application. Writing a good engine means first and foremost, understanding the data.