
|
Is Perl the only scripting language you need?
The CPAN rocks thread below got me thinking. Acutally I've thought about this before, but that thread inspired me to acutally write about it.
So why should I learn Ruby/Python/XYZ-scripting-language-of-the day when I already know Perl and I have such a huge resource as CPAN?
The main argument I hear is that Perl is ugly. Well the fact is Perl can be made readable with a little bit of effort so to me that argument is very weak.
Crimson
Saturday, April 10, 2004
I was a PERL programmer. I used CPAN modules to solve projects. I'm (still) impressed with it's power. But's not just ugly: it's strange, it's weird, it's illogical.
If that bothers you then I recommend looking to Python or Ruby or PHP. Otherwise, stick with PERL.
Almost Anonymous
Saturday, April 10, 2004
As AC says, Perl will do anything I need it to do. But making perl clean, easy to read, and easy to understand, is *hard*.
Thay's why my scripts are all Python nowdays.
Snotnose
Saturday, April 10, 2004
I kinda know PHP, and its cool for system scripting and web apps but I couldn't see a way to do Windowing apps. That's why I started to learn Python. So far I like Python and it has several frameworks for windows UIs that are highly spoken of. How 'bout Perl?
Ken Klose
Saturday, April 10, 2004
If you need to build a Windows UI, why not just use VB6?
OK, so you're not as *cool* as if you use Python, but I guarantee you'll get things done quicker. I don't care about being cool though.
VB is built for building GUI's. Python et.al. are just generaly scripting languages that happen to have hooks into the Win32 API available to them.
Can you even get a decent WSIWYG designer for Windows forms for those languages? (Please don't tell me that a designer doesn't make your work go faster, that's bull.)
If you have Python/Perl/etc. code that you want to use, why don't you make a standard/com DLL wrapper that the VB app could use?
Wayne
Saturday, April 10, 2004
Furthermore, any Windows form IDE/builder for Python/Perl/etc. won't be half as good as VB's IDE since it would probably be open source and wouldn't have even half the development time invested in it.
Wayne
Saturday, April 10, 2004
Perl is indeed the most universal language, imho. But it will never be as clear as an specialised language. If you code object oriented you should seriously check out Ruby. It's an awesome language with a very simple syntax. (Which is why Perl 6 will pick up some stuff from it.) Python didn't appeal to me, as I find it has the same drawbacks as Perl while being slower and without cpan. Other people have other tastes.
Jonas B.
Saturday, April 10, 2004
I do alot of work in perl but the perl motto "there's more than one way to do it" makes for some unreadable code. I think python is easier to grasp, has a better object model, and no references (which can be good or bad).
Tom Vu
Saturday, April 10, 2004
> But making perl clean, easy to read, and easy to understand, is *hard*.
Perl lets you express whatever you want: clerity, or tersity. Just because most Perl hackers opt for tersity doesn't mean it's "hard" to make Perl readable--it's damn easy. Just stay away from $_, use statement modifiers, import symbols by name, etc., etc.
On the subject of statement modifiers, they're one of Perl's best features. You never have write C-style crap like this:
if (!some_func())
return 0;
"if not this is true, return zero"
Perl let's you say exactly what you mean:
return unless (some_Func());
$^NAME
Saturday, April 10, 2004
"The main argument I hear is that Perl is ugly. Well the fact is Perl can be made readable with a little bit of effort so to me that argument is very weak."
Do you work alone or with a crew of highly capable programmers who believe in writing readable code? Or do you work with mostly average programmers who have the attitude "it works, I don't care"? If it's the latter, you'll be better off with something other than Perl.
Yes, one can write ugly code in any language, but some languages encourage ugly code more than others.
T. Norman
Saturday, April 10, 2004
The "problem" with Perl is that it puts a lot of responsibility on the programmer. You have grow up professionally to a certain point to be able to take responsibility, and many occasional or hobby programmers never will.
Speaking of reading others code, I get to see *a lot* of code written by others. And it's always very nice for me to know that the system I'm going to fix/modify is written in Perl. A much better chance the original developer knew what he was doing.
Learn Python or PHP to get your feet wet with scripting, then learn Perl to get real work done effeciently. I'm glad I did.
Egor
Saturday, April 10, 2004
Well, for my view.. Perl was the first scripting language I learnt, and it's probably the one I know best. For any quick hack or anything under 100 lines that I think is cool to do (quick automation, grab something off the web) Perl is my automatic choice.
I don't want code clarity then, I want to finish the job.
I know Python, I like the language.. and I'd probably use it if I had to, but it doesn't have CPAN. For me, the only reason to really use Python is wxPython. Yes, there is a Perl port, but I don't like how Perl integrates wxWindows widgets, Python does it in a much cleaner, intuitive fashion. Almost anything else in Python is replaceable with Perl.
For UI stuff on Windows, I use C#. I have never learnt VB, and I can just barely read Basic code. I played with Delphi a bit, if I really had to, I'd use it too, but C# serves my (admittedly modest) needs in the UI area.
For everything else... there is Java :)
deja vu
Saturday, April 10, 2004
err.. one addendum. For anything webby, I'd consider Perl (mod_perl or CGI), PHP and servlets, depending on many factors. I haven't used PHP outside a webserver yet. Not sure if there is a need for it, for me.
deja vu
Saturday, April 10, 2004
REBOL, folks. REBOL. (look it up)
Likes long walks, short piers
Saturday, April 10, 2004
Use watcha know. Unless there's the slightest chance that someone else will ever have to understand your code. In that case, use watcha know unless it's perl ;-)
Forth rules.
fool for python
Saturday, April 10, 2004
"So why should I learn Ruby/Python/XYZ-scripting-language-of-the day when I already know Perl and I have such a huge resource as CPAN?"
Speaking as JAPH, I think learning other languages is a good (and required) thing for several reasons:
1. Learning other langauges can show you other ways to do things, and teach you new ways to think. Learning various ways to do things is wjhat Perl is all about.
2. Learning other languages makes you more valuable to an employer (or potential employer). It shows you're ready to learn things, aren't afraid to learn new things, and will even learn new things on your own time.
3. Learning other languages can help you understand Perl things better. Playing with Tkinter opened my eyes to a couple of things with Perl/Tk. Dabbling with Common Lisp taught me a few new ways to look at arrays and hashes.
There's more reasons, but those are my favorites. Just remember, it's easy to say, "All I need is Perl" today. However, who knows what you'll need a few years from now.
Andrew Burton
Sunday, April 11, 2004
I never bought the argument that perl is ugly. I've yet to see a language which makes building a 2 dimensional array prettier than:
my @matrix = (
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
);
or a language that makes declaring a hash of hashes prettier than this:
my $users = (
matthew => {
age => 29,
country => Australia
},
bob => {
age => 25,
country => UK
}
);
It it would be even prettier if I could use a monospaced font here!
Matthew Lock
Sunday, April 11, 2004
Whoops the above should read my %users = (...
Not enough coffee!
Matthew Lock
Sunday, April 11, 2004
I am also addicted to this perl feature. You can use symbols other than quotes if it's incovenient.
For example instead of:
my $html_string = "<input type=\"text\" name=\"name\" >";
I can go:
my $html_string = qq{<input type="text" name="name" >};
Now to me, that makes for a pretty piece of code.
Matthew Lock
Sunday, April 11, 2004
Mathew, you could also use single quotes so you
wouldn't need to escape the double quotes.
son of parnas
Sunday, April 11, 2004
Matthew,
With Ruby:
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
users = {
:matthew => {
:age => 29,
:country => "Australia"
},
:bob => {
:age => 25,
:country => "UK"
}
}
The scope of the variables can be changed with @, @@ and $ depending if you want them to belong to the object, class or global variable, respectively.
The hashes can have any object as key. I used "symbols", as they are internalized strings (only one copy of the string is stored).
The Perl version has a little edge in its hash creation, but I think Ruby's is not bad as well.
Dewd
Sunday, April 11, 2004
With Ruby:
html_string = %q{<input type="text" name="name" >}
Dewd
Sunday, April 11, 2004
No wonder that some say that Ruby is Perl done right.
Giovanni Corriga
Sunday, April 11, 2004
Alrighty! How about this insert query for pretty:
$dbh->do( qq{
INSERT INTO users ( name, address, phone, email )
VALUES( ?, ?, ?, ? )
}, undef,
$name, $address, $phone, $email
);
AND perl's DBI will autoescape the variables to be substituted so there's no chance of an sql-injection attack.
For the record I have nothing against Ruby. I'm just trying to demonstrate that the freedom Larry Wall gave with the perl syntax means you can make some extremely pretty looking programs.
Matthew Lock
Sunday, April 11, 2004
Real programmers program in machine language.
A Real Programmer
Monday, April 12, 2004
http://ruby-dbi.sourceforge.net/
dbh.do( %q{
INSERT INTO users ( name, address, phone, email )
VALUES( ?, ?, ?, ? )
},
name, address, phone, email
)
I urge you to take a look at the site, as they have an example using Ruby features.
Don't worry about the usual libraries, Ruby has all of them.
Dewd
Monday, April 12, 2004
Matthew, regarding:
"I've yet to see a language which makes building a 2 dimensional array prettier than:
my @matrix = (
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
);
Check out Dyalog APL, or J (J Software), or K (Kx Systems), where the above is written more or less as:
3 3 r i 9
where r is the reshape function "rho" and i is the index function "iota". In APL, i and r are greek letters, in J and K they are simple ascii characters like #, but the concept is the same. In all three languages, r and i are primitive functions built right in to the language.
alberti
Monday, April 12, 2004
Recent Topics
Fog Creek Home
|