4 ms·
The point of branded types is, among other things, that you do not need to introduce a wrapper class which consumes additional memory.
by beeboobaa3 2y ago
The point of branded types is, among other things, that you do not need to introduce a wrapper class which consumes additional memory.
- throw156754228 2y agoReally? I'm surprised you mention memory is even a consideration, never even heard it raised as far as typing choices are concerned.
- beeboobaa3 2y ago(More than) doubling the memory required for all of your integers would be silly. You could use `{userId: 12345}` everywhere, or you can use a branded type and it's just `12345` at runtime.
- golergka 2y agoAre you worried about compiler memory consumption? Because it's not a class, it's a type, and it's erased at compile time.
- beeboobaa3 2y agoRuntime. Not compiler.
- golergka 2y agoNone of this exists at runtime.
- hombre_fatal 2y agoWell, they're talking about alternative solutions that do exist at runtime like wrappers. Granted, it's hard to know exactly what solutions the person is pitching (the person they're responding to). This person presumably thinks renaming arguments like foo(string:) to foo(hash:) solves branded types. And then they vaguely gesture at other solutions like namespacing and 'safe classes'.