News for hackers. Stuff that matters.
Re:What is Rust and why is it so popular? by MadWombat on Tuesday January 21, 2020 @11:49AM (#22108605)
OK, I will bite. If I had to come up with a case where Python is better than Rust, I would say with rapid prototyping and scientific computing. If you just want to try a few things out, python has faster development cycle and if you want to do some super clever math python has better library support. With a bit more mind stretching, I can make a case for Go with a bit more mind stretching. If you want to write a massively parallel network server of some sort you might be better off with Go, especially if you want to use protobufs and grpc. But what would be the case for Node and Java?
Re:What is Rust and why is it so popular? by christiansakai on Tuesday January 21, 2020 @01:03PM (#22109499)
For massively parallel even with async, I still think Go is better than NodeJS. I still don't know how to do bounded parallelism in NodeJS but really easy in Go.
Re:What is Rust and why is it so popular? by lostcolony on Tuesday January 21, 2020 @01:21PM (#22109727)
https://github.com/caolan/async/blob/master/lib/internal/eac... - this is the code the async Node lib uses for every "(X)Limit" function to limit the number run at once.
Re:What is Rust and why is it so popular? by terminaljunkid on Tuesday January 21, 2020 @11:56AM (#22108675)
Ecosystem..

I don't know about node. But there's whole lot of java code and libraries out there. Otherwise why would people build other languages for the JVM?

Ease of writing; Most of code is okay having a GC. But time to produce working code (not necessarily 100% correct code) is important.

Rust is created for low level stuff. It is wrong to expect web backend programmers to deal with ownership, stack-vs-heap and all.

Re:What is Rust and why is it so popular? by MadWombat on Tuesday January 21, 2020 @12:21PM (#22108980)
> It is wrong to expect web backend programmers to deal with ownership, stack-vs-heap and all.

I am a web backend programmer. I respectfully disagree. I would much rather deal with ownerhip and related issues than deal with dynamic typing fallout. Unfortunately, I am stuck in Python land for some foreseeable future.

> But there's whole lot of java code and libraries out there.

That is true about every other popular language. Rust might not have the ecosystem, being a lot younger, but why would anyone pick Java out of all the other options?

As far as I can tell, the only two reasons people continue coding in Java are "We have an existing Java ecosystem, it is easier to continue doing what we have been doing than to switch" and "Java is what we know best and it is easier to use Java than to learn new technology stack".

Re:What is Rust and why is it so popular? by sweeneyrod on Tuesday January 21, 2020 @12:46PM (#22109292)
> I would much rather deal with ownerhip and related issues than deal with dynamic typing fallout.

Those two things aren't connected. You can avoid both of them by using one of the many statically typed languages with a GC. It might be the case that Rust has other advantages over those languages that make power-assisted manual memory management a cost worth bearing, but it is still a cost. The amount of successful web backends written in Python/Ruby shows that performance demands on a typical web app are nowhere near high enough to justify doing away with the GC.

Re:What is Rust and why is it so popular? by bcrosby95 on Tuesday January 21, 2020 @02:10PM (#22110294)
Here's why we use Java:

1. It performs well - we're a small company, so hardware costs matter to us. Its a similar performance class as Go and C# - if you want to go faster, you likely have to use Rust, C, or C++.

2. As said, the ecosystem is huge. If you need to do something, there's probably a library or tool for it. If you have a problem with one of their libs, someone else had the problem too. Unless your business is consulting, spending your time going down paths no one else has gone down just so you can use a shiny new language is a waste of resources.

3. The language isn't full of too many concepts. This makes it easier to get people up to speed with it if they're unfamiliar. I like Rust for some personal projects, but lots of the complexity of the language is completely pointless for most of what we do at my company.

4. The JVM is great.

5. We already know it.

Even ignoring #5, our priority of languages is probably C#/Java, then Go. Java is a meh language. And I feel like the annotation soup only makes it worse: it makes Java both verbose and magical, a truly shitty combination. But the ecosystem is awesome. The performance is good. The JVM is great.

With .NET Core, it might make sense to look at C#. But the language is fairly similar to Java anyways. Switching for switching's sake seems pointless. And Microsoft only relatively recently started officially supporting Linux, so I would be wary of using it for greenfield, much less switching our existing company.

Kotlin is a decent contender here too. But it's not that widespread as a backend language, at least not yet. If I could pick any language, I would choose Clojure because it benefits somewhat from Java's ecosystem and is (IMHO) the best JVM language. Immutability is killer, and I find dynamic typing with specs a good middleground between purely dynamic and purely static languages.

But Clojure makes things pretty difficult when it comes to the hiring end of things and developer familiarity. If I worked at a greenfield company solving the same problems I do today, Java would probably still be my first choice.

Re:What is Rust and why is it so popular? by ggregoire on Tuesday January 21, 2020 @01:01PM (#22109473)
> If I had to come up with a case where Python is better than Rust, I would say with rapid prototyping and scientific computing.

Scripting? I'm not gonna write a 50 LOC single-use script in Rust.

Re:What is Rust and why is it so popular? by estebank on Tuesday January 21, 2020 @01:18PM (#22109690)
I've found that a lot of scripts end up not being single use. In my case they usually do end up rewritten in Rust, with the benefits of having a proper --help command from the bother. Once you know enough Rust the obtuse parts of the language that must exist to cater for the performance critical crowd cease to be a problem.
Re:What is Rust and why is it so popular? by oconnor663 on Tuesday January 21, 2020 @01:49PM (#22110043)
I do write a lot of Python and Bash scripts, even in my Rust projects. They're perfect for gluing together a build. But I'd add that as soon as I want an external dependency (often a more featureful command line flag parsing library), I usually RIIR.
Re:What is Rust and why is it so popular? by jayd16 on Tuesday January 21, 2020 @12:14PM (#22108886)
Can Rust do things like heap compaction? You could do it by hand I guess but its not exactly trivial. There's probably a whole class of problems the GC still excels at.

JVM tooling is also pretty nice. Can you trivially get deep app metrics from any Rust program?

Re:What is Rust and why is it so popular? by steveklabnik on Tuesday January 21, 2020 @12:19PM (#22108949)
I think you're asking rhetorically, but just in case:

1. Rust-the-language doesn't know anything about allocations, so strictly speaking, it cannot. Furthermore, without a GC, it's unclear how it could in the first place, given that a compaction would invalidate all pointers to that memory.

2. Certainly not to the same degree as the JVM, given that there's nothing inherently to inspect, like there is in languages with a runtime. You can instrument your own application, but that does mean doing the work yourself, and you only get as good of results as you put in in the first place.

Re:What is Rust and why is it so popular? by zozbot234 on Tuesday January 21, 2020 @01:06PM (#22109538)
> Rust-the-language doesn't know anything about allocations

AIUI, Rust knows more about allocations than it should, since it's still limited to a single global allocator, and Box<> (which relies on that global allocator) is implemented via compiler magic and cannot be supplemented by equivalent library code. If Rust supported "pluggable" allocators in some fashion, fancy features (including heap compaction, although I find that a bit dubious TBH) might become easier to implement.

Re:What is Rust and why is it so popular? by steveklabnik on Tuesday January 21, 2020 @01:45PM (#22110014)
Global allocator is a standard library concern, not a language concern, and Box is magic in only one tiny way that doesn’t actually have to do with allocation. Eventually that will be available to other libraries too.
Re:What is Rust and why is it so popular? by shepmaster on Tuesday January 21, 2020 @01:22PM (#22109743)
> If Rust supported "pluggable" allocators in some fashion

It's coming, but it's still unstable and being actively developed

- https://github.com/rust-lang/rust/issues/32838

Re:What is Rust and why is it so popular? by Ar-Curunir on Tuesday January 21, 2020 @01:10PM (#22109600)
`std` data structures that are generic over type of allocator are in the works.