3 ms·
What i learn from Erlang, is, naming is hard. What does `gen` mean in `gen_server` ? Thanks for replies for "Generic". So this article is not well organized i
by revskill 4y ago
What i learn from Erlang, is, naming is hard.
What does `gen` mean in `gen_server` ?
Thanks for replies for "Generic". So this article is not well organized in that case. With some simple naming explanation, it should be obvious to guess what the system does.
Abbreviation doesn't save the writings.
Some more examples, in Ruby, instead of calling `implement Module`, it uses `include Module` . I do think include is not as clear as implement.
- mtremsal 4y agogeneric, I believe. i.e. it’s an interface that has to be implemented.
- sodapopcan 4y agoYep, “generic” it is.
- deleted 4y ago[deleted]
- dolmen 4y agogeneric?
- lopatin 4y agoI always thought it was “generate” and that something about the implementation/immutableness required the server to be “generated” at runtime. I never did any actual Erlang programming, it’s just how my brain plugged in the gaps when I heard about all the gen stuff.
- mabbo 4y agoIf they called it 'generic_server' then people would make fun of it for being too verbose. If they call it 'gen_server' then everyone pretends they know what it means and stays quiet.
- edgyquant 4y agogen_server to me is “generate a server”
- layer8 4y agoI associate “gen” more with “generation”, in the sense of “gen Z”. In any case, it’s confusing. With code completion you shouldn’t have to resort to abbreviations (unless they are already part of the (business) domain language). This was different in the 1980s though.
- bkolobara 4y agoI also dislike this name, as it was not clear what it does just by looking at the name. Recently, I was adding a similar abstraction to Rust on a project I'm working on and I called it `AbstractProcess`. Like, it is some kinda of template for a process. Still don't think it's clear what it does by just looking at the name. Does anyone have a better idea on how to name such a pattern?
- revskill 4y agoCould also be called "ProcessTemplate" ?
- gen220 4y agoThe suffix `Factory` often gets made fun of, but there are a few places where it makes sense. Sounds like this is one of them.
- imtringued 4y agoFactory went out of favor. Nowadays people just add an s as a suffix in Java.
- Lammy 4y ago> Some more examples, in Ruby, instead of calling `implement Module`, it uses `include Module` . I do think include is not as clear as implement. Agreed, though I do think the `include` naming might just be a relic from a time before `prepend` and `extend` also existed in Ruby. I find it a lot more intuitive when I remember it as `append`ing to the ancestors, and the language even sort of calls it that internally with the naming mismatch between `include` and `append_features`: https://ruby-doc.org/3.2.0/Module.html#method-i-include https://ruby-doc.org/3.2.0/Module.html#method-i-include Then one can see that's exactly what it does to a Module's ancestor chain: irb(main):001:0> RUBY_VERSION => "3.2.0" irb(main):002:0> lol = ::Module::new => #<Module:0x00007f2969821740> irb(main):003:0> lol.ancestors => [#<Module:0x00007f2969821740>] irb(main):004:0> lol.singleton_class.ancestors => [#<Class:#<Module:0x00007f2969821740>>, Module, Object, PP::ObjectMixin, Kernel, BasicObject] irb(main):005:0> rofl = ::Module::new => #<Module:0x00007f296982dfe0> irb(main):006:0> lmao = ::Module::new => #<Module:0x00007f296982fd40> irb(main):007:0> omg = ::Module::new => #<Module:0x00007f2969822a00> irb(main):008:0> lol.include(rofl) => #<Module:0x00007f2969821740> irb(main):009:0> lol.prepend(lmao) => #<Module:0x00007f2969821740> irb(main):010:0> lol.extend(omg) => #<Module:0x00007f2969821740> irb(main):011:0> lol.ancestors => [#<Module:0x00007f296982fd40>, #<Module:0x00007f2969821740>, #<Module:0x00007f296982dfe0>] irb(main):012:0> lol.singleton_class.ancestors => [#<Class:#<Module:0x00007f2969821740>>, #<Module:0x00007f2969822a00>, Module, Object, PP::ObjectMixin, Kernel, BasicObject]
- dragonwriter 4y ago> Some more examples, in Ruby, instead of calling `implement Module`, it uses `include Module` While (as a sibling comment notes) “append” might be better than “include” given other terms used in Ruby, “implement” would be completely wrong. Modules aren’t interfaces; in fact, they are almost exactly the opposite. A class in a language with interfaces declares that it “implements” an interface because the interface provides guarantees, and the class provides an implementation of those guarantees. An included Ruby module provides implementation, not guarantees that the class provides implementations for. “include” describes what it does much better than “implement”.