Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How Many Languages are in Your .pl?

by hardburn (Abbot)
on Oct 12, 2004 at 14:56 UTC ( #398515=perlmeditation: print w/ replies, xml ) Need Help??

You may well think that all you do is program in Perl. All day, every day. This is almost certainly not the case. Mini-languages abound everywhere. Here's just a few that you may use all the time without thinking about it.

And that's just the core language. If we extend the list to include popular uses and modules:

  • SQL Almost any database application has SQL in it somewhere. If it's not SQL, then it's almost certainly some lesser-known query language.
  • HTML Lots of (IMnHO) naive people still embed HTML in their CGIs. Those of us who have moved on to templates are actually adding yet another language (that of the templating system itself). Interesting that adding another mini-language tends to make things easier . . .
  • Parse::RecDescent Those strings containg the grammar certainly aren't Perl code.

And probably gobs and gobs more. Any given peice of perfectly valid and clean Perl code could easily contain four or five mini-languages without anyone realizing it. I find this interesting, as I hear from many managers that your orginization should stick to using just a few languages. They probably mean full-fledged languages, but I still find this view a bit naive.

One of the reasons I'm excited about Parrot (more than Perl6) is to use it to make all sorts of mini-languages that can be more easily embedded into a main language, or have them call routines built from other languages.

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Comment on How Many Languages are in Your .pl?
Re: How Many Languages are in Your .pl?
by dragonchild (Archbishop) on Oct 12, 2004 at 14:59 UTC
    You forgot a few. Some, however, may not be in the .pl or .pm files, but they're part of the overall project.
    • CSS (it's kinda Turing complete, right?)
    • Javascript
    • Template Toolkit (it is its own language, but H::T isn't)
    • Inline makes embedding languages a (mostly) trivial task

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      I was thinking more of mini-languages, i.e. ones that aren't necessarily Turing Complete, but are very good at solving their own little problem (which does qualify H::T, and certainly H::T::Expr). Except for CSS, I wouldn't call any of those "mini".

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        Hrmmm ... in that case, wouldn't a mini-language be anything that has a defined syntax and an engine that does stuff behind the scenes? That would qualify most non-trivial OO APIs, and I don't think you want to go there. So, personally, I would actually require Turing-completeness for this exercise,

        Being right, does not endow the right to be rude; politeness costs nothing.
        Being unknowing, is not the same as being stupid.
        Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
        Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: How Many Languages are in Your .pl?
by kvale (Monsignor) on Oct 12, 2004 at 15:19 UTC
    I use XML all the time via Perl. XML is definitely a language. Heck, XML is a also a metalanguage: I also use it to create new languages.

    -Mark

      and I guess that you could add all of the XML related technologies e.g. xslt, dtd, xpath. Also, anything that you can transform XML into.

        Yes, let's just hope no one comes up with XPERL:

        <line> <function> <call> <print filehandle="STDOUT">Just another XPERL Hacker</print> </call> </function> </line>

        :-P

        radiantmatrix
        require General::Disclaimer;
Re: How Many Languages are in Your .pl?
by hv (Parson) on Oct 12, 2004 at 16:28 UTC

    Every time we parse some data we also potentially create a new mini-language; even something as simple as this could qualify:

    my @countries = map { chomp; my($isocode, $name) = unpack "A2xA*", $_; Country->new($name, $isocode) } <DATA>; __DATA__ AD ANDORRA AE UNITED ARAB EMIRATES AF AFGHANISTAN AG ANTIGUA AND BARBUDA ...
    .. but I see (and create) more complex examples all the time.

    Hugo

Re: How Many Languages are in Your .pl?
by demerphq (Chancellor) on Oct 12, 2004 at 17:04 UTC

    I would argue that you omitted an important minilanguage. While I suppose you could argue that its just perl I think the data structure language that is used in perl can in many respects be viewed as a minilanguage of its own. You know what I mean:

    my $hash={ key => [ qw( a list of words and ), {objects=>0}],foo=>\do{ +my $v}};

    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi

      Flux8


Re: How Many Languages are in Your .pl?
by gmpassos (Priest) on Oct 12, 2004 at 21:10 UTC
    You forgot XS and perl_API, and forcing a little Inline::*. Perl have a lot of mini languages or things got from other languages, and is possible to put anything on it (Inline::C, Inline::Java, ...), or put it on anything (PLJava, PLDelphi, ...), this is way Larry likes to say that Perl is just a glue between other things.

    All of this is only possible because Perl is completely free and we have access to all it's sources, where we are able to change and improve any part. So, Perl programmers are so creative because they are free to do this (read my sign frase in the bottom that I always use.)

    Graciliano M. P.
    "Creativity is the expression of the liberty".

Re: How Many Languages are in Your .pl?
by pg (Canon) on Oct 12, 2004 at 23:57 UTC

    I did a page search, and surprisingly, nobody mentioned SOAP. If you count things like HTML and XML, then count SOAP.

    In theory, two languages with SOAP support can always call each other's functions, subs, procedures, ... cannot forget this one ;-)

Re: How Many Languages are in Your .pl?
by guha (Priest) on Oct 13, 2004 at 10:31 UTC

    I'm a little surprised that no one has mentioned pod and plain # comments.

    Comments come in many flavours differing in language, volume and style but may not necessarily be TC ;-).

Re: How Many Languages are in Your .pl?
by Anonymous Monk on Oct 13, 2004 at 11:41 UTC
    How far do you want to go? What is a mini-language anyway? Would you consider the she-bang line a mini-language? What about every function call or operator? Their arguments have requirements (syntax) and meaning *semantics), so do they qualify? Some are simple, like sin, both others are more complex, like split, splice, and eof. And it gets even more complex if you look at non-primitives, for instance Getopt::Long::GetOptions, where even the arguments themselves have mini-languages!

    Then we have the @EXPORT, @EXPORT_OK, %EXPORT_TAGS, and %EXPORT_TAGS interface to Exporter. YAML, Data::Dumper and other serializing modules each use their own mini-language as well. Oh, and let's not forget all the quoting constructs (single and double-quoted strings, q[qrwx]?) - mini-languages are used to be able to find the terminating delimiter.

Re: How Many Languages are in Your .pl?
by Forsaken (Friar) on Oct 14, 2004 at 12:53 UTC
    there's quite a bit of yet another language in my files as well. Generally english, sometimes even dutch, depending on who I intend the code for ;-) Sorry, lame comment, I know, but couldn't resist...
Re: How Many Languages are in Your .pl?
by hsinclai (Deacon) on Oct 17, 2004 at 20:59 UTC
    That is a cool observation!

    And doesn't Perl have parts of it derived from other languages (er, technically, tools with their own languages) -- sed, awk .. others?

    Didn't the editing in place flag (-i) come from sed? and also these constructs s/// and y/// ?

    What about any magical auto-split behavior - wasn't it inherited from awk?

    As well as a thing like
    BEGIN { ... }

    Perl is a gumbo.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://398515]
Approved by Corion
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-11-25 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (160 votes), past polls