News for hackers. Stuff that matters.
Re:Two years of Rust by bluejekyll on Monday May 15, 2017 @07:04PM (#14345985)
`cargo check` is pretty darn fast, and that's pretty much all you need while developing. I'd say it's generally 50% faster than a standard compile (not benchmarking, just a gut feeling).

On top of that `cargo watch 'test'`, runs fine on a 100kloc project, way better than my personal experience with Java. Now, when Rust compiles all dependencies from the ground up it is really slow, but that's only generally one time during development or after updating dependencies.

For me, the compile times are fine, and the end product generally doesn't need as much debugging as an interpreted language that requires no compilation at all, or has minimal validation, prior to running.

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @12:42AM (#14347411)
That assumes you're using cargo and it's "fuck the package manager" approach.
Re:Two years of Rust by bluejekyll on Tuesday May 16, 2017 @02:10AM (#14347696)
Cargo is a development and build tool, and it's quite possibly the best I've ever used. I don't know of any specific reason it's "fuck the package manager".

Cargo does it's own dependency management, so I assume you mean to say that because of this, it makes it difficult to integrate into standard methods package managers use. After reading some of the email threads with OpenBSD, I do get the sense that it's complex in that situation, but isn't that because of Ports? And Ports' expectations? Most things in Ports are C, right? I haven't worked with Ports in a long time, so I don't know it very well.

If you're pre-building something and pushing a package for say dpkg or rpm, I don't see a problem. If you're packaging source, then you'll need have the rust tools installed on the host to do that, which seems obvious.

After that, I can see some debate about blessing versions of crates in the Rust ecosystem for use in the OS' package manager, but this starts to blur the lines between what the OS is guaranteeing and what is the responsibility of the build tool. Should an OS want to bless crates, cargo does have an override for crates.io: http://doc.crates.io/config.html see the 'registry' section. I believe the other options in that configuration would also be things that the package manager on the OS would want to specify as well.

I haven't done any of this myself, but would be interested in trying to help figure it out if you have specific concerns.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:14AM (#14347714)
My main pet peeve with cargo is lack of support for binary crates.

Compiling the whole world, including dependencies is big waste of time.

I already tried to play around with workspaces to see if at least crates only get compiled once.

With other AOT compiled languages I use, zero third party dependencies are compiled from scratch.

Re:Two years of Rust by bluejekyll on Tuesday May 16, 2017 @02:23AM (#14347748)
Yeah, I agree with this. This confused me when I first started using the language. I do think there could be some better options for caching or downloading precompiled packages, but I also think this has partly helped with the development effort in Rust as well. That being said, a system wide cached package repo could work, but it also has issues (looking at you Maven) so it would be interesting to figure out how to get it "right" when dealing with source packages.

This old issue discusses a bunch of this: https://github.com/rust-lang/cargo/issues/610 I couldn't find another in a brief search.

Edit: I should add that it does harken back a bit to my Gentoo days, where recompiling the world for that 10-15% architecture boost was a lot of fun, but also a waste of time in general ;)

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @02:34AM (#14347785)
> Cargo does it's own dependency management

Exactly, that's why it's a "fuck the package manager" approach, it ignores the package manager.

> If you're pre-building something and pushing a package for say dpkg or rpm

The problem is multi copies of the same dependencies everywhere adding all sorts of bloat and security issues. Not to mention introducing it's own incompatibilities.

> Should an OS want to bless crates, cargo does have an override for crates.io

That's a recipe for dll hell if I've ever heard one.

Re:Two years of Rust by bluejekyll on Tuesday May 16, 2017 @02:58AM (#14347856)
> The problem is multi copies of the same dependencies everywhere

most binaries would be statically linked and compiled, so there wouldn't be copies, but you do have a valid point of an issue with needing to upgrade an tool that was build with a static dependency that has an issue.

If I understand you, you're saying Rust, a general purpose language, with it's own build tool should do what exactly? I see that you believe it's doing it wrong, but every package manager for every OS out there does things differently, Rust can not fix this.

> That's a recipe for dll hell if I've ever heard one.

The package managers can be configured to work with Rust, and likewise Cargo can be configured to work with the various package managers, but it takes work.

I think what you want is every crate on crates.io to be packaged as an installable rlib and dylib for every package manager out there, with the cargo manifest used to generate the various package managers dependency graphs as necessary. This would probably look a lot like, or actually be an integration with, FPM.

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @03:47AM (#14348018)
> but every package manager for every OS out there does things differently, Rust can not fix this.

Exactly, it can't fix it but it tries to cover over this fact by bundling dependencies with every app.

> I think what you want is every crate on crates.io to be packaged as an installable rlib and dylib for every package manager out there

Basically, but more to the point, when a bug or security issue is fixed I don't want to rely on individual programs updating their dependencies. Let's say 10 years from now the rust version of gstreamer is widely used and a security issue is discovered, I want to be able to "apt-get upgrade" and know that it's patched. This is how things work now with the c version, but this can't be done with cargo, every app using the library has to update it's dependencies and many (particularly any corporate ones) will never update. Rust might be a boon for security but cargo could undermine the effort.

Aside from that, static linking creates a tonne of bloat, memory and disk. There is a reason windows apps are often so bloated compared to their linux counterparts.

> The package managers can be configured to work with Rust, and likewise Cargo can be configured to work with the various package managers, but it takes work.

I don't think that's good enough, if rust wants to be a systems language then it has to work with the system, not be a layer on top of it like java/.net/node. It can do this technically, but culturally it's looking more like node and less like c.

Re:Two years of Rust by kbenson on Tuesday May 16, 2017 @11:24AM (#14350277)
While I understand your point, there is a difference between something installed through cargo for use in building software (in the manner rust does, where it's generally statically compiled), and something installed through the package manager for use in running the system.

If I'm installed zlib for general system use, I want a package manager. If I'm installing a Rust compression library to be compiled into the program I'm working on, I want that to be managed by my build chain (especially since the version I'm using in my build may not necessarily match what I have installed on my system to run).

As another example, if someone makes a cook general purpose library using Rust, eventually it should be packaged up and shipped in the normal distro package format by the distro if it's useful. I wouldn't expect cargo to be the normal way to distribute software. It's the Rust equivalent of the old tar -zxvf package-1.2.3.tar.gz && cd package-1.2.3 && ./configure && make && make install. You can do it, but if you have a distro package, use that first.

Re:Two years of Rust by steveklabnik on Tuesday May 16, 2017 @12:30PM (#14350873)
> I wouldn't expect cargo to be the normal way to distribute software

To be clear, neither does the Rust team. You're exactly on point here.

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @06:49PM (#14354020)
> Next, I'll introduce you to a tool called Cargo, which will help you write real-world Rust programs.

From the getting started chapter of the rust book (which I believe you wrote?). That implies that rust can't be used without cargo right there. And I'm not seeing any libraries published as ubuntu packages.

After this conversation I thought I should expriment more with rust and it's linking options and quickly ran into an error of some sort (quite possibly a system one) trying to buils hello world with dynamic linking:

http://stackoverflow.com/questions/44012802/rustc-and-prefer...

Re:Two years of Rust by steveklabnik on Tuesday May 16, 2017 @07:06PM (#14354133)
(I did write the book, yes :) )

> That implies that rust can't be used without cargo right there.

rustc can absolutely be used without cargo, and is in larger companies that use tools like Bazel. And we're working on making this even better, see https://github.com/rust-lang/rust-roadmap/issues/12 for one of the major items of work this year.

Second, again, Cargo is a tool you use to build your software, not necessarily one you use to distribute your software. It's like the difference between Make and pbuild or a similar tool; see the parent comment about "./configure && make" vs a system package.

> And I'm not seeing any libraries published as ubuntu packages.

Debian has an entire tool, https://crates.io/crates/debcargo, which automatically re-packages a Cargo package into a .deb. Currently, they only package the Rust compiler itself and Cargo, but this work was done specifically so that programs in Rust could be included in the distro, but packaged the way distros like. They've mostly been working on that stuff; I assume by the time Buster's cut-off date happens, there'll be some stuff; I'd like to see ripgrep, personally.

I haven't used -C prefer-dynamic in a while; usually SO questions get answered relatively quickly though.

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @08:17PM (#14354534)
> Second, again, Cargo is a tool you use to build your software, not necessarily one you use to distribute your software.

The trouble is it's both. It's a build tool like make and I have no issue with that, I'll stick to make personally but to each there own. But I can't do that because It's also the primary distribution mechanism for rust libraries and even some apps. SPeaking of ripgrep, take a look at the installation section of ripgrep (http://blog.burntsushi.net/ripgrep/#installation) "cargo install ripgrep" is an installation option.

And because static compilation is also a distribution mechanism (just not for the end user) the binaries are 10 times larger than grep, not to mention a giant GPL trap for commercial users.

Re:Two years of Rust by burntsushi on Tuesday May 16, 2017 @09:04PM (#14354784)
> SPeaking of ripgrep, take a look at the installation section of ripgrep (http://blog.burntsushi.net/ripgrep/#installation) "cargo install ripgrep" is an installation option.

Please don't misrepresent my writing. `cargo install` is NOT the primary distribution mechanism for ripgrep. The installation section starts with instructions that use standard system package managers, and only then suggests installing it using cargo if you're a Rust programmer. Why did you leave that out?

You might also consider looking at the actual README of the project[1], which lists several more installation options, including using brew, chocolatey, pacman, emerge, dnf, yum and nix. There is clearly an effort to suggest that users install ripgrep using their standard system package manager.

Some of the points you've made in this thread are valid concerns, but please don't misrepresent other peoples' hard work while you're doing it. It's extremely rude.

[1] - https://github.com/BurntSushi/ripgrep#installation

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @09:29PM (#14354881)
Sorry, I didn't mean to imply that cargo was the primary distribution method, merely that it was one and that cargo has gone well beyond being a build tool. Rereading the comment I can see how you interpreted it that way. I could have been any app built, ripgrep was just the only one that came to mind.
Re:Two years of Rust by steveklabnik on Tuesday May 16, 2017 @09:21PM (#14354856)
We have resisted adding features to Cargo that would make it better for end-user distribution, and the RFC for "cargo install" made it explicit that it's a non-goal. It's for distributing stuff for Rust developers, like additional Cargo commands, not for general end-users.
Re:Two years of Rust by flukus on Tuesday May 16, 2017 @09:36PM (#14354909)
What's the policy of crates then? It's clearly being used here as a way of distributing end-user software. If node is anything to go by then this will only increase.
Re:Two years of Rust by jfoutz on Tuesday May 16, 2017 @01:56AM (#14347660)
But that's how languages do it. CPAN was my first experience with it. At development time, I need weird libraries.i hope they're ready by release time. Package managers are awesome, but sometimes, fuck them.
Re:Two years of Rust by flukus on Tuesday May 16, 2017 @02:07AM (#14347687)
Higher level languages get away with it because they are platforms in their own right, rust is meant to be a systems level language. I expect a systems level language to work with the system, not against it.
Re:Two years of Rust by jfoutz on Tuesday May 16, 2017 @02:36AM (#14347788)
I think I understand your opinion, but I'm asserting development time is wierd. Sometimes I need the bleeding edge. Sometimes I'm debugging the bleeding edge. If you're willing to stuff nightlys in artifactory, I'm willing to roll with the package manager. Realistically People aren't willing to own that process, so I grab a sane ish version, and go on with my life.
Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:16AM (#14347721)
So do you enjoy packaging code for every single OS, in its own specific way?
Re:Two years of Rust by flukus on Tuesday May 16, 2017 @02:23AM (#14347749)
Of course I don't, but I don't think it's an important aspect in any case.

I think the user experience is more important than the developer experience. Using shared libraries that are likely already in memory provides a better user experience because it's faster, more stable, more secure and uses less memory.

The cargo approach will end up with windows/node level bloat where every app bundles half an OS.

Re:Two years of Rust by AsyncAwait on Tuesday May 16, 2017 @09:20AM (#14349303)
True, but there's not a simple, unified way to maintain packages across all major platforms that does not involve having your own package manager like Cargo.
Re:Two years of Rust by flukus on Tuesday May 16, 2017 @06:51PM (#14354025)
No there isn't. That doesn't mean a rust platform has to be created that sits on top of the system.
Re:Two years of Rust by kbenson on Tuesday May 16, 2017 @07:36PM (#14354339)
Well, there is benefit to the platform, I think you've just misinterpreted it's use.

Cargo is to Rust as cpan (the client) is to Perl, as pip is to Python, and as gem is to Ruby. All those other languages also have packages provided in many distros, but the developtment tool listed that downloads and installs relevant packages is also used when appropriate. For the regular, non-developer user that needs a module to support some program, that may be never. For the developer working in those languages that needs the newest version of the package, regardless of the back-patching policy of their distro, that may be often.

Re:Two years of Rust by flukus on Tuesday May 16, 2017 @09:32PM (#14354898)
> Cargo is to Rust as cpan (the client) is to Perl, as pip is to Python, and as gem is to Ruby.

As I said, rust is meant to be a systems language, it shouldn't have an equivalent of cpan and, pip or gem because it needs to work with the system, not be yet another platform.

Re:Two years of Rust by kbenson on Tuesday May 16, 2017 @10:34PM (#14355180)
> rust is meant to be a systems language

It's meant to useful as a systems language, so was designed with certain constraints in mind. It is whatever people want to make of it. There have been plenty of instances I've seen on HN alone of people mentioning use that isn't specifically tailored for a systems language.

> it shouldn't have an equivalent of cpan and, pip or gem because it needs to work with the system, not be yet another platform.

Those are entirely orthogonal issues. Cargo works with the system just as well as tar and make. They're just binaries. You could just as easily say that traditional source tarballs shouldn't be provided because people might download the source and use their compiler to build instead of using the distro package. This is a non-issue. The only people that will even have the choice are those that chose to install the compiler (whether it be a C compiler or Rust), and even then the vast majority that actually do so will probably end up having a good reason for doing so.

Cargo is part of the build tool chain. Just because it can be used to distribute a package, and even while it probably will be used to distribute a package, that doesn't mean it's purpose is to do so, or that it's inappropriate that it exists. Any feature can be abused. You should not judge it by the abuse, but by its intended and common use.