Hacker News new | past | comments | ask | show | jobs | submit login

Do you really avoid pointers by making everything a pointer?



Yes, if the reference is immutable. The main problem with pointers is ad-hoc memory management anyway.


The references are not immutable in this case.


A reference, unlike a pointer, always points to the same memory address(*); so the reference is immutable even if the cell contents it points to are not. That's the difference between a reference and a pointer, by definition; not just the different syntax.

Back in the day, that was one of the major selling points of the new language Java over the more common C and C++. Developers don't learn about it nowadays because changing pointers is practically never done outside the most esoteric parts of system programming.

(*) Semantically, at least. The compiler is free to relocate the value to a different memory position in a way transparent to the programmer.


Ah, not the pointer problems I thought they were talking about...




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: