Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

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.



I 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.


I 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?


The suffix `Factory` often gets made fun of, but there are a few places where it makes sense. Sounds like this is one of them.


Factory went out of favor. Nowadays people just add an s as a suffix in Java.


Could also be called "ProcessTemplate" ?


> 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

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]


> 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”.


generic, I believe. i.e. it’s an interface that has to be implemented.


Yep, “generic” it is.


If 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.


gen_server to me is “generate a server”


I 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.


generic?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: