Re: Perl Pros and Cons: Syntax and Modules (Was: Larry Wall Talks, Perl and Lua)

Hi Octavian,
File handles:
Octavian Rasnita wrote:
> I like more the old style because I never need to pass file handles to other
> subroutines, and the old style is shorter.
Fair enough. And the old style let's you say
print outFile $stuff; # which is always nice.
 
Error handling:
> but I make very many dirty short programs that do different things that need
> to be ran only once maybe,
The exact same thing here, I use Perl a lot for this kind of thing. If
I'm being absolutely lazy I either use the fatal module with open and
close, or else wrap the whole thing in an eval block and print out
errors. I also use the magical <> file handle and the $^I switch a lot,
see perlvar.

Subs:
> I never used prototypes in the subroutines I make, maybe with the exception
> of Catalyst actions, because in the perldoc I've read that the recommended
> way is to not use prototypes.
They are a bit problematic. I'm trying to avoid using them these days.
The only situations I use them in include:
- passing a code block argument without the sub keyword, as in map.
- for functions that need to work with true arrays or hashes only, as in
pop or push, however this is rare.
- if a function has very many scalar arguments and I need compile time
checks of the right number being used

Comment style:
> > =pod
> > code here
> I do that, but I can't say that I like it.
> Using a comment like #[ ... ] would be good at least for the fact that we
> will be able to jump easily from the beginning of the comment to its end,
Agreed, though you could always jump via regexp matching in an editor
e.g:
^=cut  or any pod command:
^=\w+

> but I don't like it because it is not standard, it is not used in other 
> languages
True, but then again neither is the use of /*** ***/ exactly standard.
It is just a wide convention that particularly popular languages
happened to have used. Lua uses --[ and --] in stead using # as a length
operator. If PErl didn't use # it could be the symbol for hashes, since
SUpernova says it hash anyway. I don't like braces myself, Ruby and Lua
using words is, to me, much preferrable with speech. e.g:
for i = 1, 10 do print(i) end 


> Beeing more different would mean that it would be harder to learn
Right, but commenting is easy enough, no matter which convention you
adopt. In small things I second you on borrowing syntax from other
languages if there's not a reason to be diffferent. Perl borowed the
hash comment from shell scripts, make files and other Unix tools that it
is much closer to in mentality than C. Since Perl aims to please
everyone it has never been ment to be easy to learn completely, however,
the idea being you learn a subset you need and also providing a lot of
extremely useful  power that you need only occasionally. I'm a big fan
of hash slicing especially in multiple assignment with qw lists.

> companies don't like when they need to use a language that's
> used by very few programmers
But Perl does have advantages, such as easy integration with Unix tools.
It was designed to replace shell scripting and I think it has somewhat
succeeded in that in a cross-platform manner. I think Perl is best at
niches such as shell scripting, biology, text processing etc... Not as a
general purpose language like Java, or as an easy language for, say,
teaching programming. But then again, it was never ment to be either.

I think Perl is even gaining some ground in Windows via ActiveState and
Microsoft. FOr the first time in their scripting compo, Microsoft had a
separate category for Perl scripts.

> choose PHP or Ruby or Python instead of perl, because they might be simpler
> to learn.
That's true, but as I said, being similar to the rest would not keep
Perl Perl. It has never aimed to compete directly wih Python, the way I
see it. RUby has most of hwhat's good in PErl and Python, to me, yet
feels Perlish. I hope PErl 6 manages to keep PErl Perl yet make  the
basics of OOP and other aspects as straiht forward as Ruby, while
providing wonderful new perlisms.

Thanks for your soap explanation, I don't know enough of how it works to
be able to offer much valuable input at this point. But I've heard that
the problem of the .NET runtime not suiting dynamically typed languages
very well is not Perl specific, though Perl seems to suffer most from
it.

> I try to study the module POE in order to create multi tasking cooperative
> application thinking that it could be easier than using a multi process or
> multi threading style,
Possibly, Lua has such a system built-in as a module, by the way. I have
yet to understand it properly, however, I think the basics of Java's
threading were real easy to pick up. YOu just implement runnable.

> WxPerl is not so light, but it has many more features than Win32::GUI, and
> it is also portable, at least partially. And it has UTF-8 support.
Nice, and looking at the project page it is being updated quite rapidly.
HOwever, how did you learn it, i.e. where can I get proper Perl specific
docs? I also find it strange that it is not part of the ActiveState PPM
repositories yet. I'm planning to give it a spin when it reaches 1.0.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila
__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

Other related posts: