[asterisk-users] noun-verb vs verb-noun aka dogs black vs black dogs

Steve Edwards asterisk.org at sedwards.com
Wed Dec 19 16:47:39 CST 2007


Wow. I wasn't expecting such a voluminous reply -- some I agree with and
some I don't.

My apologies for an equally voluminous reply.

On Wed, 19 Dec 2007, Tony Plack wrote:

> > We're not discussing code or the inner workings of Asterisk or even
> > changing the functionality of Asterisk, just what the proper order of
> > the words should be.
> > 
> > Most of us users are people, not parsers. The developers? Well, that's
> > why they're developers :)
> 
> We are discussing the inner workings of Asterisk as this is an Asterisk
> thread.  With that in mind, we are also discussing the order that a
> program works best in parsing code.

I disagree. I can discuss the placement of the controls in my car without
the slightest interest in whatever is in front of the firewall.

This is not "the inner workings," just the external presentation.

> The real reason that programmers use languages (like C or perl) is that
> machines are less intelligent than humans.  If we used English to program
> computers, the computer would have to read the slight nuances that exist
> in English and just like this thread, we would be asking mathematical
> machines to make assumptions about what each say.  Who is to say what
> variant of the English language is to be used, because people may still
> not understand the syntax of language we use.

"Who is to say" is the developers since it is their "gift" that we use. My
only hope is to influence their decisions to what I think will suit me and
the majority of whom I perceive to be the users. If I don't like it, I know
my choices -- I can choose not to use their product, I can adapt to their
decisions, I can suffer in silence, I can ask for consensus for change, I
could even write a humongous patch to coerce their code to fit my view of
the world.

> That being said, ordering in a command structure should make sense to the
> application (less intelligent entity), not to the "programmer" (hopefully
> more intelligent).  Anyone who has configured most applications would
> agree that they are more of a programming language than a conversational
> language.

I disagree. I think the command structure should make sense to me.

I'm pretty sure the engineers that designed my car placed the air
conditioner controls comfortably within my reach because users before me
said that's where they wanted them to be. Otherwise, we might find the air
conditioner control under the hood next to the compressor because it used
less wire.

I think the command structure should follow widely accepted patterns --
MySQL, GDB, Oracle, ad nauseum.

Think how much fun it would be if Chevy engineers thought the brake should
be under your right foot and Ford engineers thought the gas should be there.
I'm sure both camps would have rational arguments. Now if we could just get
the "Brits" on the right side of the road...

> The Asterisk core program doesn't know what verbs each module, channel,
> res, or function contains.  It must ask the code(noun), for a given verb
> (function) and then pass that function the options (adjectives).

You are mistaken. When a module is loaded it registers as many CLI objects
as it wants to, so the "core" does know what commands are available.

> So if I use show black dogs, with dogs being the module, show being the
> verb, and black being the option, here is what would happen:
> 
> Look for module show -> doesn't exist
> Look for module black -> doesn't exist
> Look for module dogs -> Found, get reference
> 
> Ask module dogs, for function show -> found, get reference
> 
> Send option black (remaining words from the parser) to function show in
> module black.

This is only because of how you think it works. It doesn't work that way and
I don't really care how it works. I just know how I want it to look.

It would be perfectly reasonable for a module to register cli objects with a
"show" command handler. Look at the code in chan_sip.c. The module registers
multiple objects with "sip" and "show" as the first 2 words in the command.

You are thinking way too rigidly. Asterisk does not need to know a noun from
a verb, just what words can follow which words and how to complete the
command (as in "show channel <TAB>").

> In my opinion that makes Asterisk slow and introduces bugs if some
> programmer creates a new app_black which causes a video screen to go
> black, then we have a problem.

And that is what it is -- an opinion. I don't see a problem here. A well
defined, consistent command structure would ease the addition and adoption
of new apps, not hinder it.

> In this example, we are left with fixing the position of the module as
> position 3 in the command stack.  That also means that additional
> parameters (options) must limited to one (which doesn't work) or messes
> with the command structure by placing adjectives after the noun like:

No. we don't need to fix anything in any position. The command parser only
needs to know what words can follow the current word.

> show black dogs dachshund
> 
> That doesn't make any sense for humans again.

Your straw man won't even stand up.

Of course not. "Show black dachshund dogs" does, but "show black dachshunds"
is better since I don't know any dachshunds that aren't dogs. The command
parser only needs to know that "dachshunds" can follow the word "show" or
the word "black." Think of "show channels" and "show sip channels."

> So then for the computer, we are left with the following syntax that
> works:
> 
> Module Function Option1, Option2, ....
> 
> The module is fixed, position 1.
> The function is fixed, position 2.
> The options are everything that follows.
> 
> In our example, that would be:
> 
> dogs show black

I am not a computer.

This only "works" because you are closed to the alternative. The alternative
(verb-noun) works fine for the above referenced applications and many more.
Do you want to "tally" the number of users of applications that use
noun-verb instead of verb-noun? Is there a reason verb-noun works fine for
them and not for us?

> Is it English?  No but it isn't Spanish, Italian, and whatever language I
> have left out.  It is Asterisk and computers.  It also means profitable
> employment for people willing to learn this language.

I'm sure both you and I think we are far enough out on the right side of the
bell curve to master any arcane syntax that can be dreamed up, but why? We
should design the command structure to be obvious and natural and consistent
and approachable and and and. I prefer to earn money for creative solutions
that can be (at some level) managed by my clients, not hold them ransom
because I know something they don't.

> We could fix the verbs that are used, but that means that every module
> would have to have the same core verbs and we could have no exceptions.
> That means that ZAP, SIP, and MeetMe could have no functions that adhere
> outside the standards OR that most modules would have huge amounts of
> unnecessary functions which do nothing but take up space and cause bugs.

Only because you think it would either limit or bloat the code. Try thinking
of the command structure as a tree. Any module can add a branch or a leaf at
any point. At the end of the leaf is a pointer to some code.

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                             Fax: +1-760-731-3000



More information about the asterisk-users mailing list