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

Strings are immutable in go so they don't need to be copied?

https://go.dev/play/p/o-ly05_Q46E




Yes I know :) Equally importantly, the Go GC will keep a string alive as long as you have a reference to it, so different objects can hold a pointer to the same string without worrying about who's going to free it or whether one of those pointers might become dangling. Python and Go (and others?) get a lot of mileage out of making strings shared and immutable, but languages with manual or destructor-based memory management don't really have that option.




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

Search: