2 ms·
“Langauges such as Rust and Go do not have this problem, mainly because they don’t have the new keyword!” Oh but they do. You should spend some time with those
by reactordev 3y ago
“Langauges such as Rust and Go do not have this problem, mainly because they don’t have the new keyword!”
Oh but they do. You should spend some time with those languages so you can do a proper comparison.
Go has had new for a while now.
- deleted 3y ago[deleted]
- steveklabnik 3y agoGo may (also in my understanding, it's not actually a keyword, but close enough?), but Rust does not.
- reactordev 3y agoOh, excuse me, Box::new :D. At least in rust it’s an explicit method call instead of implicit.
- agumonkey 3y agobut it's a convention right ? there's nothing special about `new` IIRC
- reactordev 3y agoYeah, whether it’s explicit method call or an implicit macro, something is being called. A constructor, a new method, that’s what I was getting at. Saying you dislike the implicit new is valid because you can’t visually see the call where in rust you can. In go, we often take the NewFactory approach even though there’s a new. It’s easier just to return the reference knowing it will out live the stack call.
- steveklabnik 3y agoThat's correct.