Java Is Better Than Rust
rohan.ga
rohan.ga
> Even when I do systems programming, like low level stuff, I just want to manage my own memory. I do not want to beg the compiler to let me write code, I just want to allocate stuff and put stuff into there. C is fine for this. I’ll try zig later.
Oh lordy please no. That's how we got into so many messes in the first place. I think writing Rust made me a better C programmer by drawing my attention to how many bad things I was doing that a C compiler would cheerfully compile without saying a word. Oh, you want to malloc a chunk of heap, free it 8 calls deep in some random function, and then pinky swear never to touch it again? Go for it!
I don't have anything objectively bad to say about Java, except that it's probably a terrible fit in any scenario where you'd be using Rust in the first place. (Notice there's not a big push to re-implement a bunch of command line tools in Java?) For me, it's almost entirely a preference thing. Java looks ugly and inelegant to me in a way almost no other popular language does. It doesn't mean you can't write beautiful, elegant code in Java. It does mean, in my opinion, that it will never look beautiful and elegant. By analogy, notice that even people who've taught themselves Klingon don't spend a lot of time writing poetry in it. You could, but it's never going to sound as pretty as a shopping list written in Italian.
There is no default system memory allocator in Zig--this is a signficant difference between Zig and C or Rust.
If you want to allocate in Zig, you have to cough up an allocator and pass it around.
The downside is that a lot of things need an allocator and that makes some things more complicated (printing to console, for example). The upside is that if there is no allocator being passed, you're guaranteed to not be allocating/deallocating memory.
Also can someone tell me exactly what they mean by "Java is ugly?" Yes, you can write ugly Java, but you can write ugly code in any language. You can also write elegant Java, it just takes more skill. I don't see verbosity as a negative, since any half decent IDE has had non-AI autocompletion for decades, and your screen has been able to accommodate more than 80 characters for even longer.
I've thought the same thing for a really long time. Are people writing code with notepad??
Conceptually, the borrow checker and lifetimes are no big deal. (As an aside, I think that the less exposure someone has to other programming languages, the easier it is to “get it”) They are being introduced and taught very poorly. By very smart and accomplished experts, yes. Just not experts in teaching. And if you look at the GitHub discussions for the rust book, for example, you’ll see suggestion after suggestion on how to make improvements - from people learning rust - but they don’t want to accept this advice because then the website and the printed book would diverge.