3 comments

  • throwaw1236 minutes ago
    people working actively in &quot;modern&quot; Go codebases with generics, is it becoming like a Java&#x2F;Spring kind of codebase?<p>I understand why you might need generics, but I hate how Java ecosystem exploits it so much that, reading code becomes so difficult, because it was inherited from 10 levels of parent classes and in some cases Java Beans get created based on generic types and their parent classes are abstract classes.
    • throw-the-towel7 minutes ago
      I remember my coworkers having managed to write Java in pre-generics Go. The code had functions wrapped in functions wrapped in yet more functions, and interfaces only ever implemented by one type to replace the generics abuse. Life finds a way.
    • riobard32 minutes ago
      &gt; inherited from 10 levels of parent classes<p>This is not (yet) a thing in Go. Go does not have classes and inheritance. Interface is more like duck-typing.
  • tancop1 hour ago
    &gt; Go’s interface system works at runtime. The specific type of a value passed into an interface parameter is resolved while the program runs. This dynamic dispatch clashes with generics being resolved at compile time.<p>What if the compiler generated <i>both</i> vtable and monomorphized variants for each method? Most calls would use the static version but places that need it like interface generics call the virtual method.
  • EdSchouten42 minutes ago
    Go is often thought of as a successor of C. C doesn&#x27;t have methods, only global functions. From my perspective, Go added methods primarily so that you can use them in combination with interfaces. Given that interfaces don&#x27;t support generic methods, I&#x27;m personally not convinced that this feature was worth adding.
    • munificent15 minutes ago
      <i>&gt; From my perspective, Go added methods primarily so that you can use them in combination with interfaces.</i><p>They also give you a limited form of overloading. Without methods or overloading, you end up in the situation that C and Scheme are in where every operation on a data structure has to redundantly have the data structure in its name like:<p><pre><code> list_clear(my_list); queue_clear(my_queue); map_clear(my_map);</code></pre>
    • etse6 minutes ago
      What was the reason for interfaces having to work at runtime?