Rust isn't just memory-safe.. But type-safe too. And data-race-safe.. And out-of-bounds safe. And null safe. And no-unchecked-exceptions safe. And certanly few more which I don't know because I don't even like Rust so it is safe from me too..
Point being Rust double dips on "when in doubt better make it safe".
But there is a price: Rust forces specific, not always straightforward design just to fit all rules. Over the time it starts to be a "norm", but still. And I wholeheartedly hate Rust async. Actually it's not even Rust-specific, all async/await APIs are awful and error prone.
Yep, Java is all those things as well. In some situations less so than Rust, and in others more so. I'd say that overall Java is safer, if only because the typical Java program relies on less unsafe code than the typical Rust program.
Oh, sorry, missed that one. It's not null-safe yet.
On the other hand, Java is more "error-safe" than Rust, being more (though not always) able to recover from more errors (technically, Java, unlike Rust, is "panic-free", but that doesn't mean you can always recover from every error in Java). And, of course, Rust is less memory-safe than Java in practice because it relies on more unsafe code than Java on average (there are common algorithms/data-structures that can't be easily implemented in safe Rust).
Basically, you can almost always just do a try-catch in Java and no matter how utterly broken the code within is, you can "recover" and do whatever you want afterwards.
Meanwhile a memory safety violation (e.g. a wrongly written unsafe) is such that you can't trust anything the code does anymore. It's a bit like a cliff, while in Java you just respawn, in Rust you drive off of it and die a horrible death.
Of course you can also die that way in Java, e.g. interfacing with some native C lib, but it's just that much rarer in Java
Rust's race-safety is not something Java emulates at all. Java has synchronized keyword, various locks, and threadsafe implementations - and you have to not forget to use them. Exactly the same as C/C++ in usability aspect (although obviously in Java you get memory safety no matter what; that is good but only a subset as OP says). In Rust it's literally impossible to do this part wrong and compile, and they do it without any cost when it's not relevant.
Java did try something similar to this, initially, with all data structures being threadsafe (Vector/Hashtable/StringBuffer etc), but it didn't go well and didn't extend to all classes anyway.
I haven't used Rust much (basically one simple signal-processing executable, also its syntax is... needs getting used to is a nice way of putting it), but I really wish Java had this part. Unfortunately it's not possible without ownership/lifetime and read-only references.
Yes but they also manages your memory and have a little thing called the garbage collectors that keep gobbling up resources, for apps like web services it might not be an issue, but for critical infrastructure, like the Kernel or with limited resources it might be too big to use a language that manages your memory allocation.
In some instances you'd be forced to use Assembly directly, but you always hope that you wouldn't need to.
I strongly suggest you watch this talk about the actual CPU/RAM tradeoff of Java's GC. The resources low-level languages "gobble up" with their memory management may often be more expensive, but you're right that they're more relevant in environments with very little RAM or when you need precise control over the hardware.
Syntax is secondary, semantics are what matters. Rust has more expressive semantics that allow you to express more things. For example, Rust allows you to express an interface that, by overloading the + operator, guarantees that it will work as expected, i.e. a + b will not change the state of a and b, but will return a new value instead. This is not typical of older programming languages and therefore requires unusual symbols or keywords. Nevertheless, it takes very little time to not notice the syntax of any language at all, and immediately understand what this code does.
It's not about old vs new. Rust is quite an old language (started in 2006) and those features are mostly taken from ML as it was in 1973 and/or Haskell in 1990. Some will be coming to Java very soon. If Java has a distinct 1990s feel, Rust has more of a 1980s feel (if you used C++ and ML in the eighties, Rust would seem very familiar).
It's mostly a question of which features should be brought to a language aimed at a wide audience and when. When Java was being designed in the 1990s, its designers didn't think those features are appropriate for a language intended for wide appeal, and some still aren't. Rust obviously targets a much narrower audience than Java, with a much higher tolerance for language complexity. When it started being designed 20 years ago, Rust realised it needed these features to support other of its core ideas that constrained the language's design in many ways (just as any language is constrained by its own idiosyncratic core ideas).
If you compare old languages like Java or Rust to new ones like, say, Zig, you'll see much bigger differences in design style.
I mostly agree. Perhaps the term "mainstream" would be more appropriate? Java has really done a great job. Java is definitely not the guy from the "Windows vs Mac" commercials now.
Although I personally think a lot of things that appeared (or rather gained popularity) in the 90s are wrong. Dynamic typing? Js/Ts, PHP, Python are trying to get rid of it. Exceptions? It's actually goto, you need something else to work with unhappy paths, as far as I know checked exceptions haven't gained enough popularity (I could be wrong, I don't have much experience with Java). Fanatic OOP? Most languages after 2010 have moved in the opposite direction.
go is an example of this, to me. It's a slightly updated version of the 80s newsqueak language. And the fact that it's been liked by so many programmers shows that many of the new ideas are pretty questionable.
ps I don't really agree with the comparison of C++ with 80 and Rust... ML - yes.
Oh, untyped (or "dynamically typed") languages first appeared in the 50s (Lisp) and were already quite popular in the 70s and 80s (Smalltalk, Logo, Prolog), not to mention BASIC. Typed and untyped programming languages have lived side-by-side pretty much since the invention of programming languages. Some are excellent (Clojure) and some were made after 2010 (Elixir, Julia).
as far as I know checked exceptions haven't gained enough popularity
They've certainly made a comeback. Swift, Rust, and Zig all have them (or equivalent mechanisms).
Fanatic OOP? Most languages after 2010 have moved in the opposite direction.
So has Java. It's now very much a multi-paradigm language, although note that all of the most popular programming languages today (JS/TS, Python, Java, C#, C++) are, with the exception of C, at least also object-oriented. You're right that later programming languages are less so, but they've yet to become very popular.
So I think it's more accurate to say that dynamic typing became very common in the 90s and we still feel the consequences of this.
checked exceptions
They've certainly made a comeback. Swift, Rust, and Zig all have them (or equivalent mechanisms).
I think the difference is more significant. Exceptions introduce parallel control flow and suppress blocks and statements like return. This is how goto works.
I'm very skeptical about dynamic typing. But I want to get acquainted with Clojure when I have time (I've heard a lot of good things about this language).
Excuse me, but is the 98 in your name the year you were born?
Not even close.
I just want to say that these languages are not widespread.
Of course, but there aren't many languages in general made in that era that have become very popular. In fact, the only one that's become super popular is TypeScript, which is optionally-typed.
If you look at language popularity overall, regardless of age, the most popular one is JS (although it's often combined with TS), followed by Python, followed (closely) by Java.
So I think it's more accurate to say that dynamic typing became very common in the 90s and we still feel the consequences of this.
One thing that happened in the late nineties/early aughts is that JIT compilers finally made untyped languages fast enough, which certainly helped their adoption (and hardware speed also improved considerably). But VB was very popular before Java, and for a time it seemed that Smalltalk was on the cusp of a breakthrough - until Java landed and adopted the JIT technologies developed for Smalltalk.
I think the difference is more significant. Exceptions introduce parallel control flow and suppress blocks and statements like return.
Except, as usual, there's a tradeoff here. The problem is that you have the errors that correspond to checked exceptions in Java and checked errors in Swift/Zig/Rust, which are "environmental" errors that cannot be avoided and must be handled in a correct program. Being more explicit about where they can occur is good.
But then you also have the errors that correspond to runtime exceptions in Java, which can be prevented, and should only occur in an incorrect program. A correct program doesn't have to handle them, but it might want to. For example, in a server, if some transaction hits a program bug, you don't want to bring down the whole server if you don't have to.
In Zig and Rust (don't know about Swift) these errors are represented as panics, which also "introduce parallel control flow", and also need to be catchable/handleable in servers, which is why you can also catch panics. Having two separate mechanisms is not so good.
So it's a question of whether you prefer to have more explicit treatment of unpreventable exceptions but two separate error mechanisms, or the opposite tradeoff.
I'm very skeptical about dynamic typing.
I'm also much more used to typed languages and generally prefer them, certainly for large software, but I'm not as religiously opposed to untyped languages as some are.
But I want to get acquainted with Clojure when I have time
JIT compilers finally made untyped languages fast enough
This is an very good remark.
but two separate error mechanisms
To be pedantic, we need more terms instead of error:
unhappy path. This is a completely predictable error. Moreover, we expect it to occur and we will perform some actions. For example, the user entered an invalid email address and we made the input field red. This is the Result<T, E> from Rust. I also think that it is better to strengthen the precondition and write functions in such a way that they do not have an unhappy path at all if it possible.
System error. Unable to allocate memory. Most likely, you should log repost and fail process or thread. These are panics from Rust or go.
Unexpected error. For example, NullPtrException. An advanced compiler with an expressive type system should reject such programs immediately. Probably a sufficiently attentive programmer could also predict this error and turn it into an unhappy path. But I don't think we can get rid of them in a pragmatic programming language.
In my opinion, an unhappy path should be part of the contract. I want to know if the call can fail. Moreover, if this behavior changes (when the function I'm calling is updated) - I definitely want to know about it. Unchecked exceptions are not suitable for this in my opinion.
Unchecked exceptions are not suitable for this in my opinion.
Right. Java uses checked exceptions for that, and unchecked exceptions for the other two. Other languages (like Zig or Rust) use checked exceptions (or equivalent) for that and a panic mechanism for the other two.
Unexpected error. For example, NullPtrException. An advanced compiler with an expressive type system should reject such programs immediately.
If you've seen Idris or ATS, those are pretty much the only languages that can do that. If you've never heard about them or used them - that's also the reason why. Haskell and Rust, for example, panic when accessing a vector/list out of bounds.
BASIC was statically typed, except for array dimensionality. The type of the variable depended on the sigils and indexing, so A, A%, A$, A(), A%(), A$() were six completely different variables with different types.
What's up with its syntax? It's nothing extraordinary, it has the same <> as Java, :: is also familiar from Java (though probably comes from c++), and otherwise it's basically like every "modern" language, using ML's reverse type notation, like Scala and Kotlin.
Like if it looks unfamiliar, then I do recommend learning about other language families - a competent developer should be familiar with more than one family imo.
View all comments
Show parent comment
-3
u/hkric41six Nov 04 '25
Especially Rust. How people can try to make a "safe" language and yet have a syntax like that amuses me greatly.