Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

modules = minilanguages?

by Anonymous Monk
on Dec 21, 2004 at 18:55 UTC ( [id://416582]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is it just me, or are modules, in and of themselves, sort of like minilanguages?

Like, you have foo.pm, and you write a script to invoke it:

use foo::bar;

$baz = new foo::bar;
$baz->foosub;

that sort of thing.

Replies are listed 'Best First'.
Re: modules = minilanguages?
by davido (Cardinal) on Dec 21, 2004 at 19:04 UTC

    That's simply using an object oriented interface to a module. But to answer your question, modules can be viewed as language extensions. They use existing language syntax combined with their own documented interface. For more complex modules, learning the module's interface can be a lot like learning a sub-language.

    Many of us here speak English, but many of us would be lost if we were asked to discuss a medical proceedure in medical terms. The medical terms are a subset of English (often based on Latin roots, etc.), but they happen to be a subset for which people outside of the medical industry are not proficient.

    A new module can be a little like a medical journal that uses an unfamiliar subset of our familiar English language. You'll have to familiarize yourself with its terms (its user interface) before you'll be able to make sense of it. Fortunately, we don't need a degree in medicine to understand most modules' documentation...with the exception of modules written by TheDamian. ;)


    Dave

Re: modules = minilanguages?
by revdiablo (Prior) on Dec 21, 2004 at 19:01 UTC

    I would tend to say no. Mini languages generally have their own syntax and semantics, whereas Perl modules usually have to follow standard Perl syntax and semantics. Granted, there are some people (*cough* TheDamian *cough*) who do things in their modules that might fit a "mini language" description, but I think that's the exception.

      also TheDamian showed Trey Harris the way in Commands::Guarded which is a neat mini-language encapsulating certain Perl usage patterns
Re: modules = minilanguages?
by Aristotle (Chancellor) on Dec 21, 2004 at 20:24 UTC

    Quite certainly. An API gives you a vocabulary to describe some algorithm just like the core langauge itself does. They work on different levels, but the distinction is ultimately artificial. Functional programming languages have long advertised this fact, f.ex.

    Makeshifts last the longest.

      An API gives you a vocabulary to describe some algorithm just like the core langauge itself does.

      And the cool thing about Perl is that it is so flexible that a module cannot only add to your vocabulary, it can also change the grammar of the language.

        To a certain extent. Perl5 is not close to the most malleable language in that respect. Most functional languages are much further along and have been for a long time, and Perl6 will be a world apart from Perl5. (I can't wait — I've said before that the thought of TheDamian tinkering with Perl6 gives me the shivers, both in a good and bad way. ;-))

        Makeshifts last the longest.

Re: modules = minilanguages?
by gaal (Parson) on Dec 21, 2004 at 19:46 UTC
    You might like to take a look at "Notation", probably the most interesting chapter in Kernighan and Pike's (interesting) The Practice of Programming.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://416582]
Approved by dragonchild
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-09-20 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (26 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.