Hacker News new | ask | show | jobs
by estebank 1886 days ago
I wouldn't say that thinking about ownership is "low level details". You are (or should?) always having to think about this when building APIs. The difference is that in for example Python you don't have a way to encode that information and enforce it. I would say that the "feeling" of writing on a high-level language comes from a few ergonomic features:

- Match ergonomics, so that you have to think about borrowing less in patterns

- The compiler providing suggestions for those cases where you must specify them

- Type inference

- Iterators letting you write fairly functional code

Things like having to write &*foo[..] or .as_mut_ref() are indeed "warts" when you don't care about those details, but they happen uncommonly enough that it isn't perceived as an onerous cost.

1 comments

> You are (or should?) always having to think about [ownership] when building APIs.

This isn't strictly true. For instance Swift uses value semantics, which is equivalent to adding an implicit `.copy()` in rust every time most variables are passed around. It obviates a lot of the low-level details, at the cost of performance and control. This is a lot more "python-like" in my opinion, where having to hold these details in your mind is very much against the design priorities of python.

Python wants everything to be implicit, to eliminate tedium wherever possible, and for syntax to barely exist. By contrast Rust favors explicitness, demands a lot ceremony, and is very syntax-heavy. These languages are antithetical in so many ways.

It's fairly subjective, so I would not try to convince you that Rust is more similar to C than Python, but many of the points you brought up apply to virtually every modern mainstream language. It's hard to imagine why Python would come up as a comparison point for Rust unless C and Python were literally the only other languages you had ever programmed with.