Forum Moderators: coopster

Message Too Old, No Replies

Is Php the new duct tape?

Less and less perl posts here...

         

lexipixel

3:16 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have been noticing less and less posts here (WebmasterWorld 'Perl Server Side CGI Scripting' board), and more and more posts in the Php board...

If you are (or "were") a Perl Programmer and have moved to Php, please throw a comment in here giving a reason or two...

Easier to develop for?

More code available?

Easier to install?

More call for php work?

Better editors / tools?

Other reasons?

DrDoc

5:03 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am one of those Perl programmers ... Although I have not "moved to" PHP, I use both Perl and PHP daily. So, let me give you my personal opinion on the questions you asked:

Easier to develop for?
Not really. I find both Perl and PHP easy to develop for. True, there are certain things which are built-in into PHP which you have to do manually in Perl. But, on the other hand there are other things which are much much easier to do in Perl. PHP may have a simpler syntax in some ways, but Perl is still easier and faster for more demanding tasks. Then again, for a mostly HTML driven site where scripting is just used to enhance and bring in some form of dynamics -- PHP is easier, especially due to the ability to toggle between PHP and non-PHP mode.

More code available?
Nah. More built-in functions, yeah (including very useless ones too). Then again, in Perl you can sometimes perform more than one task with a single function, whereas you have to resort to separate functions in PHP. If you count functionality available via Perl modules, there's definitely more code available for Perl than there is for PHP, hands down. PHP also lacks functionality which Perl (and many other languages with some level of self esteem) include. Try running SHA1 on a string in PHP without also getting the optional hex encoding. Great, we have to _decode_ it. Lame.

Easier to install?
Try more _difficult_ to install. Perl is a breeze to install on any platform. PHP can give you some headache at times. Then there's the endless recompilation/reinstallation of PHP if you want to add functionality. In Perl you just add a module on the fly and you have immediate access to even the most advanced functionality (advanced cryptography, for example). Let's not even begin discussing getting certain expanded functionality working in PHP on Windows, for example. Perl, no problem regardless of platform.

More call for php work?
Not really. It is just so readily available. Also, most sites which require dynamic functionality really do not call for advanced features. It's a little print here and there, an occasional database query, etc. No need to pull out Perl for that ... especially since so many incorrectly find Perl to be an inferior language. That's just because they don't understand it. PHP is good for the average site, though. And, average sites are definitely in majority.

Better editors / tools?
Nah. They're the same. If anything, it is easier to accomplish local mapping (to preview dynamic functionality) in Perl.

Other reasons?
I think the Perl vs PHP issue is very similar to the whole [insert windows scripting language] vs [insert windows scripting language].NET. Many think that simpler syntax means better for coding, or that "if I can more easily read the code" that it would be better. PHP was designed to lower the barrier of entry into the scripting/programming world. But that doesn't make it better, nor does it make it worse. It does, unfortunately, allow people who should not be programming in the first place to do it. And whoops, we have security holes and poorly performing code. There's nothing worse than thinking that you are a programmer when you really aren't. ... I can't tell you how many times someone with a tad of PHP knowledge has asked me for some outrageous complex functionality and then been upset when I tell them how much it will cost to develop (and I still consider myself employing very reasonable pricing). So then they hire some highschool kid who develops something. Not only does it take 10 times as long, but it doesn't really work. Then I have to come clean it up, and start from scratch. A little bit of knowledge can be dangerous.

[edited by: DrDoc at 5:05 pm (utc) on Sep. 27, 2006]

coopster

5:15 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I still use perl and other scripting and compiled programming languages, just much much less nowadays. My preference for server-side work is PHP. It likely comes down to development speed for me.

I think you are going to find your answers as diverse as the programming language field, lexipixel.

I suppose another draw may be that PHP has certainly risen in popularity in the past few years. Prior to that it was often difficult to find big names putting any *umph* behind the development tool, or any non-propietary tool for that matter. However, in the past few years you are seeing more and more support from everywhere, including some of the bigger names in the software industry like IBM and Oracle.

So when it comes right down to it, why do I use PHP? Because I like it better than the others ;)

lexipixel

5:33 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Exellent reply DrDoc.. (geez, I hope people don't think you covered "it all" and think their $0.02 won't add to the discussion).

"..It does, unfortunately, allow people who should not be programming in the first place to do it. And whoops, we have security holes and poorly performing code."

- DrDoc

This has been a primary concern for me -- security.

A 'fer instance' for me: a site which allowed uploads. Unfortunately, the upload script didn't verify the <input type="file"...> data well enough, and someone uploaded a php file. The server was configured to process php by default --- what the hacker uploaded was a Php control panel type file --- instantly they had full access to the entire site. Luckily they just did a home page defacement and tagged it for their trophy case (and didn't hijack the site, redirect it or worse)... I don't think this could happen with Perl -- they would have needed a password that allowed them in to set the permissions. That single incident scared me off of Php for a while, (although I do occasionaly use it now on low risk sites when I need a simple bit of dynamic data and perl would be overkill).

lexipixel

5:36 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks for the reply Coopster, (you posted while I was commenting on DrDoc's post).

coopster

5:39 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



But that can happen in any language, can't hang it on PHP.

Long before the web this problem existed. However, there were management teams in place, internal quality assurance testing, etc. Now, you have "the independent developer who is programming for the web". Who is validating that work? You better feel good about who you are hiring for what reason. If you are allowing file uploads, secure access, etc. you had better be certain you have a good developer. I don't care what language they are using, PHP or otherwise, this problem exists. If you think you are seeing more and more of it in PHP then that is likely because of something which DrDoc alluded -- the popularity and widespread acceptance of the language. I've done my fair share of cleanup in other languages myself, perl included.

Chico_Loco

7:27 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to learn PHP now, but I'm having a terrible time adjusting to the way variable lexical scopes work (I think that's the name of it).

