4 ms·
> The problem to me of naming types is that a lot of the time there is no meaningful name to give, and so it becomes noise. Do you have examples? That's not m
by Yoric 4y ago
> The problem to me of naming types is that a lot of the time there is no meaningful name to give, and so it becomes noise.
Do you have examples? That's not my experience.
Of course, we may simply be working on very different types of code :)
- vidarh 4y agoIt's hard to give a neat example, because it really changes how you write code and it's been a long time since I had to suffer through much static code. But e.g consider basically almost any case with abstract member functions / methods. While that happens in Ruby (or the equivalent: Leaving a method which raises an exception unless overridden) it's far less common. Typically you'll instead implement defaults in a module if there is lots of functionality that a client might want for itself). These are generally fine to name, and type check by the module name. But when that is not* the case (any class consisting mostly of abstract methods), a Ruby implementation would be more likely to instead expect the presence of a single method and embed the default functionality in the calling class. That's the kind of scenarios where you end up with the kind of long, contrived class names people tend to mock Java for in particular. But going further, a Ruby implementation will instead often take an argument that is expected to support "to_proc" or a block argument, so that you can provide a lambda/closure to do what you'd otherwise put in an "adapter" or "shim" class. Conversely, any time where you demand (whether in a static language by type annotiations or in a dynamic one by checking for the class) an object of a very specific class and only call one or a few methods on it, you're sidestepping this problem by avoiding the creation of a more precise interface that'd clutter up the code. You don't create and name interfaces that encompass the specific operations needed by each method because it'd be a total mess.
- Yoric 4y agoFair enough. A few common examples for which I rely upon static typing: - I have a proof that operation X is complete, because I have a protocol to follow; - this string is a Matrix room id (and not a Matrix user id or a Matrix server id, also strings); - this time is in milliseconds. Sounds like very different use cases :)