Hacker News new | ask | show | jobs
by insanitybit 1327 days ago
Garbage Collection is extremely complicated. It is a whole other program running to manage your memory using extremely complex, hyper optimized algorithms that have lots of best and worst case scenarios depending on which one you use.

GC implementations can very easily make code confusing. Consider `finalize` in Java - a destructor that gets called at a completely indeterminate period of time, making it a very confusing tool for resource management.

I find Rust trivial by comparison. But isn't that interesting, how we all view simplicity so differently?

2 comments

That is why finalize is deprecated for removal, and will eventually be dropped from Java.

https://openjdk.org/jeps/421

One is supposed to use try-with-resources, determinist resource management, or cleaner types.

I did want to say Rust was complicated, I meant to say it was complicated to learn. You never need to learn the Java syntax finalize, it is invisible until you have a problem where that is the solution. Similar to Java templates or overloading they dont exist until they are the solution to a problem you are having.

My critique is that Rust appears (and I am probably wrong) to have a problem where syntax for complicated language features appear in the simplest code that even a day 1 grade 8 student needs to memorize, even if they wont understand it until the second year of university.

> syntax for complicated language features appear in the simplest code

IDK, I hear you but I'm of two minds.

1. I think a lot of this is familiarity.

`public static void main(string[] args)`

That's a lot of stuff that I don't actually really need to care about but is in every single Java program. It even has 'static', which is honestly something I found very very confusing when I first learned Java (technically my first language since I took a course at a local community college).

Compare that to c, `int main()`

That's a lot less in my face for sure.

But if I were used to Python? I'd just write my code directly in the file and it would execute from top to bottom. WTF is this `int` and `main` ???

In Java you have int and Integer, and Integer can be this "null" thing? I just wanted to add 2 and 2 wtf??

Generics? `class Foo<T>` ? WTF is `<>`?

The point is that what you have to learn when you first use the language is really going to depend on what you learned before it. I don't consider that complexity, it's just new.

The thing is that there is no language that you're likely to have used before that will prepare you for some bits of Rust.

2. Rust could be easier. It would be cool if there were a way for beginners to think less about the differences between String and &'a str and &'static str. At the same time, abstracting over those would have its own downsides - if you learn about strings in Rust in a way that abstracts that all out, will you understand the underlying components and how the abstraction works? It's tough.

I think the reality is that Rust is just not going to be as easy to learn as the same exact language but where lifetimes are managed at runtime. It probably shouldn't even try too hard to be that easy, because being that easy has costs, and there's a limit to how much you should optimize for newcomers. Rust has balanced things pretty well so far there - 2018 brought a lot of ergonomics wins that I frankly don't care for very much or even just forget about, but it helped tons of people pick the language up.

All this is to say, I think there's truth to what you're saying but I also think you may be attributing some issues to complexity where I believe it's an issue of familiarity.

I appreciate your opinion on this though, I do always find it so interesting to hear about how others view complexity and programming languages (when they're constructive about it).

Highly agree with #1. I think it really does come down to familiarity. I've learned all the languages you listed and every time there was something that was confusing only to then be cleared up the more I use it.