9 ms·
I find async is so much fun in Python and meshes with the other things you can do with generators but that is because I have the reference collector cleaning up
by PaulHoule 3y ago
I find async is so much fun in Python and meshes with the other things you can do with generators but that is because I have the reference collector cleaning up behind me.
Looking back with like 30 years of hindsight it seems to me that Java’s greatest contribution to software reuse was efficient garbage collection; memory allocation is a global property of an application that can’t efficiently be localized as you might want a library to use a buffer it got from the client or vice versa and fighting with the borrow checker all the time to do that is just saying “i choose to not be able to develop applications above a certain level of complexity.”
- airstrike 3y agoAnd Java's worst contribution to software was how painfully slow and resource hungry most of the software written with it tends to be... Your argument is looking at the advantages Java brought to development speed and entirely disregarding runtime speed
- fnord77 3y agojava benchmarks are close to C's benchmarks; thousands of times faster than python
- cies 3y agonot in terms of memory usage and startup time. otherwise it's quite fast.
- jshen 3y agoI don’t like Java, but you are completely wrong.
- notamy 3y agoAny tool can be misused - the same comment could be made about Javascript, PHP, Perl, C, C++, Python, really any language.
- charrondev 3y agoThe only Java thing I work with is ElasticSearch (and in the past other lucene based search tools like Solr). These can be resource hungry depending on what your indexing but they are also faster and more scalable than other tools I’d used before.
- jjav 3y ago> And Java's worst contribution to software was how painfully slow and resource hungry most of the software written with it tends to be... It's hip to hate on java, but at least do it from an informed position. Java is extremely fast, which is why it's so popular for server code where performance matters.
- fnord77 3y agothe JVM is an underappreciated engineering marvel
- cies 3y ago> underappreciated widely used though. not sure if that count for appreciation, but i think it's one of the highest forms. it's not bad, not not great either. i miss proper sum types, and it really lament the fact that static things are nearly impossible to be mocked which prompts everyone to use DI for everything instead of static.
- za3faran 3y agoJava has sum types now with sealed interfaces and pattern matching. Records have detructoring out of the box, and I believe supporting it for general classes is in the works.
- cies 3y agoI think sealed interfaces it not quite the same as "tagged unions"-style enum's with payloads. Also, it does not matter much anymore, the whole std-lib is full of exceptions-to-implement-multiple-return-values.
- za3faran 3y agosealed interface Shape {} record Square(int x) implements Shape {} record Rectangle(int l, int w) implements Shape {} record Circle(int r) implements Shape {} double getArea(Shape s) { // Exhaustively checks for all alternatives. return switch (s) { case Square(var x) -> x * x; case Rectangle(var l, var w) -> l * w; case Circle(var r) -> Math.PI * r * r; } } This is a good article: https://mccue.dev/pages/11-1-21-smuggling-checked-exceptions https://mccue.dev/pages/11-1-21-smuggling-checked-exceptions
- cies 3y ago
- codeflo 3y agoI agree that memory management can't be solved locally. The situation in C++, where every library or API you use has a different cleanup convention, that you need to carefully read about in the documentation to even properly review a pull request, is proof of that. I disagree that this criticism applies to Rust. For 99% of the cases, the idiomatic combination of borrow checking, Box and Arc gets back to a unified, global, compiler-enforced convention. I agree that there's a non-trivial initial skill hurdle, one that I also struggled with, but you only have to climb that once. I don't see that there's a limit to program complexity with these mechanisms.
- meindnoch 3y ago>The situation in C++, where every library or API you use has a different cleanup convention, that you need to carefully read about in the documentation to even properly review a pull request, is proof of that. Lol wut. The C++ resource management paradigm is RAII. If you write a library that doesn't use RAII, it's a bad library. Not a fault of the language.
- codeflo 3y agoYou have two choices. Either you write code with good performance, which means that functions do take references and pointers sometimes, in which case you do have all of the usual lifetime issues. This is the proper way to use C++, and it's perfectly workable, but it's by no means automatic. That's the reality that my comment was referencing. Or you live in a fantasy land where RAII solves everything, which leads to code where everything is copied all the time. I've lived in a codebase like this. It's the mindset that famously caused Chrome to allocate 25K individual strings for every key press: https://groups.google.com/a/chromium.org/g/chromium-dev/c/EUqoIz2iFU4/m/kPZ5ZK0K3gEJ?pli=1 https://groups.google.com/a/chromium.org/g/chromium-dev/c/EU...
- cma 3y ago2014, isn't that pre-C++11 in Chromium?
- 3y ago
- Nullabillity 3y agoThe problem with garbage collection is that it doesn't work for other kinds of resources than memory, so basically every garbage collected runtime ends up with an awkward and kinda-broken version of RAII anyway (Closeable, defer, using/try-with-resources, context managers, etc). Static lifetimes are also a large part of the rest of Rust's safety features (like statically enforced thread-safety). A usable Rust-without-lifetimes would end up looking a lot more like Haskell than Go.
- pphysch 3y ago> The problem with garbage collection is that it doesn't work for other kinds of resources than memory Why is that a "problem with GC"? Abstracting away >90% of resource management (i.e. local memory) is a significant benefit. It's like saying the "problem with timesharing OS" is that it doesn't address 100% of concurrency/parallelism needs.
- insanitybit 3y agoI think a charitable reading would be that by "problem" they meant "limitation".
- pbourke 3y agoI quite like context managers and try-with-resources style constructs. They make lifetimes explicit in the code in a fairly intuitive way. You can get yourself turned around if you deeply nest them, etc but there are usually ways to avoid those traps.
- ok123456 3y agoDon't static lifetimes just mean that leaking memory is considered 'safe' in rust?
- Nullabillity 3y agoStatic lifetimes as in "known and verified at compile-time", not "the 'static lifetime".