3 ms·
My main problem with Java is that it's picky, and has some static typing, but it also has heaps and heaps of loopholes in the type system (that turn into runtim
by hedora 4y ago
My main problem with Java is that it's picky, and has some static typing, but it also has heaps and heaps of loopholes in the type system (that turn into runtime exceptions), so it's this weird compromise where everything is substandard. I've found that Go "feels" a lot more like a dynamically typed language, but still has the good IDE support that you're talking about.
If you want to see how much progress there has been in production-quality statically typed languages, write some multithreaded code in Rust. In addition to being memory safe without a GC, the compiler also confirms that your code is threadsafe.
Both those guarantees can be violated using the "unsafe" keyword; Java has similar mechanisms that break memory safety. Java doesn't provide meaningful thread safety, in the same way that C's malloc/free don't provide meaningful memory safety -- it's possible to write thread- and memory-safe programs in both languages, but the Java compiler doesn't really help out much with thread safety, just like the C compiler doesn't typically check for use-after-free, etc. Go's thread safety semantics are closer to Java's than Rust's (though multithreaded programming in Go is more ergonomic than in the other two languages).
- pdntspa 4y agoI've read enough critiques of Rust to be put off from trying it out at this time. And there's a lot of things I don't like about Go. (Zig is interesting though) Unfortunately Rust doesn't have the kind of library support that Java does, and I don't really want to roll my own on some things (the side project will never get done if I get lost in the weeds) For this project the choice fell between Java and C#, and Java won because I was familiar with the library code that does what I want to do. Besides, Java has Swing, which is about the only cross-platform GUI toolkit I can stand to work with (GTK as a close second) > but it also has heaps and heaps of loopholes in the type system (that turn into runtime exceptions) I've yet to run into this in places where I don't really expect it. Do you have some examples of where this becomes a problem? I wrote a bunch of reflection code that triggered a lot of RuntimeErrors, but that was foreseeable as its reflection, the whole point is to figure out types and whatnot during runtime. And at that point, I just fall back to how I write code in dynamic languages.
- kaba0 4y ago> In addition to being memory safe without a GC, the compiler also confirms that your code is threadsafe. No, not at all. Rust verifies that your code has no data-races. That is an absolutely tiny subset of all race conditions, that are simply not verifiable statically.
- Jweb_Guru 4y agoData races, in my experience, are not a particularly small subset of practical race conditions, particularly in Rust which tends to shy away from unnecessary mutable aliasing. YMMV of course.
- kaba0 4y agoI absolutely love what rust does, and in practice in “ordinary programs” data races probably come up more often than other kinds of race conditions, I just wanted to express that one should still very much pay attention to concurrent code.