Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Perl vs Python revisited

by kel (Sexton)
on Feb 05, 2017 at 20:26 UTC ( [id://1181147]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl vs Python revisited
in thread Perl vs Python revisited

As a pure acolyte for the past ten years, when I finally took note of the need to have a good scripting language for my online business, and began writing perl spaghetti code to get simple jobs done - recently I had an epiphany.

I was having difficulty with a Perl text parsing script that 'normally' works but was utterly recalcitrant at renaming some files.

Now, please understand that I am not a programmer. Typically I hack scripts as templates to get them to work. And after enough time they normally always do. This script was an exception. Homegrown.

I tried for about two hours oin Python to get it to work. No luck. Tried Ruby, and in a few minutes it was working fine. It was my one and only time I have ever written a Ruby script.

I realized that I had a lot of programming to do in the future. I am planning on coming out of semi-retirement (assuming the economy improves) and overhaul my web sites, as well as creating a specialized library catalog for over half a million etexts.

But at that fateful moment with Ruby I had a sudden enlightenment. I have dabbled with trying to learn a host of other languages. C is simply monstrous and needlessly repetitive for my needs - its Assmebler with labels.

Java is someting I have come to hate. I have worked in multiple Java projects, only to find it pointlessly confusing and bloviated.

There is something likable about Python, but its hopelessly cracked for me. Its main strength lies in what people have done for it (modules), rather than what it can do technically, at least as easily with Perl. Mind you I speak as a dabbler, and not a pro.

Ruby showed me outright that i needed to spend as much time and effort as possible mastering Perl. Which I have been doing for the past two weeks. Relearning it from v5.10 basics. To me at least, Ruby is Perl Lite geared for OO. I have very little need for OO, which I see as needlessly complicating for non-production scripts.

My point in this meandering gibberish is this: In the past few years Perl has arisen from the dead, and nobody noticed. But most importantly, unlike Ruby and Python which seem to have decent, if not strong neophyte communities, for Perl the only site with sufficient traffic to avoid continuous necroposting is here, Unfortunately this site can be a bit intimidating for new users.

I spent the majority of last night looking for a simple forum to ask dumb questions on perl. Sorry but IRC and mailing lists are simply out for me. No way, no how. I also noticed the forums with the heaviest traffic seemed to be PHP. My experience with my web site and its support forum is that the majority of PHP users are not programmers. Hells bells, even apparently the majority of web site *designers* are not programmers.

The average person does not understand what TIMTOWTDI(sp?) means and the utter personalization of styles that Perl allows, allowing one to write utterly obfuscated, to essentially GW BASIC code. I proudly use the GOTO statement, for example. I do not write my scripts for peer review. However when I do share code, Perl allows me to spiffy it up, and become more easily readable by non-programmers. Its syntax, when not using unnecessary shortcuts is actually quite readable. Even a few *years* later. Larry is after all a linguist....

An humble suggestion would to create here amongst the giants, a *playground* where strict and warnings are left at the gates, and new folks are encouraged to play around with the code and grow with it, and even personalize it to their languages and cultures. Even a MyBB type subforum for those who find the interface here a bit inscrutable, like I did for many years.

I also believe the playground should include Rakudo, especially as with it, Perl does not seem as cracked as the forks of Python. I dont use any 'fancy' techniques in my scripts so I dont forsee any problems with Inline::Perl5, but then again I am still installing it. Its repo is painfully slow.

Replies are listed 'Best First'.
Re^4: Perl vs Python revisited
by stevieb (Canon) on Feb 05, 2017 at 23:45 UTC

    Great post, and I'm glad you shared your findings!

    One nitpik though:

    "An humble suggestion would to create here amongst the giants, a *playground* where strict and warnings are left at the gates"

    That likely won't happen on many people's watch here, as use warnings; and use strict; *force* you to write proper Perl code. Essentially, it helps the code writer identify really, really simple mistakes that could cost them hours upon hours of heartache wondering why their code doesn't do what it's supposed to, and eventually quit Perl to move to something else that has these specific checks and bounds on by default.

    I do agree that we need a playground, but I'd still be pushing folks to use the two mentioned pragmas.They are there to help even the most experienced Perl hackers avoid silly avoidable mistakes, and when a newcomer asks questions, it avoids a lot of delay if they run it under them.

    Also, I don't know if you're aware, but Rakudo is the VM for perl6, which is quite a bit different than perl5. That said, to have a playground for that here too would be great.

      TIMTOWDY (or however its spelled!)

      There are THREE main ways to do things, including programming. The Right Way, The Wrong Way, and the Casual Way.

      Perhaps an example: When I work on my websites, I always script and test everything under Win in XAMPP. The reason is that there I dont have to worry about permissions problems. When everything is working as I want, then I will port to Linux, and if problems pop out - I then check for permissions. The idea is to save time and bother of not have to check for a problem that might not show up.

      I prefer to use Perl rather than Bash scripts, many of which are simply throwaway. And this is one of the greatest strengths of Perl. Now, on my single user network, without servers normally running, including SSHD nearly always turned off, and remote access disabled, security issues are a hindrance, and not a feature. EVAL is a necessity for me, and undeclared/unused variables are not an issue at all for the needs I have. The beauty of Perl for me is that I can write code in a sequence that is readable to me, And I can follow it years later. It is not however, 'proper programming'.

      I see a world of difference between scripting and programming. I need to strip files of everything after the first semicolon, dump into a file, sort it, and remove duplicates. I can probably do this in 5 minutes, and it is going to look ugly. Variables from quick testing all over the place. Properly, it would take a half hour or more as I check the purity of syntax, comment it, and make it production ready. I'll forget where I put it, and should I ever need the function again, I'll simply rewrite it.

      However, I would never use this method, or even Perl for accepting Internet connections. There security, strict, and warnings are absolutely required. And I still would be averse to the idea since I simply do not know enough about Perl networking.

      This is where the gulf between scripting and programming come into play. At one time Perl was popular among young folk using CGI to play around hacking old dotcom era websites. These days, what do people *play* with. Young folk are apparenty attracted to Ruby because its structure is even more linguistically oriented than Perl, while the hacker folk apparently like Python, because its 'easier' to play with net connections there. Perl has the magic of CPAN, for doing almost everything, but it aint magic when the instructions for using the modules are written in technobabble as obscure as a man page. It took me hours to decipher the docs for Net:: Ebay. Actually, I never did. I pulled some scripts out of the modules package and used them as examples for what I wanted. Less than half of them still worked. Old.

      Formal rules and structuring have their place in programming, but can be a hindrance to creativity - especially when one is trying to program on the spur of the moment. I would be the first to fully agree that in writing real programs that 'proper' techniques be used, especially if they are ever going to be shared. But most of Perl's potential user base will never write a program. Especially when it becomes obvious how superior Perl is to tradtitonal tools used in shell scripting. For these folk, myself included, a proper enforcement of rules would mean not permitting a system call to rm -rf \ *. Not a complaint about unused command line argument variables.

      As to Rakudo. The way I see it, I have two versions of Python here, two versions of Ruby, 2 versions of mySQL, countless versions of Java, so an extra version of Perl is no big deal, regardless of what its called.

      Perhaps whats needed is another pragma called <SCRIPT> where maybe Carp like warnings may be given as suggestions, but the program is allowed to run its course so users can *see* the errors in the output which is much more educational and may be actually more useful in certain applications, such as using deprecated versions of old scripts.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-03-29 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found