9 ms·
Rust 2018: an early preview
- ben0x539 8y agoYeah I can't see myself ever writing "crate struct Foo" or "crate use foo". :/
- steveklabnik 8y agoThere’s no plans to remove pub(crate), so you can still use it if you like.
- chrismorgan 8y agoReflecting on it months later, I’m more open to the rest of those changes (I was never against any of them, but I had reservations), but I’m still a bit baffled that bare `crate` as a visibility modifier, instead of `pub(crate)`, was approved. The rest has rationale, but that just doesn’t have compelling rationale (apart saying “this lets us forget about `pub(…)` syntax completely” counts), and met with quite a bit of resistance as well. I may still end up writing it if it goes out in that form; I’m not sure. Certainly removing the need for `extern crate` reduces the probability of confusion for developers old and new after the dust settles.
- burntsushi 8y agoI think you also need to consider consistency with the fact that `crate` can be used to start paths local to the crate in Rust 2018. (I'm not bothered by these changes personally, but I'm not really bothered by the status quo either.)
- ben0x539 8y agoPlain `pub` was concise and local and simple. :<
- steveklabnik 8y agoYou can do that too! pub isn’t going away.
- epage 8y agoI think I saw something about a lint for bare `pub` that isn't visible to the user. I think one of the intents is to make it easier to audit for what is publicly exposed and what isn't. Found it: https://github.com/rust-lang/rust/issues/45521 https://github.com/rust-lang/rust/issues/45521
- ben0x539 8y agoYeah, that's gonna be seriously annoying. :/
- Rusky 8y agoPlain `pub` actually isn't quite local, and that's part of the confusion that `crate` is intended to address. There's also the confusion of looking at a `pub` declaration and not knowing whether or not it's visible to the parent module or visible to the world- at which point maybe you don't want a purely local visibility mechanism.
- ben0x539 8y agoNah it's extremely local, that's why everybody is mad at it
- epage 8y agoI never really thought about it before when seeing the proposals but when looking at the guide's sample code, I wonder if this decision is something we'll end up regretting. As it reads, it sounds like you are declaring something is a crate akin to `mod` which I can see being confusing for new users.
- nixpulvis 8y agoI don't see it as a problem yet, `mod` still means submodule, and `crate` still means top level. The fact one is defining a new grouping structure and the other is defining visibility is slightly unfortunate, but probably not a huge deal.
- ben0x539 8y agoUsing JavaScript to remove certain lines from the code examples in the book is such a weird choice.
- steveklabnik 8y agoIt’s primarily so that tests can still be run, while presenting only the info you want to show to those who read the docs.
- ben0x539 8y agoYou should filter those lines before they hit .html files.
- maxbrunsfeld 8y agoThere's a button to toggle whether these lines are shown or hidden. Implementing this button's behavior using JavaScript seems perfectly reasonable to me.
- steveklabnik 8y agoYes, you want to be able to show people that it needs additional context to work, and what that context is.
- epage 8y agoI appreciate this. There are too many times that example code omits things and as someone new you get confused as to what the boiler plate is you should use.
- coldtea 8y agoSo that the 0.01% of people who turn off Javascript have a nicer experience?
- pjmlp 8y ago
- pietroglyph 8y agoThese are welcome improvements, but I worry that they will continue increasing complexity to the point that we have another C++ on our hands. There's a balance between new features and improvements, and simplicity and stability. I hope the Rust team finds that balance.
- xiphias 8y agoEven if Rust becomes almost as complex than C++ (which may be necessary to be able to move all low level code base from C/C++ to Rust), the world becomes a safer place by not having so many memory corruption bugs while being CPU/memory friendly. I really appreciate the fast pace the Rust team has and hope for this transition to start ASAP (though features are still missing for big code bases, like distributed compilation).
- adrianN 8y agoYeah well, that assumes that everybody will start using Rust no matter how complex the language becomes.
- pjmlp 8y agoThere is another way, which is how all surviving systems programming languages got their job. A major OS vendor states "if you want to target my OS here is the language".
- badsectoracula 8y agoAnd a C compiler writer would reply "hold my beer" :-P. (talking as someone who was working on a C-to-C# transpiler for PSMobile to port my C game engine to it before Sony axed it :-P)
- pjmlp 8y agoMost likely using a C compiler writen in C++. :)
- qop 8y agoRust is getting too complicated and noisy. It's not that it's difficult to use, but there's just too much stuff shoved into the drawer, and I really just need some silverware. my two cents. All the rust I've written is just rewrites of things I originally wrote in other languages. I'm a little disappointed to realize that I'm glad I don't have to write Rust for a living. I also think the 6-week release cycle is WAY too fast for a language with the low-level ambitions of rust. Granted, it's not like stuff is being broken every six weeks, they're doing a wonderful job with backwards compat in mind, but just the sheer volume of language delta is a lot for the average programmer, I think. Maybe I'm just a below average Rust hacker and maybe I'm just not "getting it"
- nazka 8y agoPlease don’t make Rust harder to read and code. I am almost done with the long tutorial/documentation and it’s already a lot. The genetics syntax with the ownership and the strut/impl/trait is already a lot to eat. For me if you have to break the past version of the language for the better it’s great. Just build an as simple and readable language as you can.
- pimeys 8y agoWhen you've written Rust a bit longer (over two years for me now), these changes address issues we face every day, making it now much easier to reason about your code. Before the introduction of `impl Trait`, splitting a large function using Futures to smaller ones either required you to have a ridiculously long type signature or take a performance hit with dynamic approach using a `Box`. The introduction of NLL will make beginner's life easier, so will the changes to the lifetime variables and if writing async code, you should be counting days to get the async/await and pinning to the stable rust. I'd like to know what changes here you think will make it harder to read and code Rust?
- pjmlp 8y agoI for one dislike the new dyn addition. Then again, I have other horses to worry about.
- nixpulvis 8y agoI for two.
- nazka 8y agoFrom where I am now and so not far in the world of Rust, I am struggling to learn all the new paradigms and ways of doing things with a special syntax. Maybe the syntax is easier for others or it will get better for me after a while but when I see the new dyn it’s hard for me to place it in an already crowded things to know. The other thing is how past and future features/syntax are supported, like for the new modules systems. I will prefer to break things when it makes sense with new features well thought out rather than support different ways of doing something and have as many ways of writing it. At the end of the day with a full team it’s as many way we have to read and so to understand. And even thought your team has the same guideline it’s the same problem when we start to read open source projects all with different ways of doing things. I won’t want to have a language that don’t break things and features stack themselves across the years but rather a language that refine itself over time with only one way of doing things. We can see how it turned for C++ where the language is so big that you have different ways of writing it and like how Google has its own guidelines and others too. On the other end look how Swift look now. Right now my feelings are not to add new features but to refine the language and the syntax. But I can be all wrong. I mean I have just starting to learn Rust. A syntax with some ideas from ReasonML for instance will maybe make it better. On a side note I hope this comment comes not too raw I see many down votes. I am just expressing my point of view as a beginner. Right now I know many of my coworkers will be turn down with what I said in my first comment. And they will turn to Go instead. Which I am sure can be fine technically but I really want to see Rust succeeds and have even more Rustaceans!
- deleted 8y ago[deleted]
- nixpulvis 8y agoI'll be really curious to see how the async/await stuff plays out. I'm still a bit unclear as to why it needs to be a language feature and not something in STD or an external crate. I'm sure if I read the RFCs/Issues I'd understand better, but it's been a while. Regardless, most of the changes so far are welcome in my eyes :)
- steveklabnik 8y agoThe PR to add it just landed in nightly, incidentally! But yeah, if you care, reading the RFC should explain that. It's been a while since I read it, but we had a procedural macro based version, but ended up with real language support for a reason.
- Mouse47 8y agoStupid question on `Box<Foo>` vs. `Box<dyn Foo>`: does this syntax apply to any other places where a trait is used as a type parameter? E.g. //do we write the type of MyBox like 'MyBox<dyn Debug>'? struct MyBox<T : ?Sized>{ inner: Box<T> }
- chrismorgan 8y agoYes. The unsized trait object type is being renamed from `Trait` to `dyn Trait`.
- jokoon 8y agoI recently found out about volt. I was so glad i found this language, which has everything i want, basically an improved c. Then I learned it was garbage collected. I felt disappointed.