4 ms·
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
by MadWombat 7y ago
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?
- terminaljunkid 7y agoEcosystem.. 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.
- MadWombat 7y ago> 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".
- sweeneyrod 7y ago> 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.
- bcrosby95 7y agoHere'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.
- jayd16 7y agoCan 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?
- steveklabnik 7y agoI 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.
- zozbot234 7y ago> 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.
- Ar-Curunir 7y ago`std` data structures that are generic over type of allocator are in the works.
- shepmaster 7y ago> 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 https://github.com/rust-lang/rust/issues/32838
- ggregoire 7y ago> 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.
- estebank 7y agoI'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.
- oconnor663 7y agoI 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.
- christiansakai 7y agoFor 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.
- lostcolony 7y agohttps://github.com/caolan/async/blob/master/lib/internal/eachOfLimit.js 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.