Oddbean new post about | logout
 Hey what's so bad about C++? I find it beautiful. 
 I guess that it depends. It has many more features than C which makes it harder for beginners like me.

like, I don't understand what's "smart" about smart pointers, and why exist... 
 Smart pointers are extremely useful and make writing C++ a lot safer.

One of the most common bugs C has is leaking resources and double free-ing.

A smart pointer makes sure your resources are deallocated when they go out of scope. A shared smart pointer is one that when it gets copied, it points to the same resource but increases the ownership count, decreses the ownership count when it goes out of scope. So for shared smart pointers their resources only get release when  the ownership count drops to 0. 
 C++ also has templates (one definition multiple types) and concepts (constrain the accepted types to have particular properties) which are all resolved at compile time. 
 templates are just complicated garbage code generators that take ages to compile, aka "generics", i have written dozens of code generators for teh same kinds of purposes and i could count the number of times it's been important on two hands in the last 8 years

interfaces achieve the same result but force you to actually think about it so the compiler doesn't have to spend many seconds trying to figure out what you mean when you refer to a method on a type that isn't explicitly tied to it

i have lost count of how many times i've used interfaces for this kind of polymorphism but it's also quite overrated, it's more useful for plugging modules together without needing to know the internals, ie, it helps with encapsulation

go has simple types of generics but only on value types, and they are actually handy a lot (especially between types of integers and between strings and byte buffers) 
 templates are just complicated garbage code generators that take ages to compile, aka "generics", i have written dozens of code generators for teh same kinds of purposes and i could count the number of times it's been important on two hands in the last 8 years

interfaces achieve the same result but force you to actually think about it so the compiler doesn't have to spend many seconds trying to figure out what you mean when you refer to a method on a type that isn't explicitly tied to it

i have lost count of how many times i've used interfaces for this kind of polymorphism but it's also quite overrated, it's more useful for plugging modules together without needing to know the internals, ie, it helps with encapsulation

go has simple types of generics but only on value types, and they are actually handy a lot (especially between types of integers and between strings and byte buffers) nostr.fmt.wiz.biz 
 here is the thing, I can't think of any situation where I would absolutely need these things, so 🤷

I guess I am a minimalist