In perl, if you set a variable ie. $abc=1, then it's available everywhere (global, unless you use my). But, in PHP, that's not the case, and I just can't figure out how to exchange data between functions.

Can anyone shed some light on that?

Anyway - so far it seems that php has the advantage of being embedded in an HTML file, whereas perl has the advantage of maturity and elegance. I'll have to reserve final judement until I become more proficient in it.

henry0

8:42 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Chico_Loco look HERE [us2.php.net]
and search for class/function/scope

Back to the main topic

Aside its functionality there is probably also some hype surrounding PHP
It’s a well covered topic, many tutorials and books.
Not to go against Dr Doc but if you ask around about PERL, you will get may times an answer (Possibly uneducated!) stating that PERL is tougher than PHP to learn.
As far as capability with PHP5 PHP stands closer to high languages,

New comers are subject to be attuned to surrounding as Coopster mentioned PHP is also very popular among the big guys.
If you are looking at any *nix system you will almost de facto be exposed to PHP

Further if you are somehow in the web biz you made an habit of checking URLs
And many end by PHP :)

DrDoc

10:06 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not going to disagree with the statement that Perl is tougher to learn than PHP. That is a fact which I agree with. But once you know both -- then it all comes down to the speed by which you can develop new code, make changes, maintain it ... especially with multiple developers involved.

If varying skill levels among multiple programmers is an issue, PHP definitely lowers the barrier.

henry0

10:50 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dr Doc approached it earlier; such a topic has two sides
A) You are a seasoned programmer
B) You are a beginner in server side

lexipixel

3:23 am on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just thought I'd note; I posted the original post in the Perl Server Side Scripting forum -- one of the mods moved it here.

I posed the question(s) mainly due to the fact that there have been less and less frequent posts in the Perl forum. To me, it was an indicator that there was starting to be less interest in Perl.

I prefer perl and don't trust Php (yet)... but like to keep an eye on the future.

RonPK

1:19 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My 2 cents: I never did much programming in Perl - the horror of working with some vague cgi-bin directory, file permissions and weird shebangs didn't really attract me. My major experience in Perl was modifying the infamous but nevertheless hugely popular formmail.pl. That script of course shows that Perl is not inherently secure.

To me PHP was attractive as at the time it seemed easy to learn, even for someone with my modest programming skills.

timster

2:27 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I work with and like both Perl and PHP, so no partisan here. For the OP's original questions, I agree with the other posts that those aren't the reasons compelling PHP's inroads into Perl "territory."

Although I don't believe PHP is completely displacing Perl, I think it might be the new "duct tape" already. (Perl lovers embrace the "duct tape" moniker, but Java boosters don't use it as a compliment.) But these days I always use PHP for those small, quick & dirty web projects.

Perl is a little-endian language -- one where you can start using it productively without understanding everything in the "Programming Perl" book -- but PHP has it beat in that regard. I know web designers who have started using PHP knowing only how to use the include command, and have just gone on from there.

Like a lot of folks, I prefer embedded web code like PHP. Although I use Embedded Perl, not all web hosting companies support it. So PHP has an advantage these days when portability is important.

I find myself using Perl for some larger web projects (where Perl's "use strict" pragma makes finding syntax errors easier) for ETL and text munging, and for automated jobs.

jatar_k

5:54 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the thing is php was made for the web

perl wasn't

each has it's place but php has a lower learning curve, which is a help as much as a hindrance, and if you want to do something on the web the odds are it has a built ion function for it.

the availability of mod php is very good, mod perl, not as much.

Easier to develop for?

very similar, though if you are brand new to coding I think php is simpler.

More code available?

probably more code around for perl since it has been around so much longer. Though for the things that newcomers are going to likely want to do with their websites, php has a function for it.

Easier to install?

both simple

More call for php work?

not really

Better editors / tools?

same I think, though debugging php, I believe, is much more straight forward

Other reasons?

take a look at the cultures, everyone uses php but perl coders are real geeks. I think that the php community is a little more comfortable for people who don't classify themselves as programmers.

coopster

6:10 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> but perl coders are real geeks

HEY! I'm not sure if I'm offended by that yet or not ;)
Forgiveness can be purchased at PubCon Vegas

DrDoc

6:16 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



... whereas PHP coders are just geek wannabes? :)

And, yes, PHP debugging is so much easier and more intuitive.

wruppert

3:43 am on Sep 29, 2006 (gmt 0)

10+ Year Member



I love Perl, but as mentioned, it runs like a dog without mod_perl, which is unusable in cheap shared hosting environments due to security problems. So people migrate (and now flock) to the otherwise inferior (imho) PHP.

ergophobe

4:58 pm on Sep 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hey, I was taking a swing through the old neighborhood and saw this. I don't have anything to add and don't want to divert the thread, but Chico_Loco, if you want a very elementary explanation of scope in PHP, you can try this thread [webmasterworld.com] (go down to message 1256687).

For the record, though, duct tape is the new duct tape - excellent for every task except one... taping duct work, where it actually failed miserably in recent tests by someone (consumer union, fine homebuilding, something like that). PHP on the other hand, works quite well for the task it was designed for.

moltar

1:49 am on Oct 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am surprised nobody mentioned Perl's secret weapon -- CPAN. There are literaly thousands of modules to do anything from simple text manipulations, to complete database abstraction to biological formula calculations. Sometimes I come up with some crazy idea, and think to myself "I wonder if there is a Perl module to do that", and 7.35 out of 10 times there is!

There is also an awesome framework that's growing by the day that is definetely worth mentioning - Catalyst. It simply kills ROR and similar frameworks.