News for hackers. Stuff that matters.
Re:Two years of Rust by sillysaurus3 on Monday May 15, 2017 @03:38PM (#14344458)
I'm still on dabbling in Rust, but I'm fairly convinced that in another few years after this Tokio churn has gotten a chance to settle down and the async patterns are more broadly refined, there won't be many justifiable reasons to not write new projects in it, whether they're as low level as a Postgres extension or as high level as a DB-backed HTTP application.

Not being hindered by the compiler telling you what you can and can't do; freeing yourself from the write-compile-debug cycle, reducing it to repl-done; etc.

Re:Two years of Rust by brandur on Monday May 15, 2017 @03:47PM (#14344536)
> Not being hindered by the compiler telling you what you can and can't do; freeing yourself from the write-compile-debug cycle, reducing it to repl-done; etc.

Yeah, I certainly understand various language trade-offs, but in my experience any of these early wins of interpreted languages come back to haunt you at significant cost.

I saw someone use the analogy of a credit card on here before: purchases are very easy to make, but have to be repaid in full, and without perfect discipline you'll be paying interest on top. Now consider most development teams (who are generally strapped for resources) like middle-class earners who don't make quite enough to pay back that balance every month. It starts to accumulate, and the owed interest compounds.

Compilers can do a lot to ensure high productivity and a good user experience: (1) be fast, (2) have great error messages, and (3) be easy to use (no makefiles or heavy build systems). Rust's compiler has learnt from the mistakes of its predecessors in other languages, and does all these for you.

Re:Two years of Rust by comex on Monday May 15, 2017 @04:39PM (#14344910)
Rust's compiler is not fast. At best it can beat C++ compilers - C++ being a language whose build times people love to bemoan - but usually it does far worse. This might change once rustc eventually gets proper incremental compilation (not the codegen-only thing that's currently in beta). Hopefully. Rust doesn't use header files, so in theory it should be possible to leapfrog C++ (at least until C++ gets modules standardized), but for now that's just theory.

Right now, I don't do much serious work in Rust, almost solely because of compilation speed.

Re:Two years of Rust by brandur on Monday May 15, 2017 @05:38PM (#14345350)
I was partly relying on the context offered by the article and my parent comment to imply that sure, Rust's compiler isn't the fastest in class, but the team has identified speed as a major outstanding problem and is working very actively to address it.

Compilers are pretty hard. Languages like C and Go are able to short circuit the problem by having a simplistic type system, but the Rust team's main option here is hard work, and so far they seem to be more than willing to engage in it.

> At best it can beat C++ compilers - C++ being a language whose build times people love to bemoan - but usually it does far worse.

Citation needed on that one. How can you even make that kind of comparison fairly?

Re:Two years of Rust by nickpsecurity on Monday May 15, 2017 @07:17PM (#14346060)
It's one of those things that's happened to so many people with so many C++ compilers on projects of any significant size that almost everyone says it. Happened to me with several where I moved from a Pascal-like language to find the compile time terribly slow even when I barely used the language. A lot of it is do to how the language's syntax, semantics, and esp templating are designed. Plenty of languages with even more flexibility compile faster than C++ due to better design.
Re:Two years of Rust by brandur on Monday May 15, 2017 @09:29PM (#14346722)
Oh totally agreed that C++'s compilation times are (quite infamously) a mess. I think that my parent was asserting that Rust's compile times are "usually ... far worse" (the "it" in the quote above is a reference to Rust).

For all I know, that might be true, but it's one of those "citation needed" type things.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:03AM (#14347676)
Personal experience.

It takes me about half an hour to update rustfmt, racer and rustsym, every time a new Rust release comes out. On a dual core with 8 GB and HDD.

On the same computer, any of my VC++ 2015/2017 builds, configured to take advantage of incremental compilation and linking, using forward classes and PIMPL idioms, with all third party dependencies already available as binary dependencies, takes around 5 minutes.

Lack of incremental compilation and cargo not being able to deal with binaries dependencies has putted me off, after all if I want slow builds I can have them already in C++ when I go template meta-programming craziness, which are not that slow when using the experimental work Microsoft is doing with C++ modules.

Also since our use of C++ is constrained to libraries used from Java/.NET/Android/iOS, the build times are usually relatively fast.

Hard to sell Rust to anyone on the team, if that means their workflow would become slower, in spite of the safety improvements over C++.

Re:Two years of Rust by MaulingMonkey on Wednesday May 17, 2017 @03:08PM (#14361779)
If my github api-fu is correct that's what, 40kloc for the rust side of things? Doesn't seem unreasonable times (vs C++) for a full rebuild on that machine - which I'd generally want to do for anything but the most trivial C++ toolchain bump too (in fact, I'm usually forced to) making a comparison against incremental builds very apples-to-oranges IMO. What's your C++ LOC/full rebuild like?

I'm used to ~100kloc of C++ taking half an hour per config+platform on a 4-6 core, 16GB+, SSD machine. Less hygenic than your codebase sounds like, but with some beefy PCHs. Toolchain updates are usually a full day affair in this context, although that's not entirely from just the compiler bump.

Of course, incremental vs full rebuilds are no contest. Rust is at least working on incremental builds now that they have MIR AFAIK. And binary cargo support would be really nice as well. As would be compiling in general.

Re:Two years of Rust by oblio on Tuesday May 16, 2017 @02:36AM (#14347792)
Well, as you said, C++ had a ton more effort poured into the toolchain, at this stage.
Re:Two years of Rust by nickpsecurity on Tuesday May 16, 2017 @12:47AM (#14347427)
Maybe I misread as I quickly moved through the thread. It does look ambiguous now. All I'll claim is horrible compile times on C++. I'm not sure where Rust is at now.
Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:07AM (#14347685)
On personal projects sadly slower than C++ equivalents.

But I do take advantage of all VC++ improvements for fast C++ compilation, even playing around with the ongoing research work for C++ modules.

Re:Two years of Rust by nickpsecurity on Tuesday May 16, 2017 @02:23PM (#14351998)
How does it compare to the free C++ compilers in building large projects like you described in other post on 30 vs 5 min?
Re:Two years of Rust by vvanders on Monday May 15, 2017 @05:32PM (#14345305)
Oh please, it's plenty fast, at least on par with javac. There's also 'cargo check' which is blazing fast.

If you're seeing very large compile time then it's a good sign that you probably want to break things into smaller crates anyway. I've been working on some pretty large stuff and compile speeds haven't been an issue(aside from the Emscripten linker, but that's not Rust's fault).

Re:Two years of Rust by hyperpape on Monday May 15, 2017 @06:21PM (#14345684)
Is this based on benchmarks? I don't have any, but I can do a clean compile of 8000 java classes (> 2 million lines) in 3 minutes on my underpowered Mac mini.

I wouldn't expect Rust would ever be as fast to compile, even if it weren't a younger language, because Rust is doing compile time optimization that Java defers until runtime. And that's ok: there may be times what Java does is better, but there are also times it's worse.

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.

Re:Two years of Rust by vvanders on Monday May 15, 2017 @06:38PM (#14345790)
Mostly gut feeling :).

To be fair my javac comparison with with Gradle + Android Studio layered on top so it may be a bit slanted in favor of Cargo/Rust. That said I've never seen a Java build environment that I'd call 'snappy'.

Re:Two years of Rust by fnord123 on Monday May 15, 2017 @07:05PM (#14345995)
Maven takes a long long time to start up, but once it's ready, javac is pretty quick.

Some Rust projects are very quick to build; but some are astonishingly slow to build. e.g. lalrpop is unusably slow (~15mins to build on 2014 Macbook Air).

I think the place here performance breaks down is liberal use of generic types in functions. e.g. AsPath<T> and AsRef<T>, etc.) where the compiler creates the function for all the different types and then tries to collapse them again later on. So one rules of thumb is to only use those in the public APIs and convert the type so it can be passed around without generics internally within a module. Or maybe that's just me trying to do some `cargo cult` heuristics (haha! puns!)

Re:Two years of Rust by wtetzner on Monday May 15, 2017 @07:21PM (#14346082)
> Or maybe that's just me trying to do some `cargo cult` heuristics (haha! puns!)

I always thought `cargo new` should have been called `cargo cult`.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:22AM (#14347739)
So better try again with straight javac, Ant and Maven.

Gradle sucks big time, why do you think Google still does talks letting angry Android developers that Gradle + Android Studio will some day be as fast as Ant + Eclipse?

http://androidbackstage.blogspot.de/2017/04/episode-64-gradl...

https://www.youtube.com/watch?v=BKRK4SvMtRk

The Android Gradle plugin being slow as molasses is a typical discussion theme at Google IO since it was introduced. Being partially written in Groovy also doesn't help.

Re:Two years of Rust by lenkite on Wednesday May 17, 2017 @11:50AM (#14359635)
Take a look at the Kobalt build system http://beust.com/kobalt/home/index.html
Re:Two years of Rust by steveklabnik on Monday May 15, 2017 @05:37PM (#14345341)
"rustc is too slow" is possibly our most commonly-heard feedback. I am glad that you don't find it onerous, but many still do.
Re:Two years of Rust by bluejekyll on Monday May 15, 2017 @07:34PM (#14346152)
I don't know... I really think it depends on the audience you're catering to. As someone who only ever deals with compiled languages, this has never seemed to be a problem.

Now, viewing this as someone coming from Python, Ruby, Node, etc., I can see compilation as being annoying. Is it really the only reason that they are disliking the language or is that just a strawman?

I wonder if too much attention is being paid to this. Now there are legitimate things we can focus on, such as making cached precompiled libraries very easy to use. This can especially be important in CI environments... This would also generally make most compilations fast.

Re:Two years of Rust by steveklabnik on Monday May 15, 2017 @07:48PM (#14346232)
> such as making cached precompiled libraries very easy to use.

This is already true today; that is, this cost is only paid the first time you compile. It's still not fast enough for people.

On my machine, a fresh build of rustc takes an hour, and small changes take 20 minutes, and even that makes it a giant pain. It's an ergonomic thing, IMO.

Re:Two years of Rust by bluejekyll on Monday May 15, 2017 @08:32PM (#14346475)
I should have been more clear; I mean a solution for many devs to pull precompiled caches, and share those for the same version of libraries... this would also benefit CI, as all CI runs to be based off this.
Re:Two years of Rust by kibwen on Monday May 15, 2017 @07:55PM (#14346262)
> a fresh build of rustc takes an hour

A bit influenced by the fact that rustc has to compile itself three times. :P

Re:Two years of Rust by steveklabnik on Monday May 15, 2017 @08:26PM (#14346437)
Sure, but as with all end-user stuff, I don't care what it has to do, just that it has to do it.
Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:25AM (#14347756)
Turbo Pascal 5.5 was compiling 34,000 lines/minute.

https://edn.embarcadero.com/article/20803

And even today Delphi 10 is quite fast.

Same applies to many other compiled languages with modules.

Re:Two years of Rust by bluejekyll on Tuesday May 16, 2017 @03:16AM (#14347909)
I haven't worked with Pascal since 1999, I remember it being a much simpler language.

And no where near as fun. Hilarity ensued when I didn't realize there was no garbage collector.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @03:32AM (#14347968)
Pascal and Turbo Pascal aren't the same thing.

Turbo Pascal was more a kind of simplified Ada than a pure Pascal, which made me look down on C when checking down the laundry list of language features of Turbo Pascal 6.0 versus ANSI C89 in 1993.

Also by 1999 no one was doing anything serious in Turbo Pascal with the last version being targeted at Windows 3.1.

Delphi 1.0 was released for Windows 95, and it did at least have some kind of GC for COM based classes.

Also Delphi 10 might not have every Rust feature, but it surely has it own set of complex language features.

Or if you prefer Ada, C#, D are also possible sources of information regarding performance of compilation toolchains, with relatively complex languages.

Re:Two years of Rust by WatchDog on Monday May 15, 2017 @05:52PM (#14345464)
Is it as fast as javac? Maybe on a line of code basis, but I imagine java is much simpler to to implement incremental compilation with. Since sources map pretty much 1 to 1 with classes, you mostly only need to recompile the class that changed.
Re:Two years of Rust by swsieber on Monday May 15, 2017 @10:19PM (#14346912)
Unfortunately, it's not quite that easy since java inlines constants, plus you have to account for package protected, inherited methods, etc. that you don't have to implicitly import. But really, it's the constants that make incremental compilation slower...
Re:Two years of Rust by amorphid on Monday May 15, 2017 @10:21PM (#14346923)
When you compile Java from the command line, is the compiler smart enough to not recompile files that haven't changed? Or is that an IDE feature?
Re:Two years of Rust by cytzol on Tuesday May 16, 2017 @05:26AM (#14348365)
javac itself doesn't do any incremental compilation and will happily compile over your .class each time (though you can tell it not to; see http://stackoverflow.com/q/8271282)

Build tools like Maven and Gradle, as well as IDEs' internal build tools, will be smart and compile only the changed files.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:10AM (#14347697)
I wish it would be on par with javac, but my experience compiling rustfmt, rustsym and racer tells me otherwise.

Also a bit disappointed when compared with other languages that support modules, specially the ones whose toolchains support binary dependencies.

Not everyone has a high end development workstation.

I am however confident the experience will eventually improve.

Re:Two years of Rust by kibwen on Monday May 15, 2017 @07:50PM (#14346240)
> but usually it does far worse

Cite a source? This isn't my experience at all, Rust is still way faster at compilation than C++ on average. The advantage that C++ currently has is ccache which helps avoid needless rebuilds (which pairs well with C++'s smaller compilation units relative to Rust); building this behavior into the compiler is part of what the incremental compilation initiative is addressing.

Re:Two years of Rust by lumpypua on Monday May 15, 2017 @08:02PM (#14346300)
https://michaelfairley.com/blog/i-made-a-game-in-rust/

> It consists of ~7700 lines of Rust

...

> Compile times with Rust are Not Great. This is easily my single biggest gripe about Rust right now. The build for A Snake’s Tale takes 15+ seconds, which makes iterating rather tedious. The current incremental compiler work also doesn’t seem to make the build for A Snake’s Tale’s codebase any faster.

Re:Two years of Rust by kibwen on Monday May 15, 2017 @08:45PM (#14346527)
That compile time is Not Great, but 15 seconds for 7700 lines of code isn't even close to "far worse than C++". :P If incremental compilation is showing no benefits whatsoever, then I'm guessing that time is largely attributable to linking (and I tend to doubt that 7700 lines of code is counting the basic third-party libraries that are required to create a crossplatform GUI app (but I'd love to be surprised!), which will contribute to linkage time... LLD please!).
Re:Two years of Rust by stevedonovan on Tuesday May 16, 2017 @02:44AM (#14347814)
For a full rebuild, that's a reasonable C++ build time for a project of this size. But full rebuilds are not representative, if the project is composed of many independent compilation units. The compilation unit in Rust is the crate, which is an exe or a library, so currently the best strategy is lots of little crates, which is not so ergonomic (heh) with Cargo.

Actually, the compiler isn't the bottleneck - most of the time is LLVM codegen. So 'cargo check' is fast - the miri MIR interpreter likewise.

Re:Two years of Rust by sillysaurus3 on Monday May 15, 2017 @04:35PM (#14344891)
Yeah, I certainly understand various language trade-offs, but in my experience any of these early wins of interpreted languages come back to haunt you at significant cost.

If you understood the wins of untyped languages, you'd be aware that this is often the most optimal path for a startup to take. Get features done now + fix them later is, in hundreds of cases, the way that startups win.

It's also a win for people who come home from work and want to get features done on their side projects rather than write perfect code.

It's beginning to get tiresome to continually hear the Rust community go on and on about how amazing Rust is and say, with a straight face, that eventually there will be no reason to write anything in not-Rust. Are you serious? The hubris is off the charts.

If your language doesn't have a REPL, your language is less productive. Deal with it.

That said, the engineering tradeoffs are often a win. I love Rust; borrow checking is frankly incredible. But it's important to keep perspective.

Re:Two years of Rust by zzalpha on Monday May 15, 2017 @04:47PM (#14344957)
If your language doesn't have a REPL, your language is less productive. Deal with it.

Oh hardly.

As someone who's developed software in Perl, Python, C, Java, C#, Haskell, and a few others besides, a REPL is the one thing I use the least. I've honestly never understood the obsession with it.

Is a rapid compile-run-debug cycle important? Absolutely. If I want to test something in isolation, being able to rapidly turn out a UT to prove my code does what I think it does is incredibly important.

But a REPL is a nice-to-have. Nothing more. Treating its absence as some fundamental black mark on a language is completely absurd.

Re:Two years of Rust by derefr on Monday May 15, 2017 @06:08PM (#14345577)
> I've honestly never understood the obsession with it.

The true key to understanding REPLs is their role in consuming third-party libraries. While languages both with and without REPLs will have well-used packages in their package ecosystems that are well-documented; languages with REPLs will also manage to have well-used, poorly-documented packages: packages whose "documentation" consists only of the de-facto ability to reflect on the API in a REPL, doing the moral equivalent of exploring a filesystem using cd(1) and cat(1), until you figure out what functions—and what arguments—combine to produce an acceptable result for your use-case.

That may sound like a bad thing, but it's not! Those packages are packages that wouldn't exist otherwise; they're marginal packages, packages which people wouldn't have had time to write if they were required to also document them properly enough to make use of them without a REPL. They're needs being satisfied, that would otherwise—given the stricter requirement of useful API documentation—be going un-met.

If you look at e.g. Ruby's gem ecosystem, there are tons of packages that have more than a million downloads, and either no docs or awful docs. How? Because Ruby is extremely amenable to exploring APIs through a REPL. You take a module or class, ask it what its children are, what its class methods are, what its instance methods are. Find a class with instance methods that sound right, attempt to instantiate it. Figure out you can't do that, look around the class methods for something that sounds like a factory method. What arguments does said factory-function take? Well, feed it some at random and see what error you get. Etc.

Re:Two years of Rust by zzalpha on Monday May 15, 2017 @06:36PM (#14345782)
For (most) languages lacking a REPL, it's very similar. Instead of a REPL you write compiled unit tests and/or test programs to poke around at the API.

For languages with a reasonably sophisticated IDE, use the IDE itself to jump straight to the class/function declarations to understand the surface area of the API, and jump to the decompiled code for the implementation of those functions if you're the type to want to understand the machinery.

Other languages (like Haskell) may not have the IDE support but attempt to solve the problem with auto-generated docs so you can at least see the surface area of the API and can start prodding it.

Re:Two years of Rust by derefr on Monday May 15, 2017 @07:03PM (#14345971)
> What's your experience level with other languages?

~15 years experience across C, ARM assembler, Javascript, Lua, Ruby, Python, Erlang, Go, and Rust. Mostly doing Elixir these days.

Admittedly, I've never used an IDE; I write all my C in vim.

> ...you write compiled unit tests and/or test programs to poke around at the API.

That assumes you can get your tests to compile; or that the compilation errors are at-all helpful when they don't. If you've got a library that

1. ships as a binary blob + header files, and

2. most of its functions take handles to structs that are declared opaquely in the SDK headers; and yet

3. nothing you do with the badly-documented "create handle" parts of the API is giving you a struct that the "consume handle" parts of API will do anything with but crash...

...then you'll really wish that you had a REPL; or rather, a language runtime that enforced some level of introspect-ability on everything, so that a REPL could show you what's in the struct and whether your calls so far have failed to touch some obviously-necessary-to-fill-in part of it.

Without such support, you will have to rely on reading the decompilation results of both ends of the API to figure out what's really going on.

Re:Two years of Rust by zzalpha on Monday May 15, 2017 @09:38PM (#14346762)
or rather, a language runtime that enforced some level of introspect-ability on everything

And now we get to the real meat of it.

It's not a REPL you want.

It's reflection.

It just so happens that the latter is frequently paired with the former.

And I agree, that feature, which separates C#, Java, Ruby, Perl, Python, etc, from legacy languages like C make them significantly easier to use as a developer as the compiler, debugger, and IDE can do a much better job.

But as a feature it's orthogonal to a REPL.

Re:Two years of Rust by derefr on Monday May 15, 2017 @10:09PM (#14346869)
Reflection isn't orthogonal to a REPL; it's synergistic with a REPL. When you have a static language, yes, REPLs don't add much; reflection by itself is all you need and an IDE will suit you fine.

But when you are working in a language with runtime code generation—one where objects can build themselves new runtime-native function handles in response to messages—then a REPL will be able to do things for you that an IDE cannot†.

A REPL in a dynamic language (that takes advantage of its dynamicity) can be used to "explore" down CORBA/DBUS object trees; or fluently walk REST or SOAP endpoints without needing pre-baked WSDL descriptors to guide you to them. Heck, an Erlang REPL can hot-upgrade remote nodes. :)

† Or, at least, not a traditional IDE. You would need an IDE connected to a "live session" of your project—essentially a hybrid IDE-REPL. (Examples: Light Table; Emacs' CIDER extension for Clojure.)

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @08:02AM (#14348884)
Lisp, Smalltalk and Mesa XDE at Xerox PARC are the genesis of what an IDE is supposed to be.

Two dynamic and one static languages.

Re:Two years of Rust by photojosh on Monday May 15, 2017 @08:15PM (#14346368)
> then you'll really wish that you had a REPL

Yes. I write roughly equal amounts of C (microcontroller firmware) and Python (overall system control, running on embedded Linux).

I absolutely wish I had a REPL for C. When implementing with a new library in Python, I'll usually use iPython to explore it, and if I need to run a decent amount of data through, I'll use a Jupyter notebook. I'd put the difficulty of grokking a C library somewhere between 10x and 100x harder.

Re:Two years of Rust by yorwba on Monday May 15, 2017 @11:33PM (#14347180)
I use gdb as a C REPL. You attach it to a binary that has the functions you need, then you can use them with the `p` (or `print`) command. Loops and new function definitions are not possible, but sometimes it's still good enough.
Re:Two years of Rust by RhysU on Tuesday May 16, 2017 @07:54AM (#14348858)
Gdb as REPL is a nice trick. Beaker Notebook might give the notebook parent wants for C work.
Re:Two years of Rust by photojosh on Wednesday May 17, 2017 @09:09PM (#14364155)
Thanks. It won't since all my C work is embedded and mainly systems programming rather than algorithms. But I'll keep it in mind for the next time I have to translate my Python explorations over to C for production.
Re:Two years of Rust by photojosh on Wednesday May 17, 2017 @09:04PM (#14364131)
Good point. I've only been working with AVRs for a few years since I've been at this job, but looks like it might be doable. Thanks for the tip.
Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:49AM (#14347829)
That is how I once developed a B+ Tree library for low level disk blocks back in 1996, it was quite helpful tracking down how the nodes were being used.
Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:47AM (#14347821)
C has had REPLs since the 90's, one just needs to search for them, and eventually buy them.

They were quite common advertising in The C User's Journal and Dr. Dobbs.

Re:Two years of Rust by Manishearth on Monday May 15, 2017 @07:18PM (#14346066)
Note that with strong typing this is less of an issue -- with Rust you can just go to http://docs.rs/<nameofcrate> and navigate the structured docs. They may lack explanatory text, but you can click around them and search and it's overall much nicer than fiddling around in a REPL.

(Still, doesn't fit all use cases of a REPL for this. REPLs are especially nice for when you want to fit together highly generic APIs)

Re:Two years of Rust by curun1r on Monday May 15, 2017 @08:04PM (#14346309)
Also, cargo doc --open for offline version of docs.rs :-)
Re:Two years of Rust by derefr on Monday May 15, 2017 @07:30PM (#14346130)
True; but also, "strong typing" on its own isn't a panacea for guidance; unless you're writing Coq or Agda, the API functions you're calling are still going to have preconditions that are not encoded in the type signature, so you're still (partially) reliant on having either good docs or a REPL [or clumsy REPL-equivalent, like exploratory unit tests] to inform you of those preconditions.

And if you are writing Coq or Agda—well, you certainly don't need a REPL at that point. The code writes itself. ;)

Re:Two years of Rust by Manishearth on Monday May 15, 2017 @08:55PM (#14346564)
Yeah, like I said, doesn't fit all use cases, but it does fit the primary one.
Re:Two years of Rust by oblio on Monday May 15, 2017 @06:18PM (#14345661)
Many languages have good IDE support, which is basically REPL on steroids.
Re:Two years of Rust by derefr on Monday May 15, 2017 @06:40PM (#14345801)
True, though "good IDE support" in the sense you're talking about (i.e. being able to discover an API through the IDE) mostly relies on strong typing in the language. (Non-inferred) type declarations are their own form of documentation, with a similar effect on likelihood of a "marginal" ecosystem package getting written.
Re:Two years of Rust by sillysaurus3 on Monday May 15, 2017 @05:03PM (#14345095)
I tend to agree, but being able to have a REPL at all is a symptom that your language is capable of an extremely fast compile-run-debug cycle.

In other words, if you can't implement a REPL, that's the definition of "less productive language." It's not about the REPL itself but the capability of implementing one.

Think about it like this: On your list of languages, which of them would you say is most productive? It depends on the context, certainly: libraries, familiarity, etc. But let's assume the languages had identical ecosystems, and that you were competent in all of them. Which of them would take the smallest amount of time to write your feature?

That'd probably be Python, Haskell, or even Perl. It seems very difficult to argue that Rust would top them. And the reasons why this is might be true are worth examining.

Here's another aspect. Is the Rust community claiming that the entire history of computing has lead up to this point, where Rust exists, and now nobody needs to write anything in not-Rust? Are people 200 years from now going to write Rust and nothing else? How about 20? 2?

It becomes very difficult to argue that your programming language is the lingua franca of the future. (And that's probably true for every language, not just Rust.)

Re:Two years of Rust by derefr on Monday May 15, 2017 @06:31PM (#14345744)
Why must productivity be measured in "smallest amount of time to write your feature"? Why not in "smallest Total Cost of Ownership [in man-hours] of the feature over the project lifecycle"?

Some projects are written as explorational prototypes or MVPs. I don't think anyone is saying Rust is much good for those.

But (numerous) other projects are written as "the first real Quality implementation of [well-known problem], using a decade's experience with other implementations." Much of the common software we use—{server daemons (HTTP, SSH, DNS...), parsers and encoding libraries (for XML or JSON; JPEG or PNG; MP4 or MKV...), databases, load-balancers, distributed queues, ...}—fits this paradigm.

If you're writing Nginx, or Redis, or djbdns, you aren't "adding features" out of some agile user-story kanban; you're carefully implementing a small, curated set of well-known, well-understood features, with much research done to ensure that you arrive at the best and least fraught implementation, the one that will make people prefer your software for its quality and reliability and set-and-forget nature.

Rust is for that kind of software. (Which makes sense, given that Mozilla's Servo rendering engine also has the goal of being that kind of software.)

Re:Two years of Rust by cwzwarich on Monday May 15, 2017 @07:51PM (#14346249)
> (Which makes sense, given that Mozilla's Servo rendering engine also has the goal of being that kind of software.)

Web browsers are not that kind of software. The web is evolving much faster than any of the other things you mentioned. New features get proposed every year, and you just have to deal with it and implement them, even if they complicate the implementation of the browser. Even if you cut that off, you still have to deal with the horrific mess that is the cumulative total of past web-related decisions.

Re:Two years of Rust by derefr on Monday May 15, 2017 @08:00PM (#14346285)
A rendering engine is not, itself, a web browser. (You might be thinking of a higher-level component, like Chromium's Embedded Framework? Not the same thing as a rendering engine.)

There's certainly a layer of a rendering engine—the part that translates a CSSOM into rendering pragmas—that changes a lot over time. But rendering the resulting pragmas itself doesn't change much, and features requiring new pragmas come about remarkably slowly.

Re:Two years of Rust by cwzwarich on Monday May 15, 2017 @08:17PM (#14346379)
I definitely know the difference between a browser and a browser engine; I worked on both WebKit and Servo. There's much more to a browser engine than rendering alone, and rendering isn't even the most complicated part of a browser engine. Outside of rendering and JS there's a steady stream of new DOM APIs, and that's the part that is similar to the "agile user-story kanban".
Re:Two years of Rust by derefr on Monday May 15, 2017 @09:44PM (#14346781)
Yes? It sounds like you're agreeing with me, and disagreeing with your own GP comment. Or maybe I misunderstood the point of your GP comment—it sounded like you were trying to use some sort of metonymy to equate Firefox/browsers in general with Servo, as an implicit counterargument to my GGP post in the sense of "it'd be bad to write a browser in Rust for [reasons you gave]; a rendering engine is part of a browser; a rendering engine thus has the same lifecycle as the browser itself; and thus, a rendering engine is not actually a good example of a good use-case for Rust, despite Mozilla's ambitions. QED."

Clearly, though, you know what a rendering engine is, so I'm not sure what your argument in the GP post was. Was it just a tangential statement (i.e. "rendering engines are well and good, but it'd be silly to write the browser itself in Rust, for [reasons]"), rather than a rebuttal...?

Re:Two years of Rust by kibwen on Monday May 15, 2017 @08:02PM (#14346304)
So we're in agreement that we should reimplement Chrome in Perl, then. :)
Re:Two years of Rust by kbenson on Monday May 15, 2017 @09:02PM (#14346608)
As a Perl programmer I'm not sure whether to laugh or cry. ;)
Re:Two years of Rust by nickpsecurity on Monday May 15, 2017 @07:23PM (#14346090)
"Why must productivity be measured in "smallest amount of time to write your feature"? Why not in "smallest Total Cost of Ownership [in man-hours] of the feature over the project lifecycle"?"

In the case of startups, their goal is to sell out way before the maintenance phase of the lifecycle. So, it doesn't really matter to them so much as quickly getting out working features. In other cases, esp long-lasting endeavors, then this is a good point to consider.

Re:Two years of Rust by kbenson on Monday May 15, 2017 @09:09PM (#14346640)
> In the case of startups, their goal is to sell out way before the maintenance phase of the lifecycle.

Or grow so quickly that replacing most the legacy code from a year or two ago is not a significant hurdle at their new size.

In this vein, I wonder if there's actually a third path that might be better than both. Using a low-level but fairly expressive and strongly typed language but very loosely, such that it allows you to iterate fact but with less performance, and you can come back later and replace chunks as needed, but with the same language. I don't have any real experience with that, and I could see it going either way for a number of reasons, but it seems like we have more languages that might fit that criteria now (or at least they are more popular now) than we have previously.

Re:Two years of Rust by tatterdemalion on Monday May 15, 2017 @05:21PM (#14345227)
> Is the Rust community claiming that the entire history of computing has lead up to this point, where Rust exists, and now nobody needs to write anything in not-Rust? Are people 200 years from now going to write Rust and nothing else?

Let's be clear - the person who said there'd be no reason to write in anything else is an enthusiastic Rust user, but they don't work on Rust & don't represent "the Rust community." They were speaking from their own experience, based on their own balancing of the trade offs as a user. Presumably a REPL doesn't rate very highly for them.

However, the reasons we don't have a REPL are mainly two: the compiler isn't architected for it and code doesn't compile fast. The solutions are:

* Re-architect the compiler to support incremental code input. This is pretty similar to what we need to support IDEs (which we're working on), so possibly this will solve the problem.

* Get a reimplementation of the backend which is a JIT interpreter instead of LLVM, which takes up most of our compiletime. Work is underway on a project called miri, though it isn't officially supported right now.

* Make the typechecking part of the compiler faster. This is underway through a project called chalk.

In other words, a REPL is not impossible, it just isn't a top priority right now. There are other lacking tools that we're working on - IDE integration and auto-formatting for example - maybe after those are done it will be the top of the docket.

Re:Two years of Rust by lacampbell on Monday May 15, 2017 @06:10PM (#14345596)
I'm no compiler writer, but presumably rust has some form of internal IR it compiles to before it gets turned into LLVM IR. Why not just write an interpreter for that layer and be done with it? The point of a REPL to me is to be responsive, not to run code amazingly quickly.
Re:Two years of Rust by steveklabnik on Monday May 15, 2017 @06:31PM (#14345746)
"Miri" is named such because Rust's IR here is called MIR.

It's a relatively recent addition though.

Re:Two years of Rust by tatterdemalion on Monday May 15, 2017 @08:04PM (#14346308)
Yes, thats what the second point is.
Re:Two years of Rust by sillysaurus3 on Monday May 15, 2017 @05:39PM (#14345355)
Let's be clear - the person who said there'd be no reason to write in anything else is an enthusiastic Rust user, but they don't work on Rust & don't represent "the Rust community."

Respectfully, the community has become increasingly vocal, and it's getting hard to separate the enthusiasm from realism. It's embedded in every HN thread. That's a good problem to have, but it can be a bit repellant to people who aren't Rust converts.

Thanks for the breakdown and future roadmap. I hope the compile times can be kept to a minimum in order to avoid C++'s fate.

Re:Two years of Rust by kibwen on Monday May 15, 2017 @08:05PM (#14346317)
The community is in every thread because the people here were HN users before they were Rust users. Look at how old my account is; I haven't quite been shilling Rust since December 2011. :P
Re:Two years of Rust by steveklabnik on Monday May 15, 2017 @08:27PM (#14346442)
And I've got a thousand days on you :p
Re:Two years of Rust by Ygg2 on Monday May 15, 2017 @11:03PM (#14347082)
Except one of tenets of Rust community is don't be a language zealot. Don't advocate for rewriting everything, etc.
Re:Two years of Rust by zzalpha on Monday May 15, 2017 @05:15PM (#14345192)
Think about it like this: On your list of languages, which of them would you say is most productive?

Define productive.

Are you measuring raw lines of code generated?

Or are we measuring amount of production-ready code?

My bet: with an experienced, diligent developer it's a wash. My gut says what you lose in a slow code-execute cycle of static, compiled languages you gain in lower defect rates from compile-time checks. Conversely, what you gain in a dynamic language, you lose in errors caught at run-time.

At that point I'd select for languages that are simpler with fewer surprising semantics (crossing Perl and Javascript off the list), with more built-in run-time and/or compiler safety (knocking things like C off the list). I generally also prefer compile-time safety over run-time safety, as I'd rather find problems on my workstation than in the field because I missed testing a codepath.

Re:Two years of Rust by kbenson on Tuesday May 16, 2017 @01:53PM (#14351696)
> with fewer surprising semantics (crossing Perl and Javascript off the list)

Actually, I think Perl has fairly few surprising semantics after you learn the major ones. The real problem is that the major one (or specifically the major one, context) is somewhat hidden in normal C-like usage until it jumps out at you and confuses you. Once you understand what it is, it's not all that surprising (but there are a few annoyances with it that still persist and cause problems). You can write Perl that looks almost exactly like C 95% of the time, but that 5% where it matters makes people that do this very confused. There are, of course, other parts of the language that are poorly chosen, but I maintain there are actually far less of them than many people seem to think.

As for JavaScript, I still can't get over all the different ways to check for equality and null or undefined. I understand a good portion of that is because I never have to use JS enough to become truly proficient, and some if it is just poor design.

Re:Two years of Rust by tannhaeuser on Monday May 15, 2017 @06:10PM (#14345595)
> It's not about the REPL itself but the capability of implementing one.

That definition excludes any bare-metal language, and use cases where you want to take advantage of cheap low-level memory protection features such as No-Execute bits. For me, a more interesting benchmark would be how well Rust fares in implementing the runtime of a higher-level language.

Re:Two years of Rust by sametmax on Thursday May 18, 2017 @05:30AM (#14365902)
As a Python dev with 12 years of experience, I still use the REPL every day.

When I wonder how something works or if I need my memory to be refreshed, I just fire up jupyter console and test quickly the code. I don't open the doc or search on the net. I have the live result immediatly.

When I want to debug my web server, I drop a REPL in the server and play with the code. It's more efficient that just debugging, because I can actually modify the code live and see what happens.

When I need to understand a format and how to manipulate / tranform data, I use the REPL (or jupyter notebook) because it's the most natural way to do it.

I don't know how much Python you have done, but you have been missing one of the greatest tool of the ecosystem.

It's like saying you don't see that much the benefits of an IDE for refactoring in Java. "yeah it's cool but how much do you use it hu ?".

Re:Two years of Rust by zambal on Monday May 15, 2017 @05:40PM (#14345372)
The usefulness of a REPL depends a lot on the language/interpreter/vm. In Erlang and Elixir the REPL is more than nice to have. Being able to connect to a production node and peeking around what is happening can be very valuable.

I guess it's one of those things that's imho hard to appreciate if you never experienced it.

Re:Two years of Rust by zzalpha on Monday May 15, 2017 @05:44PM (#14345413)
The usefulness of a REPL depends a lot on the language/interpreter/vm. In Erlang and Elixir the REPL is more than nice to have. Being able to connect to a production node and peeking around what is happening can be very valuable.

That's called a remote debugger, and it's hardly unique to languages supporting a REPL.

Re:Two years of Rust by dwaltrip on Monday May 15, 2017 @05:04PM (#14345106)
Just because you don't understand the benefits other people get from a REPL doesn't mean they don't exist.
Re:Two years of Rust by zzalpha on Monday May 15, 2017 @05:10PM (#14345154)
Just because there are benefits, doesn't make it a deal-breaker.
Re:Two years of Rust by dwaltrip on Monday May 15, 2017 @05:19PM (#14345212)
I didn't say it was a deal breaker?

Your post came off as implying REPLs don't have serious benefits for anyone, which felt a bit presumptuous to me.

Re:Two years of Rust by zzalpha on Monday May 15, 2017 @05:21PM (#14345234)
Yup, that's fair.

BTW, I actually stand by your interpretation. I challenge anyone to demonstrate significant productivity gains (as measured by number of lines of tested, production code written) that can be attributed to the availability of a REPL (which was the claim of the poster I was replying to).

I honestly don't buy it. I believe it's a very nice tool for learning a new language, and maybe for exploring an existing codebase, but I can't envision a workflow where a REPL provides significant productivity gains for an experienced, professional software developer that aren't realized in other ways (e.g. writing unit tests).

Re:Two years of Rust by dang on Monday May 15, 2017 @10:41PM (#14347001)
You're demanding the impossible here and elsewhere in the thread. Asking for the impossible is maybe ok, demanding it not so much.

No one can demonstrate productivity gains because productivity can't be measured. Lines of code can, and those are often a bad thing. Some of our most productive efforts make programs smaller.

Re:Two years of Rust by zzalpha on Monday May 15, 2017 @11:30PM (#14347170)
No one can demonstrate productivity gains because productivity can't be measured.

So then the OP shouldn't have made the claim. It ain't my job to prove it. :)

That said, I fundamentally disagree with the idea that one can't measure developer productivity. I agree that there are many potential measures, all of which have the potential to be flawed or distorted. But the idea that the productivity of a developer can't be measured at all is something I've never heard anyone seriously claim.

Re:Two years of Rust by dang on Tuesday May 16, 2017 @01:02AM (#14347476)
The fact that no one has come up with any plausible way of doing this is so commonly observed as to be a cliché. See for example https://martinfowler.com/bliki/CannotMeasureProductivity.htm....

> So then the OP shouldn't have made the claim

Come now, it was you who moved those goalposts and you moved them half a field or more. OP claimed REPLs "have benefits". Your response was (paraphrased) "demonstrable measurement of productivity improvement or GTFO". That sort of ante-upping just isn't that nice for good conversation, and certainly not when you're demanding a standard none of us can meet about anything.

Re:Two years of Rust by burntsushi on Tuesday May 16, 2017 @08:36AM (#14349050)
Not sure I buy that. I think you need to go further up the thread chain to see the OP on this[1], which, to be fair to your interpretation, wasn't written by dwaltrip:

> If your language doesn't have a REPL, your language is less productive. Deal with it.

That seems exactly like the kind of claim that everyone should view with a healthy dose of skepticism, and I think zzalpha's initial response[2] hit that right on the nose.

[1] - https://news.ycombinator.com/item?id=14344891

[2] - https://news.ycombinator.com/item?id=14344957

Re:Two years of Rust by zzalpha on Tuesday May 16, 2017 @09:53AM (#14349567)
Eh, here Fowler just falls into to the trap of the Perfect Solution fallacy.

I repeat: there are no perfect measures of productivity. But there are imperfect measures that have some utility. The idea that we cannot measure at all because we cannot measure perfectly is simply untrue.

In this case we could, for example, take 1000 individuals with similar years of programming experience and given them two languages and a non-trivial problem to solve and see how long they take to come to a working and correct solution.

Is that perfect? No. But it's still something that's measurable. Do that with a reasonably large sample and you can probably start making inferences.

Our industry suffers from a horrible lack of concrete, scientific studies to back common wisdom. We would all benefit from ignoring Fowler, here, and getting down to the nuts and bolts of finding solutions to that problem. Until we do, while we'll have lots of fun having pointless debates on HN that cannot be resolved because we have no real data, the industry simply won't move forward.

Re:Two years of Rust by dwaltrip on Monday May 15, 2017 @11:48PM (#14347242)
One example: REPLs can occasionally be a great way to implement​ helper methods or other well isolated functionality. I understand you might argue unit tests are better for this, but I would very strongly disagree they are better in every situation.

Unit tests provide some additional benefits, but are a heavier approach with a slower, clunkier feedback loop. There are times when those additional benefits are not worth the added cost. Unit tests are also additional code that must be maintained.

Re:Two years of Rust by goatlover on Monday May 15, 2017 @05:56PM (#14345495)
Lispers might be able to meet that challenge.
Re:Two years of Rust by nickpsecurity on Monday May 15, 2017 @07:27PM (#14346116)
I could probably have countered it, too, in the same language during the challenge back when I used it. I found the incremental, per-function compilation feature reduced compilation time of most changes to a fraction of a second. Most of time in programming is spent thinking, tweaking, debugging, dealing with 3rd-party libs, etc. I don't think a difference in the source-to-execution part of under 1 second is going to make a big deal.

It's high-speed iteration of code one is exploring that makes both REPL's and incremental compilation superior for productivity to full compilation.

Re:Two years of Rust by mcorbin on Monday May 15, 2017 @06:08PM (#14345580)
Try Clojure.
Re:Two years of Rust by wtetzner on Monday May 15, 2017 @07:31PM (#14346137)
At one point I wrote Clojure for my day job. I think having a REPL is actually more useful for untyped languages, especially Clojure, where most data "types" are maps/lists. By exploring in the REPL, you can get a good feel for what kinds of data a function works with.

In a statically typed language, a REPL can still be useful, but the gains from it are less than you'd get with an untyped language. It's easy to see what kinds of data a function works with by just looking at the types. There are exceptions of course, like when the type is very complicated, it can be helpful to see some examples of actual values of the type. And I suppose that's why languages like Haskell and OCaml have REPLs.

Re:Two years of Rust by fnord123 on Monday May 15, 2017 @07:23PM (#14346093)
That's hardly fair. Clojure is unusable without having a REPL already loaded.

    $ time lein run 
    Hello, World!

    real	0m5.683s
    user	0m5.981s
    sys	0m0.557s
Re:Two years of Rust by zzalpha on Monday May 15, 2017 @06:13PM (#14345623)
I have.

That's not even the beginnings of a useful reply. :)

Give me a highlight of your normal day-to-day with the language. What, exactly, does the REPL offer you that provides significant productivity gains that can't be had any other way?

Because clearly I've missed it.

And it should be pretty easy for you to describe if it's that common and/or obvious.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:45AM (#14347816)
I love using a REPL, but I kind of agree with you.

I happen to use more often the IDE's graphical debugger than the REPL.

Still Visual Studio has had immediate mode (aka REPL) since VB days, followed by .NET support.

Re:Two years of Rust by kibwen on Monday May 15, 2017 @07:57PM (#14346271)
> It's beginning to get tiresome to continually hear the Rust community go on and on about how amazing Rust is and say, with a straight face, that eventually there will be no reason to write anything in not-Rust. Are you serious? The hubris is off the charts.

Please point to a single place where anyone has ever said this. We have never positioned Rust as an end-all be-all language: it's a language that deliberately makes compromises in order to excel at a niche.

Re:Two years of Rust by bluejekyll on Monday May 15, 2017 @07:39PM (#14346179)
> If your language doesn't have a REPL, your language is less productive

Am I the only one who sees this as pure BS? Some people like REPL's, and that's cool. But not everyone. I find it utterly annoying that in any REPL I've ever used I first have to import (or similar) the libraries I want access to in that repl environment. You end up generally writing a file to do the imports for you, or cutting and pasting.

With all that effort I almost always find it easier to just write a test-case, even in languages with a REPL. At that point I have a repeatable and testable piece of code that can be run, with almost zero error due to the REPL environment not being setup properly.

Re:Two years of Rust by nickpsecurity on Monday May 15, 2017 @07:22PM (#14346086)
"If your language doesn't have a REPL, your language is less productive."

I think what you really want here is fast compiles and iterations. You can do that without a REPL if using a language that compiles ultra-fast. Industrial BASIC's I used a long time ago compiled in a split second with me seeing the results immediately. Wirth-style languages tend to be able to do that. I hear Go compiles really fast. The wait doesn't really matter at that speed. Highly-optimized, slower compiles and tests can run overnight in background on dedicated machine, too.

Re:Two years of Rust by brandur on Monday May 15, 2017 @05:22PM (#14345235)
> It's beginning to get tiresome to continually hear the Rust community go on and on about how amazing Rust is and say, with a straight face, that eventually there will be no reason to write anything in not-Rust. Are you serious? The hubris is off the charts.

So a few considerations here: (1) I really have no connection with the Rust community aside from curiosity, so it's quite dishonest to project my opinion onto all of them, and (2) this is very much my personal opinion.

---

I'd still defend the position though. Every language has merits, but especially for a lot of the older ones, there are so many accumulated problems that it's worth considering newer languages just because they're learned so much for the mistakes of their predecessors. For example, I've been doing Ruby for quite a few years now:

* Having so few constraints on implementation (e.g. duck typing) was an interesting concept, but time has proven it to be a nightmare maintainability. It buys you a little early productivity, but any honest person with a huge Ruby codebase can tell you that it's a liability.

* The only way to get truly good performance is to write a C extension. The language's whole implementation and performance-sensitive libraries are all C. Contrast this to modern languages where it's an embarrassment if your compiler is _not_ written in the language itself (Rust, Go, Swift, etc.).

* Core build infrastructure (Bundler) and environment management (rbenv) is maintained separately from the language. It works fine, but the reason it's not more core is not because it's better that way, but because the language's original designers didn't realize they'd be necessary, so they had to be developed separately. This has the effect of making the whole toolchain complex and hard for beginners to understand because none of it is integrated.

* The interpreter starts out faster than a compiler, but it breaks down fast. Codebases in the 100,000s of lines or more will take on the order of 10-100 seconds to start up, and the only way to get back to a fast edit-compile-debug loop is through tricks like Zeus. After you resort to that, unreliable runs and weird loading problems become a part of common life.

These aren't small problems. Also, I'm picking on Ruby here, but you could drill into a lot of existing languages and find flaws that are roughly on this level (JS/Python/C++/Erlang are easy, but even fan favorites like Haskell and Scala have pretty serious ones). Newer languages have their problems too, but rarely anything on this sort of existential scale.

We should stop pretending that all languages are equal with their own share of upsides and downsides. Given decades of language building, it would be disappointing if lessons hadn't been learned. Luckily this isn't the case.

In terms of what we write new projects in given a few years, there are other good contenders, but like I said above, I think that Rust has nailed a performance/safety/productivity/ecosystem compromise that's quite a bit above and beyond most of anything else.

Re:Two years of Rust by goatlover on Monday May 15, 2017 @05:59PM (#14345517)
But do you think the Go community agrees with this, just to name one of the popular newer languages? It's nice that Rust is doing well, and more power to the community. But there is an entire world of programming language communities out there that might not agree with the assessment that Rust is the future for them.

Anyway, I was around for this kind of talk when Java was new and shiny, and there were people in the Java community claiming that Java was the future for programming, and any languages in the future would target the JVM or be phased out. That didn't happen, even though Java did well for itself.

What's really telling is that Java didn't replace C/C++, despite all the hype back then. Those two languages remain widely used.

Re:Two years of Rust by sqeaky on Monday May 15, 2017 @06:22PM (#14345693)
Depending on who you ask Java did replace everything. Consider the Tiobe Index [1]. Java Beats out everything, including C and C+++ when added together. All three are growing, but not nearly as fast as everything else is growing to the point it looks likes they are shrinking.

There is an absolutely enormous amount of Java out there.

https://www.tiobe.com/tiobe-index/

Re:Two years of Rust by goatlover on Monday May 15, 2017 @06:49PM (#14345876)
If you mean Java replaced C/C++ as the most widely used language, at least according to one index, then that's one thing. So if someday Rust became as popular, great for Rust. But that's not the same thing as claiming that Rust will be the One True Programming language in use that will cause all the other language communities to die out and convert to Rust.

That's what is being claimed above, and what some in the Java community were claiming in the 90s. Also, probably some in the Javascript community these days.

But it's never happened. If there was the One True Language to rule them all, then Lisp, C++ or Haskell would have done it by now.

The point with Java is that even though it was targeting the C/C++ crowd specifically, and it became widely popular, did not cause C/C++ to die.

Re:Two years of Rust by kibwen on Monday May 15, 2017 @08:11PM (#14346348)
> that's not the same thing as claiming that Rust will be the One True Programming language

Again, who is claiming this? Can you link me?

Re:Two years of Rust by goatlover on Tuesday May 16, 2017 @12:35PM (#14350905)
Just go up several posts and read the end of the one I initially replied to.
Re:Two years of Rust by sqeaky on Tuesday May 16, 2017 @02:29PM (#14352056)
I wasn't claiming it and I even qualified my statement. I am not sure what more I could to make it clear that no languages have actually been replaced, while retaining a nuanced message that many people see replacements depending on their perspective. Then I even cited source to back it up with some some numbers.

If you want to argue with some several post up, please go several posts up. If you want to argue against me, than please do so on the merits of what I said.

Re:Two years of Rust by pjmlp on Tuesday May 16, 2017 @02:56AM (#14347853)
Java and its counterpart .NET did indeed replace C and C++ in 80% of enterprise applications.

The remaining 20% are stuff like device drivers or high performance libraries that are easier to write in C or C++, or legacy MFC applications.

Also if you look at operating systems like Android, Google makes it very explicit that you need a very good reason to down into the NDK dungeons, to the point that the set of allowed libraries only cover the use cases of 3D graphics and bringing native libraries into Android.

Likewise when Android Things was still called Brillo, the plan was to re-write the Android Framework in C++, instead they ended up bringing ART into Brillo.

Re:Two years of Rust by lacampbell on Monday May 15, 2017 @06:13PM (#14345624)
Having so few constraints on implementation (e.g. duck typing) was an interesting concept, but time has proven it to be a nightmare maintainability.

Citation needed. Just because static typing is has been more fashionable for the past 10 years, doesn't mean it's a closed case. Before that people were extolling the virtues of dynamic languages.

Some people deciding they prefer static typing doesn't constitute some kind of consensus or fact.

Re:Two years of Rust by brandur on Monday May 15, 2017 @06:28PM (#14345728)
Yes, I can't prove it. There's no quantitative way of doing so.

I've worked with very big duck typed codebases for quite a few years now (and largely statically typed in C# before that) and the above is my opinion. Duck typing is convenient early on, but it makes understanding code (especially where it gets complicated or you didn't write it) quite difficult, and any kind of refactoring downright scary. After a point you (1) start getting hugely defensive with tests because without close to 100% coverage you just can't know if anything works, and (2) stop making big changes and instead accept that small incremental deployments towards a greater end is the only safe way towards making progress.

I suspect that how much you agree with this statement is strongly correlated to the size of your codebase. I'd be surprised to meet people with codebases on the order of 100k lines or greater that don't largely share this sentiment.

Re:Two years of Rust by lacampbell on Monday May 15, 2017 @06:48PM (#14345867)
I don't understand how (1) isn't a positive in your eyes. (2) is true for pretty much every large statically typed codebase I've worked on.

I'll admit, my commercial experience has all been in statically typed languages. But there are a lot of complex, well written pieces of software written using dynamic types. Maybe you don't meet their proponents, but they do exist.

FWIW, I quite like static typing, but I consider it a feature, not a religion.

Re:Two years of Rust by brandur on Monday May 15, 2017 @07:56PM (#14346266)
> I don't understand how (1) isn't a positive in your eyes.

I like testing as much as the next person and consider it very important, but your tests should be testing business logic rather than whether your syntax is correct. The problem with dynamic languages is that while you're certainly doing the former, you're also doing way too much of the latter. Until you hit runtime, you have no idea whether you misreferenced a variable or invoked a method that doesn't exist, so you end up writing an exaggerated number of tests that are repetitive, slow things down, and end up requiring considerable maintenance.

> (2) is true for pretty much every large statically typed codebase I've worked on.

Yes, incremental deployment is always a good idea, but it's a matter of degree.

Take for example a case where I need to rename a method that's widespread throughout the codebase. In a static language, I wouldn't give this a second thought. If there's a problem my compiler will catch it, and that's the end of the story.

In a dynamic one, this is a dangerous operation: the old method name may still be getting invoked dynamically in a non-obvious way, or another branch may have been merged _after_ I branched but _before_ I deployed that still has an invocation of the old name. Hopefully you have tests on these paths that will reveal the problem, but you might not, and to hedge against that possibility, you have to roll the change out to production carefully and slowly (because even there, it might be some time before some unwitting user inadvertently triggers the bad flow).

Re:Two years of Rust by nickpsecurity on Monday May 15, 2017 @07:35PM (#14346156)
Patrick Logan on Lobste.rs comes to mind. He talks a lot about using Smalltalk for robust applications. Here's one paper he shared where Smalltalk team killed the others in productivity. Unfortunately, I didn't get defect rates on all the teams where Ada or C++ were usually winning in those kinds of comparisons.

https://drive.google.com/file/d/0B0cKsRm-3yprYTR5YTRaRFBfR28...

He said they mostly just test everything at the interfaces. However, it's simplicity also allowed for powerful tools in code generation, refactoring especially, and so on.

Re:Two years of Rust by 3pt14159 on Monday May 15, 2017 @07:02PM (#14345963)
I fully agree with you, but I still start projects in Ruby.

Why?

Because returns from startups are exponential and the interest rate is higher than the interest rate on the technical debt.

It's why compiled is a great choice for an established corporation with a well defined need and a large user base, while interpreted is better for most other business contexts, especially with tools like Numpy.

Re:Two years of Rust by perfmode on Monday May 15, 2017 @11:35PM (#14347186)
Have you seen helix? Ruby-Rust interop:

https://usehelix.com/

Re:Two years of Rust by 3pt14159 on Tuesday May 16, 2017 @09:23AM (#14349331)
Yeah, but I've been doing this stuff for a while now. I used to do it in C and then in Nim (unlike Go until about a year or two ago, Nim could always compile shared objects, so using it through the ruby FFI was pretty straight forward. I've also done some stuff in Cython and just communicated through the database to my Rails app.

I'm still not sure what the best way of doing things is. I tend to think that Rust is going to be the programming language of tomorrows operating system, but I'm not sure if it is going to get the wide library support of something like Cython, since the scientific community isn't as fractured as the software community. Tools like graph-tool / scipy / etc are hard to live without.

Re:Two years of Rust by omaranto on Monday May 15, 2017 @04:02PM (#14344646)
Compiled languages can have REPLs too. Common Lisp and Haskell come to mind.
Re:Two years of Rust by steveklabnik on Monday May 15, 2017 @04:11PM (#14344722)
https://github.com/murarth/rusti was the start of one; it's not particularly maintained these days.
Re:Two years of Rust by kccqzy on Monday May 15, 2017 @05:29PM (#14345290)
For Haskell, the GHC's compiler and interpreter are very different beasts. The former is well known to be fast, but the latter is fast.
Re:Two years of Rust by jleahy on Monday May 15, 2017 @05:41PM (#14345388)
Or ROOT for C++ (used by CERN)

https://root.cern.ch/

Re:Two years of Rust by skariel123 on Monday May 15, 2017 @04:12PM (#14344725)
and scala
Re:Two years of Rust by comex on Monday May 15, 2017 @04:29PM (#14344846)
The comment I'm replying to really doesn't deserve to be in the grey. Rust is a great language, but like any language it has plenty of tradeoffs and room for improvement. Right now it has no REPL at all; in a few years it might, but who knows. And even if it does, it's unlikely to be able to fully replicate the experience of a LISP REPL, if only because the language is thoroughly statically typed - which of course has lots of benefits as well. Tradeoffs!