9 ms·
Rust in 2023: Growing Up
- superkuh 4y ago[flagged]
- rom-antics 4y agoRust promises backwards compatibility, but I'm not aware of any language that promises forwards compatibility -- not even C. C compilers from 1999 aren't able to compile code that uses C11 features.
- pjmlp 4y agoAnd C23 compilers won't be able to compile code that still uses K&R, trigraphs, gets(), are free to ignore annexes made optional on C99 and still achieve ISO compliance.
- msla 4y agoWhat's more interesting to me is that C23 apparently removed support for non-two's-complement signed integers. Which vendors had to change position to get that change made, and what hardware had to officially get removed from serious consideration to make it happen? This site mentions UNISYS: https://en.cppreference.com/w/c/language/arithmetic_types https://en.cppreference.com/w/c/language/arithmetic_types
- superkuh 4y agoCorrect. But other more mature languages, like C or Bash or whatever, have devs that don't immediately use bleeding edge features. Bash gets forwards incompatible features all the time but it's devs actually write for pretty much any OS from 2000 to now. Because it's mature. C11 wasn't required for a significant amount of C projects until close to 2020. As Rust grows and it's demographic changes from bleeding edge types to a more general purpose userbase hopefully their use of the latest forwards incompatible features stop and distro rustc compilers become useful for more than half a year. And you know this is true. Otherwise all the docs wouldn't be advocating for dangerous curl | sh rustc (into rustup) installs. You absolutely do not get this kind of community behavior in C where your system compiler is good for at least a decade.
- orf 4y agoHomebrew manages just fine. This also sounds entirely like a problem with the rather old packaging process that evolved from the historical mess of distributing C projects.
- pornel 4y agoI've moved away from C partly because I had to fight decades-old compilers. It's incredibly disheartening to realize I can't hope it will fix even smallest warts, because the series of multi-year lags of the standards process, implementation, LTS cycles, and laggard upgrades mean everything takes decades and C from 1999 is still "new". Distros need to get their act together. Downloading a tarball every few months is not hard, and Rust doesn't have the whole-OS-breaking UB fragility that a change of a system's C compiler may have.
- kccqzy 4y agoAt work I usually write C++17 but I recently just had to work on a project in C89. Going back 28 years is painful. Not to mention the instant reduction in productivity, but it made me seriously hate my job.
- dijit 4y agoI'm not sure how I feel about this. On the one hand: I hate the growing trend of "everything bundled seperately" and "everything has it's own package manager". On the other... Why are you compiling things using packages? If your job is dev work then surely you have a bunch of tools that are unversioned by the OS? (Perhaps you've considered that they're not actually unversioned). VSCode, which updates in the background, intellij IDEA which updates into /opt. There is value in having it packaged, it helps you have a relatively deterministic system especially w.r.t. building other packages. But what does it actually give you the developer? Surely it's better to use the native tools for the language, which are tailored precisely for this and guarantee that your dependencies will be versioned correctly and available? It's not like the binaries you create using the compiler require you to have the compiler installed.
- deleted 4y ago[deleted]
- GolDDranks 4y agoMany users of Rust quite like that style, and it has served Rust well. What I think that needs to happen instead, is better support for tooling (in Cargo and crates.io) that understands about the MSRV or Minimum Supported Rust Version. Once the tooling is in place, at least you can't accidentally break your builds by updating your dependencies to versions that are too new for your compiler. Perhaps additionally releasing a Long Term Support version once a year or two would also help, as that would provide a common target for many crates to support conservatively.
- epage 4y agoSee https://github.com/rust-lang/libs-team/issues/72#issuecomment-1308130499 https://github.com/rust-lang/libs-team/issues/72#issuecommen... for what I believe is an exhaustive list of possible ways of helping the situation.
- GolDDranks 4y agoThanks for compiling that and all of your Cargo related work!
- dboreham 4y agoCan we even get a C++ compiler from the OS distribution and end up happy? Even C can be "wrong" (gcc vs llvm for example). So realistically nobody gets their compiler from the OS.
- jcelerier 4y ago> Can we even get a C++ compiler from the OS distribution and end up happy? no, tying compiler versions to operating systems as most linux distros do is one of the most harmful thing to software development in these last decades I think
- estebank 4y agoDistro provided compilers are meant to build the distro's provided packages, nothing more, nothing less. It is an accident of several confounding factors (slow release cadence, bad alternative delivery methods, wide disparity of feature support across deployments requiring developers to be conservative) that allowed some languages to blur the distinction and make their developers not have to care as much. Rust releases every six weeks. Some crates update aggressively. Others go to great lengths to support 1.13. In practice, there are "watershed releases" where most of the ecosystem migrates to relying on the same version, because a specific feature unblocks some use case. Looking at https://lib.rs/stats https://lib.rs/stats the obvious two such cases were 1.31 (async/await, edition 2018) and 1.56 (2021 edition), but at different points in time I've noticed other smaller breaks (like 1.63) for specific features (like const generics) that after a while get smoothed out by further jumps. One thing that keeps getting lost in the online arguments is that Rust is very aggressive about backwards compatibility despite its release schedule, so updating the tool chain has one cost: rebuilding your projects. Staying on older versions indefinitely means not only that you can't use the latest shiny language feature, but that you're not getting security updates or tooling improvements that materially improve your DX.
- pjmlp 4y agoYes we can, doing that for quite a few decades by now, approaching 50 years old.
- superkuh 4y ago
- insanitybit 4y ago`curl | sh` is perfectly fine and not any more dangerous than using apt or whatever else.
- stouset 4y agoIt's not quite as safe, since with apt or rpm the package can be signed by the distribution a (presumably) safer system, instead of being signed on-the-fly by an outward-facing webserver. But it's still pretty damn safe.
- 0x457 4y agoAnd `curl | sh` is signed by a certificate issued by CA. It's the same amount of safety if not more, since there is a trusted 3rd party while package managers are "trust me bro, it's our public key" Anyways, I'm not using rustup and using my nix flake to handle everything for me.
- craftkiller 4y agoThose files you get from `curl | sh` are just whatever happens to be on their internet-facing server (or any CDN server) at the time, whereas signing the actual package instead of the tls certificate for the https connection means that package building and signing could have been done entirely on a secure/isolated machine. Using `curl | sh` you're rolling the dice that the web-facing server didn't get pwned. Using signed packages means you don't care if the web-facing server got pwned.
- chlorion 4y ago`curl | sh` is not signed by a CA. With a conventional package manager, the contents of the package itself is signed, not just the connection to the mirror that hosts the package itself. Having a secure connection to the mirror is not necessary in this case because there is no way to modify the package without it being detected. With `curl | sh`, only the connection to the server is signed, but not what you are piping into your shell.
- insanitybit 4y ago
- eximius 4y agoyou can install `rustup` from a system package manager?
- giancarlostoro 4y agoI kind of wish Rust would eventually focus on a rich standard library. I'm talking everything from a basic but usable web HTTP server which others like Python and even Go (which I attribute to their success via net/http being built-in and OOTB) have available from the get-go. I also think Rust should heavily consider building a cross-platform UI stack, it doesn't have to be insanely exhaustive, maybe it can just seek for feature parity with something like Tk, but it would lead to far more adoption I think. Who doesn't prefer to just build something in a language where you know first time setup is pretty straight forward as opposed to wasting hours setting up some convoluted web project by hand? I think Rust needs to invest in providing a rich standard library, even if it is just its own library that is fully optional, as long as the core team works on and maintains it, I think it could do plenty of net-good for Rust as a whole. I'm also thinking of my favorite things about languages like Racket and Python which is a really simple editor that is built-in. Again, Rust needs to be able to build UIs to achieve this.
- ducharmdev 4y agoI think Tauri could be the cross-platform UI framework you want, if they can pull off Tauri Mobile
- satvikpendem 4y agoThe reason Rust has a lean std is because it must be backwards compatible, and already there are some deprecated things in std that must nevertheless be supported forever. With community crates, they can have breaking changes and can generally innovate more than those in std.
- estebank 4y agoAn alternative I'm not against is having the concept of "crate distros", where a bunch of related crates can be pulled in in one go with a tested set of versions. Something that delivers an experience like Django or Rails. At that point the distinction of "std" and these packages is one of nomenclature (and the kept ability to evolve independently from the compiler release schedule and remove things in the later).
- j-pb 4y agoThe thing that's really missing for me in rust is a better way to modularize enums with associated data and their behaviour. There are many cases where you have a closed set of known variants for a type, but they have very different behaviour, e.g. nodes in any kind of adaptive tree data-structure, such as an ART, HOT or Judy Array. In those cases you don't want to bring out the big guns with dyn traits. But the current approach involving huge match forests, macros, helper functions and code duplication plainly sucks ^^'. This could be solved by making enum variants proper types. Something that has been proposed already, but which has been rejected due to lacking capacity. https://github.com/rust-lang/lang-team/issues/122 https://github.com/rust-lang/lang-team/issues/122
- insanitybit 4y agoI've found that the `syn` approach works well here. You just use their Visitor or implement custom Visitors. But yeah, typed enums would be cool. I imagine as more const work is done typed enums will eventually be a natural next step.
- brundolf 4y agoThis does need to be solved, but I came up with a pattern in a recent project I'm pretty happy with: - Create all the variants as normal structs - Create enums around different subsets of them that just wrap each struct in a variant of the same name (including from/tryfrom impls) - Have methods for "casting" one of these enums into another The second and third points can be made fairly non-painful with a macro where you just say "enum X can be structs Y, Z, A, B..." and it creates the variants and impls all the traits for you But yeah. This is one of the bigger pain-points to implementing certain stuff in Rust Edit: just realized you were talking about something slightly different from me, but I think you could extend this pattern to get it: Have a trait that all variants implement, implement it on the enum too, and have the enum delegate to the variant structs (since those are already separate). The wiring should be automatable with the same macro
- j-pb 4y agoThe issue with the enum of structs approach is that it doesn't really work for low-level stuff with lots of byte-packing. Compare the following #[repr(u8)] enum Dense { A { foo: u8, bar: u16, } } struct AStruct { foo: u8, bar: u16, } #[repr(u8)] enum Padded { A { inner: AStruct } } The Dense enum will be 4byte, because Rust will use the u8 tag as an implicit first field of a tagged union with all the variants fields. However Padded will be 6 bytes, because AStruct is padded to 4byte, as the u16 causes it to have 2 byte alignment. That two byte alignment causes it then to be padded again when combined with the u8 tag. You can't mark AStruct as #[repr(packed)] either, because then the compiler can't proof that the struct will never be moved out of it's alignment providing variant (and unaligned field access is a no no for rust). The only other thing I could think of would be to transmute between the structs representing the variants, but I think that will probably cause UB because it destroys an ungodly amount of providence information.
- satvikpendem 4y agoI hope Rust can get higher kinded types through higher ranked trait bounds but for types, not just lifetimes, which would be equivalent to HKTs in other languages. I don't believe generic associated types are fully equivalent to HKTs necessarily but type level HRTBs should fill that gap. And I'm also looking forward to that keyword generics initiative, hopefully that team can look at how OCaml implemented their algebraic effects system, not sure if it's totally comparable however.
- leshow 4y ago> I hope Rust can get higher kinded types through higher ranked trait bounds but for types, not just lifetimes, which would be equivalent to HKTs in other languages. I don't believe generic associated types are fully equivalent to HKTs necessarily but type level HRTBs should fill that gap. In service of what though? I love Haskell and HKTs, but Rust is a different language and I don't find myself actually reaching for HKTs, even when writing libraries. Just my personal opinion, I think adding these features would be to Rust's detriment. I am happy to do my exploration into more complex type level features in another language in order to not add everything and the kitchen sink to Rust.
- satvikpendem 4y agoIt's more like many features are almost there but not quite and then do something differently. GATs are almost HKT but not quite and they're Rust specific rather than based in a common theory like category theory that many languages implement. Keyword generics are also almost like algebraic effects but not quite. It's more that I want Rust features to go all the way rather than do something 80% and in a different way than what other languages might commonly do.
- Gwypaas 4y agoFrom what I have read GATs (Generic Associated Types) are a deliberate choice to not have to introduce HKTs. https://github.com/rust-lang/rust/pull/96709#issuecomment-1148852889 https://github.com/rust-lang/rust/pull/96709#issuecomment-11...
- binarymax 4y agoGreat post and I really like the focus on sticking to the core mission: make things safe and do so without compromising on critical features like async. I see the complaints about things like stdlib and I don’t get it - the core team is doing an excellent job of keeping rust doing what it should do best, and the crate system and community fills that gap. If you want a big stdlib then use Python.
- thesuperbigfrog 4y agoIt is a delicate balance--having a smaller high quality standard library versus the "everything you could possibly need", "kitchen sink" approach found in the Python standard library. It is great that there is an active Rust community with tons of useful crates, but it can be daunting as a newcomer or when introducing Rust into an organization to discover and adopt the "right" crate(s) for common tasks that the standard library has no answer for. An example common task is asynchronous programming. For my current project, I am better off using thread::spawn, async / await, async-std, tokio, smol-rs, or something else? I had tentatively selected async-std, but then I came across this thread: https://github.com/async-rs/async-std/issues/992#issuecomment-1035223559 https://github.com/async-rs/async-std/issues/992#issuecommen... If I select a given crate today for a given common task, will the crate still be around and maintained in three years? Will I need to rewrite my project to use the latest crate du jour? I wonder if it would be possible for the Rust community to design / define a common library of traits for common tasks that could be used as "interfaces" (sorry, Java background) that library crates could be implemented against. This would provide better stability for crate users and help to avoid analysis paralysis and uncertainty when selecting crates for common tasks that the standard library has no answers for. There could even be multiple libraries of traits grouped by the type of task. This would allow for more natural groupings based on usage (instead of one huge library of traits) and permit independent changes from other defined libraries of traits. The Ada programming language has a similar idea called "Standard Library Annexes". See the bottom half of http://www.ada-auth.org/standards/22rm/html/RM-TOC.html http://www.ada-auth.org/standards/22rm/html/RM-TOC.html where the sections start with alphabet letters instead of numbers. There are standard annexes for: "B. Interface to Other Languages", "C. Systems Programming", "D. Real-Time Systems", "E. Distributed Systems", "F. Information Systems", "G. Numerics", and "H. High-Integrity Systems". Ada toolchains do not have to implement all of these annexes to be a standards-compliant Ada toolchain, but it gives those that do a standard interface so that they are more interchangeable, and code written against them does not have to be rewritten. Rust is wonderful and I want to see it improve. Is an idea like this feasible? If not, why not?
- thibran 4y agoRust is nice and I enjoy using it every time. Still it feels not matured as long as async is still in an MVP state.
- pjmlp 4y agoAnd error boilerplate that relies on 3rd party libs.
- paulsmith 4y agoNiko if you are reading this please add RSS to your blog!
- mjw1007 4y agohttp://smallcultfollowing.com/babysteps/atom.xml http://smallcultfollowing.com/babysteps/atom.xml looks like it works