Talk:Perl/Archive 3
![]() | This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 | Archive 3 | Archive 4 | Archive 5 | → | Archive 8 |
Context-free
- Perl has a context-free grammar; however, it cannot be parsed by a straight Lex/Yacc lexer/parser combination. Instead, it implements its own lexer, which coordinates with a modified GNU bison parser to resolve ambiguities in the language.
No it does not, in anything close to the strict definition of context-free. Actually, very few languages have context-free grammars (for example C doesn't, as a (b); may be either function call or variable declaration in some contexts).
Quick draft of a proof: function prototypes. Whether foo bar 1,2 parses as foo(bar(1,2)) or foo(bar(1),(2)) depends on earlier prototypes of foo and bar. Because of infinite numbers of possible functions, you can't encode this information in a context-free grammar. It's not the only Perl construct that's provably non-context-free. Taw 09:06, 3 December 2005 (UTC)
- You are right that Perl does not have a context-free grammar. The regex syntax isn't even context-free, since even backreferences introduce context-sensitivity. Besides the problem you pointed out, the function itself can behave differently if it is called in scalar v. list context. Your changes look good, although explicit reference to Lex and Yacc may not be the best thing; maybe it should just say "cannot be parsed by a standard lexer/parser combination" instead of "cannot be parsed by a straight Lex/Yacc lexer/parser combination". Mike Dillon 15:23, 3 December 2005 (UTC)
Hello world
Does the warning flag belong in the shebang line of the hello world program? It's never in my programs.
Maybe I'm Wassercrats, maybe I'm not. :P -Barry- 05:14, 11 December 2005 (UTC)
- I think Wikipedia should promote good coding practices, and it's good practice to get into the habit of writing
-w
in the shebang line of all Perl programs. --David Iberri (talk) 18:25, 12 December 2005 (UTC)
- Better yet, use warnings; Turnstep 18:46, 12 December 2005 (UTC)
- Add all the tips on good practice that you want, but the rule of the "Hello, world!" thing is just to print "Hello, world!" and a CR.
- I don't know who wrote the following, but it basically says that using -w isn't worth the trouble unless you need help developing your style:
- "...the code may be perfectly OK, but it will give you an error message so you have to go check. Let me warn you. It can be really annoying to be flooded with messages, especially if you know the code is OK, but my advice is to use -w anyway. If you learn to write code that doesn't generate warnings, you'll develop good style and be a better programmer."-Barry- 20:17, 12 December 2005 (UTC)
- - The "-w" switch should be included because it's canonical. It is included in the "hello world" examples in certain Perl books.
- - It is not Wikipedia's responsibility to promote good coding practices.
- - The "hello world" program is not just a program to print out "Hello, world!" and a CR. It is an idiomatic program.
- - The link ([1]) advises to use -w all the time, not just for "help developing your style". It's a good thing too, because it should be used all the time.
- The Language features or Language structure section should cover things like -w and maybe debugging tools like strict, and common practices for using Perl would be appropriate for the article. I'm not saying that any particular matter of opinion should be promoted. I wouldn't object as much about the -w in the hello world script if it was explained somewhere that it's not essential.-Barry- 21:11, 12 December 2005 (UTC)
- Only good things happen when we promote coding practices that have been widely accepted as good ones. Why shouldn't this be Wikipedia's responsibility? --David Iberri (talk) 03:00, 13 December 2005 (UTC)
- In promoting something, there's often one-sidedness, which isn't appropriate for this quasi-encyclopedia thing we call Wikipedia, but the function of -w can be explained, as well as use warnings;. Mentioning that using -w is generally accepted to be a best-practice is fine too, I guess. -Barry- 03:17, 13 December 2005 (UTC)
Perlscript
no mention of perlscript? Gflores Talk 05:58, 16 December 2005 (UTC)
The lead
I condensed the lead. The lead should be like a headline: very short, with just enough info to tell the reader what the article is about, and help them decide if they want to read further. Avoid adding anything to the lead that either is--or should be--somewhere else in the article. Swmcd 17:11, 16 December 2005 (UTC)
Perl is interpreted
There is a common distinction between intepreted and compiled languages. This distinction is not absolute. The text of most interpreted languages undergoes some kind of preliminary compliation—lexing or parsing—before it is passed to the execution engine. Conversely, every program is ultimately interpreted: CPUs interpret their own machine code.
When we say that a programming language is interpreted, that is generally understood to mean 2 things:
- programs in that langauge suffer a significant performance hit with respect to equivalent compiled programs
- the language offers strong introspection features, and—especially—an eval() function.
Both of these things are true of Perl, so we say that Perl is interpreted. Interested readers will find a more detailed description of Perl's execution architecture in the Implementation secion, while uninterested readers will draw correct conclusions about Perl's performance and language features even if they read no further than the statement Perl is interpreted.
Swmcd 05:18, 17 December 2005 (UTC)
- Sorry for editing the above post. I didn't notice that it was on the talk page.
- I thought the interpreted issue was settled months ago. Anyway, a significant performance hit won't be noticed with all Perl programs. This is covered on page 16 of Learning Perl, 3rd Edition. And eval() is nothing special to me, but maybe there's more meaning in what you're saying than I see. I'm not as into Perl as I used to be. -Barry- 08:33, 17 December 2005 (UTC)
The statement Perl programs are interpreted is gone, on the grounds that
"interpreted" implies "reparsed on every loop".
I've never drawn that inference, but if that's how the word is commonly understood, then we shouldn't use it. The word "interpreted" could be dropped from the lead. The word "interpreter" appears in 30 places in the article; I don't know what to do about that.
Swmcd 15:47, 17 December 2005 (UTC)
- Yeah, colloquially, we say "the Perl interpreter" (the standard /usr/bin/perl program), only to contrast it with "the Perl compiler" (various forms of perlcc and friends). --Randal L. Schwartz 20:02, 17 December 2005 (UTC)
Semicolons used inconsistently in one line scripts
I've seen one liners with and without semicolons in the article. For example, there's:
my $x = shift;
and there's:
$x =~ m/abc/
I suggest that semicolons be used consistently. The problem is that I encountered a line that I'm not sure can be a valid line of Perl code or whether it's a snippet of a line, so someone more advanced than me better take care of it. -Barry- 21:57, 17 December 2005 (UTC)
- You only need semicolons to separate statements. Most of the examples in the article aren't one-line scripts, they are just code fragments. The first example above would typically be a complete statement in a program, so it gets a semicolon. The second example is an expression that might be part of a larger statement, so it doesn't have a semicolon. Swmcd 13:43, 19 December 2005 (UTC)
Regex examples
Sorry, I don't understand what the following example is good for ( especially combined with 'This is more interesting for patterns that can match multiple strings', were the modifier //s should be in use ):
($matched) = $x =~ m/a(.)c/; # capture the character between 'a' and 'c'
$matched will print -1 on my machine, this should be a simple example and we should introduce $1 here Ulv 23:42, 18 December 2005 (UTC)
- The example worked as written
localhost:~/src/Perl>perl -le '$x="abc"; ($matched) = $x =~ m/a(.)c/; print $matched' b localhost:~/src/Perl>
- The term "multiple strings" doesn't mean that $x contains multiple lines; it means that the RE can match more than one string, e.g. 'abc', 'axc', a3c', etc. But the text should probably be more direct than that.
- We could describe either the return value or the $1, $2, ... variables; I'd rather not do both, in the interests of brevity. I think the return value is slightly simpler to illustrate:
($matched) = $x =~ m/a(.)c/; # capture the character between 'a' and 'c'
Page reorganization
User:Flash200 reorganized the page.
Previously, the top-level sections were
1 Overview 2 Language structure 3 Language design 4 Opinion 5 History 6 Future 7 CPAN 8 Name 9 Fun with Perl 10 See also 11 External links 12 References
Now, the top-level sections are
1 History 2 Philosophy 3 Usage 4 Syntax 5 Resources 6 Availability 7 Opinion 8 Fun with Perl 9 See also 10 References 11 External links
I think we should revert to the previous organization.
People tend to read encyclopedia articles the same way they read newspaper articles. They start at the top, and scan down until they find what they want to know, or get tired, or bored. Also encyclopedias are consulted by non-experts; experts have other resources.
So we should organize the article to quickly provide the information most commonly sought by people who don't know much about Perl. I think
1 Overview 2 Language structure ...
does this better than
1 History 2 Philosophy ...
Swmcd 14:54, 12 January 2006 (UTC)
Redraft 1
I created a subpage, User:Flash200/Programming-language_outline, for discussing the reorg. I removed most of my own comments from this page and added them there. --Flash 04:00, 18 January 2006 (UTC)
- I think you're putting the cart before the horse by making the assumption that programming language articles should all share a common structure. I'm not at all convinced of that. It seems to me that a CPAN section made a good deal of sense for the Perl article to have, and the fact that no other language has it seems like a silly reason to rule it an unnecessary section. On the other hand, a Criticism section makes sense for many languages that are or were in widespread use, but seems a bit odd for esoteric programming languages, say Emoticon or Befunge. I don't understand the need for consistency here. --TreyHarris 07:30, 17 January 2006 (UTC)
- Sorry, I wasn't being clear enough. The template above is a generic one, not specific to Perl. The Perl article would still have a CPAN section or subsection. And some articles wouldn't have a "Criticism" section. The template would be adapted as needed to fit each language.
- In the last several years, I've been adding encyclopedic content about programming languages to my website, and I'd like to migrate as much of that as possible to Wikipedia. Having more consistency and intuitiveness for the organization gives me a better frame of reference for deciding what content should be added where. And it may make it easier for others to work with multiple programming articles as well (reducing the incompatibility between the articles, and reducing the learning curve of going from one article to another). --Flash 18:56, 17 January 2006 (UTC)
I reverted most of the page reorganization. An historical presentation just doesn't give most readers the info they are looking for when they read a programming language page.
It is certainly possible that the page could benefit from some reorganization, but that should be discussed here first, and then applied to the existing structure of the page. Starting from a generic template and then trying to morph it into something appropriate to Perl is difficult and unnecessary.
Swmcd 04:20, 29 January 2006 (UTC)
- Swmcd, I'm not sure your two edits of April 1st are accurate, could you explain them, please? "Alternatively, the interpreter can be compiled to a linked library and embedded in other programs." -> "Alternately, the interpreter can be compiled to a link library and embedded in other programs.". This is an alternative (the other option of two) rather than something that alternates (first one, then the other, then the first). It's also a library that is linked, rather than a library of links. I didn't want to silently revert, even after double checking my own understanding of those words on the OED. SimonFr 14:30, 3 April 2006 (UTC)
- The term link librarary refers to a library of subroutines, suitable for linking with other code to create an executable. So it is a library that can be linked, not a library that is linked. The term linked library isn't generally used; someone hearing that term is liable to ask, "Linked with what?"
- I have to disagree, the term linked library is the one I've encountered more often, with shared library being the most common. I also disagree with your assertion of potential misunderstanding. Library (computer science) mentions the library is called a dynamically linked library. This term is sometimes shortened to "dynamic link library" It may be simpler to use shared library SimonFr 11:09, 13 April 2006 (UTC)
- I'm using alternately in sense 4 given at www.m-w.com
4 : constituting an alternative <took the alternate route home>
- Interesting, the OED doesn't mention this, it talks only about 'taking turns' definitions. Since they're effectively equivalent in US English, and have caused confusion to me, a British English speaker, could we use alternatively? SimonFr 11:09, 13 April 2006 (UTC)
- I always assumed that the term linked referred to the mechanism of referencing more than anything else. You cannot use a function within the library unless you link to it (Therefore the can/is issue is a moot point). Whether this is done statically (ie compile time) or dynamically (ie runtime) is irellevant. the concept of linking is for the library to be loaded into resident memory, providing a list of address pointers where each of the functions are now available to be called. Thus you are linking into this library in order to retrieve the code to run. I think you have the link around the wrong way... it isn't the library which is linked in but the program which is linked into the library. Enigmatical 23:20, 12 April 2006 (UTC)
Listed as a .Net Language?
Is there any reason why this is listed as a .Net language? I have heard rumours that Perl.Net may be on the cards but no mention is made of it in the article and so I am not sure why it is categorized as such. Enigmatical 01:51, 12 April 2006 (UTC)
processor-bound tasks???
From the article:
- Perl is not efficient at processor-bound tasks, and Perl data structures generally use more memory than comparable data structures in languages like C and C++.
This is true of any scripting language, so why is it nessesary to list it specifically as a criticism of Perl? Perl also isn't good for, say, creating an operating system like one would do with C and C++, but that's hardly worth mentioning. 209.92.136.131 20:53, 19 April 2006 (UTC)
Popular alternatives to Perl
Why make people click each link in the Major programming languages box on the bottom of the article when they're looking for alternatives? Perl, Python and PHP are known as the three Ps and should be mentioned as popular alternatives, either in an infobox or somewhere else.
On this page, O'Reilly's Editor In Chief, Frank Willison, says "You can use a number of languages with MySQL and PostgreSQL, but the most popular are the three "P's," the open source scripting languages Perl, Python, and PHP."
I suggest that languages listed in my proposed Popular Alternatives infobox (if a new section isn't created in an existing infobox) be limited to those in the top chart on this page. PHP and Python are in that chart.
Here's the infobox I'd like to add above the Major programming languages box at the bottom of the article:
Popular alternatives to Perl |
Alternative title: Some popular alternatives to Perl.
-Barry- 02:11, 1 May 2006 (UTC)
- See also Python's See also section. I figured an infobox is better for Perl's article since the See also section is full enough. -Barry- 02:19, 1 May 2006 (UTC)
- Sorry but this is just silly. An "infobox" presentation makes it seem like finding alternatives to Perl has some kind of prominence among programmers. Also, it's far too vague: alternatives in what particular purpose? Every possible purpose? You can't even argue that PHP fills that bill; it's a niche language that competes in a small slice of Perl's domain. My first reaction on seeing your box is that it's thinly-veiled, partisan Perl-bashing. So let's not do this. --Yath 03:09, 1 May 2006 (UTC)
- At the very least, I want to fit a "three Ps" reference in here. I wouldn't mind a short description of whatever alternative languages are included, which would mention that PHP isn't as powerful as Perl. I also wouldn't mind if Python was the only alternative listed.
- I'm surprised there's no programming language comparison on Wikipedia. Maybe I'm not looking in the right place. Maybe I'll ad an external link to one. If it's a good one, then an alternatives section wouldn't be as important.
- I think there's a place in this article for Perl bashing, but that would be in the cons section. I think alternatives should be mentioned in every programming language article. Python's article already mentions Perl.
- There are no veils here. I haven't been a fan of Perl for a while, and I'm even less of one lately, but I won't surpress anything good that anyone has to say about Perl unless it's untrue or clearly doesn't fit in the article. -Barry- 03:41, 1 May 2006 (UTC)
I have two main points. Firstly, it's a page-wide box containing just two lonely entries. It looks silly. If you want to mention "the three P's", then do so in the text. No need for a box.
Secondly, there's lots more alternatives as Yath alluded to. Off the top of my head: Bash and Csh for simple scripting, Sed and Awk for simple text manipulation, and lots of other domain-specific languages for web programming (ASP, JSP, SSI, etc...).
I just found Comparison of programming languages but it's pretty bare. You might want to bring it up to the standard of other comparison of... articles. Imroy 09:06, 1 May 2006 (UTC)
- Thanks for the link. I began fixing it up. When I fix it a little more, I'll remove some of those templates and link to it. -Barry- 00:58, 2 May 2006 (UTC)
The infor box is silly but if it were there you should add ruby Htaccess 14:23, 4 May 2006 (UTC)
At this point, the "three Ps" is an outdated concept. The application domain of Perl is shared primarily with (in alpha order): C#, Java, PHP, Python, Ruby, and shell -Harmil 19:05, 8 May 2006 (UTC)
- They're probably the languages most supported by web hosts, and probably the most used for websites, but feel free to add more detail to the article if you think the three Ps part is misleading. -Barry- 08:11, 9 May 2006 (UTC)
- The Web doesn't really have any bearing here (though I'm sure your average PHP programmer would be shocked to hear that). Perl pre-dates the Web by about 5 years and has always had strong usage in systems administration, scientific modeling, reporting, and a number of non-Web fields. As far as the Web goes, however, I think Ruby and Java have certainly made at least as much of a splash as Perl, Python and PHP. C# tends to be used more in the application programming world, but there's a fair amount of Web and data work that overlaps Perl and Python's domain. -Harmil 13:15, 9 May 2006 (UTC)
The problem is that most people don't care about comparing programming languages. Only zealots -- like Barry -- who want to make one language look better than another really care. This is a stupid idea. Pudge 15:19, 18 May 2006 (UTC)