What is Rust 2018?
blog.rust-lang.org
blog.rust-lang.org
Turn out that it's false. What's amazing is that the compiler ensures that projects using the legacy edition can still use libraries relying on the new edition.
that if you’re using Rust 2018, you can use dependencies that use Rust 2015 with zero problems. If you’re sticking with Rust 2015, you can use libraries that use Rust 2018. It all works together
That's great!
To add on top of this is the amazing work to make this work even for Macros!
One of the problems with C++ is there is less of a dependency management story around it.
- Maybe staticlibs will let you mix language versions? - Maybe DLLs will (granted you probably shouldn't have C++ in your ABI anyways)? - headers-only or vendored libraries won't allow mixing language versions.
Contrast this with Rust where all of the standard approaches for declaring a dependency allow different language editions.
C++ 17 is still really nice, the language is just old and C compat + lots of historically bloat makes it crusty. A better type system with more FP concepts and more safety is a win-win in my book.
There are some often-requested features (specialization, const generics, box syntax, placement new) that even got implemented, but are still unstable, because they aren't good enough. The bar is high.
Plenty of RFCs get rejected: https://github.com/rust-lang/rfcs/pulls?q=is%3Apr+is%3Aclose... and even more "pre-RFCs" don't even make it past initial discussion in the forums.
I think Rust is getting better over time in making ideas polished. The few warts it has so far (e.g. Error description() and cause(), struct literal parsing in `if`) are from before 1.0, and probably wouldn't get past the RFC process used today.
The case I was analysing was Qt C++ UI plus Rust library. There's a Rust text editor (xi?) which is using JSON to communicate between the UI and the core. In that case I believe it was designed like that to allow for different UIs, but it looks more appealing than the C interface.
What's funny is, it kinda goes both ways: I've recently spent a bunch of time talking to some TC39 members, and they have been talking a lot about a roadmap process that kinda looks like ours, while we've been talking about making our RFC process be a little closer to the "staged" concept that they have. Very interesting times!
Most importantly though, it had a lot of influence because they have similar stability constraints as we do; I mentioned C++ and Java in the post, but maybe should have mentioned ECMAScript as well.
Rust does follow a time-based release schedule, though (a new stable release every six weeks), and it does have many of those advantages.
1. Making the language friendlier for beginners and easier to understand.
2. Addressing pain points by production users.
That being said, I'd push back a little on "number of features" as a measure of complexity. There's a few ways in which this is a problem.
For example, the "waterbed theory of complexity", that is, if you make the language simpler, you push the complexity elsewhere. This can be good or bad, depending. I generally hesitate to compare Rust to other languages, but there was a good illustration of this the other day, about Rust and Go: https://news.ycombinator.com/item?id=17618918
Basically, Go has kept the language incredibly simple. Rust has added many features that Go does not. But that means that error handling in Go is significantly more verbose than in Rust. You can't just wave away the inherent complexity of properly handling errors; it has to go somewhere. Both choices are 100% valid, just different.
The other big issue with simply enumerating features is that cohesion and orthogonality is important. C++ did something truly impressive; they changed the fundamental model in which you write code. Idiomatic C++98 and idiomatic C++17 look and feel very different. The cost of this is that many features don't quite fit together as well as you would like. Or at least, that's what people say. We try to really make sure that features fit together in a way that makes sense.
Time will tell if we succeed.
I hope you realise that the C++ design committee also doesn't add things for the sake of adding them. They aren't morons. Often there is a very real tradeoff in every decision, but generally the motivations seem to also be those two you mention.
To quote:
The foundation begun in C++11 is not yet complete, and C++17 did little
to make our foundation more solid, regular, and complete. Instead, it added
significant surface complexity and increased the number of features people
need to learn. C++ could crumble under the weight of these – mostly not
quite fully-baked – proposals.
[0] http://www.stroustrup.com/P0977-remember-the-vasa.pdf This paper proposes a web_view facility for the C++ standard library.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p110...Yes, web view and standard library are being used in the same sentence. How on earth a web view might be considered for inclusion in a standard library is beyond me.
Getting outraged at proposals, especially from the outside, doesn't make for a healthy process; not every proposal becomes accepted. Off-the-wall proposals can sometimes help explore a problem space with a new outlook. That doesn't mean that every single proposal is worth taking equally seriously, but Hal is a well-known name in this space, and has done a lot of good work.
(Incidentally, this kind of situation is why we're interested in adding stages to Rust's process; we want clarity around the maturity of a proposal. Some proposals are just for brainstorming. Some are more mature. It can be hard to tell sometimes from the outside which is which.)
There was a years-long effort to add a 2D graphics library to the C++ standard library.
make documentation a priority! With Elixir or Golang you can access doc super easily from the command line. Some sublime text plugin shows you the doc for highlighted std functions as well. These are what make a language awesome imo.
(Some editors do have inline doc showing support; we don't have terminal doc access but we do have local html doc access)
cargo doc --open
opens documentation for the current project, including all its dependencies. Rust generates docs in HTML. While it doesn't stay purely in command line, it enables cross-linking, collapsible sections, and has built-in search.For example, many users were confused by Rust's module system, because modules behaved differently than in other languages. The 2018 edition added the "missing" features to the module system to meet expectations that new users have.
The end result is that Rust 2018 is easier to learn.
Rust has been adding features for 30 releases now, and every new release has been easier to use and easier to learn.
People added features to languages like scheme, ocaml, lisp for decades, and it was fine. There are type systems for racket, object system for ocaml, pattern matching for lisp, all of which are simple and fit into the design of the language well.
The problem with C++ is that it was based on the C language, which already was an example of terrible design (by modern standards), and new features also were half-baked or badly designed (SFINAE, accidentally turing-complete templates, 666 *values, too much implicitness and unnecessary entities, like constructors).
So far rust is very nice, concise, elaborated and explicit language. Hope that the new features would be as elaborated and neat, not just monkey patches.
Template meta-programming is awful but that particular type of turing completeness isn't a problem at all. Mere arithmetic and some kind of ability to loop gives you that kind of turing completeness. The typical compiler limits looping depth to a couple hundred, and the problem is solved. Such a construct isn't a notably slow use of templates either. It's more trouble to avoid it than to have it. Compare some macros that can't loop and need a bunch of extremely repetitive lines for different sizes.
I need my typechecker be total. And you don't need turing completeness for arithmetic and recursion.
Recursion limits make it total, very easily.
> And you don't need turing completeness for arithmetic and recursion.
Yes you do. If you allow basic arithmetic to recurse n times, it can simulate n iterations of a turing machine.
I guess by modern you mean 1980, given the alternatives.
It seems like it's maybe not a good idea to get too much into it though, the language seems to move a lot, there are still a lot of things that are not here (a rand library, benchmarks) or are subject to change. I'm not sure if I should give it more of my time.
While we do add stuff a lot, we don’t break old things, so what you learn is still going to work!
That said, that work tends to fall under "compile time expressions"; "template templates" are more likely to be served by some sort of eventual HKT, or maybe even by ATC. I always forget what perfect forwarding is so I probably shouldn't comment on it.
I am willing to bet that this stuff is a major part of next year's roadmap, but we'll see!
fn %identifier(value:%type) -> %type {
BytesMut::from(value)
}
ie, to look like html templates like handlebars or similar.https://github.com/rust-lang/rfcs/issues/324#issuecomment-24...
For powerful meta programming Rust aims for procedural macros, not for templates, but I'm not too familiar with the details.
Yes, this is a good point.
We want Rust to have powerful compile-time metaprogramming, but we also want to do it in a Rust-y way, not blindly copy C++ or any other language.
rustup target add arm-unknown-linux-musleabihf
RUSTFLAGS='-C linker=rust-lld -Z linker-flavor=ld.lld' cargo +nightly build --target arm-unknown-linux-musleabihfThe closest I've seen to this model is "use strict", but having this at the package level is a nice quality of life improvement.