Forum Moderators: coopster

Message Too Old, No Replies

How easy is PHP to learn?

And is it as stable and useful as PERL?

         

MatthewHSE

2:26 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi everyone, this is my first post in this particular WW forum.

I know HTML and CSS quite well now, and have a very basic knowledge of javascript (in that I can edit simple, pre-written scripts to better suit my needs). I was thinking it's about time I learn some real scripting, however, and am undecided whether I should tackle PERL or PHP first.

From my understanding, PERL is more stable but PHP is faster. Is that correct? Also, how do they compare in ease of learning? If anyone has any good (free) online references to suggest, I'd love to hear them too.

Also, my site already uses PERL scripts exclusively for my member-based community features. If I learn PHP, will I be able to write scripts to tie in with my PERL scripts?

I know these are all newbie questions, but I figure that's appropriate in this case since I'm as "newbie" to scripting as they come! :) Any and all advice will be appreciated.

Thanks,

Matthew

Xuefer

2:55 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



php first, and never perl
perl is a bit faster than php
but perl language is written for god to read, not human
trust me

the more u learn perl, the more excited u get, and the more time(devel time) u lost.

grnidone

3:07 pm on Aug 20, 2003 (gmt 0)



I found perl to be intimidating: there are *so* many ways to do any one specific thing in perl.

I found it difficult to find any 2 tutorials in perl that did the same thing in the same way. Maybe I didn't completely understand the author's tutorial in one program, so I'd want to go to another tutorial to double check or get additional help. Well, in perl, that was near impossible: every person did the same task in a little different way. It was just too much.

I found PHP much easier to learn: if I didn't understand what one author was saying in one tutorial, I'd just go to another one.

rcjordan

3:09 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>php first, and never perl

Perl first, never php. Perl ports everywhere.

MonkeeSage

3:20 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP = Perl: Hypertext Parser, no?

If you can understand PHP, you have the basics of Perl (like shell script)...that's how I've understood things anyhow. I don't know PHP at all and only know enough sh script to task some things in Linux, so mabye I'm incorrect here?

Jordan

Nick_W

3:47 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>Perl ports everywhere.

You want to trust your apps to a windows box? - Sure it ports, sure it's robust, blah blah... in terms of RAD PHP just floors Perl IMO.

Nick

Timotheos

4:26 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP = Perl: Hypertext Parser, no?

Um... no.
PHP = PHP: Hypertext Preprocessor
It's a recursive acronym

This is from the FAQ at php.net. I think it's a fair assesment.

4. PHP vs. Perl?

The biggest advantage of PHP over Perl is that PHP was designed for scripting for the web where Perl was designed to do a lot more and can because of this get very complicated. The flexibility / complexity of Perl makes it easier to write code that another author / coder has a hard time reading. PHP has a less confusing and stricter format without losing flexibility. PHP is easier to integrate into existing HTML than Perl. PHP has pretty much all the 'good' functionality of Perl: constructs, syntax and so on, without making it as complicated as Perl can be. Perl is a very tried and true language, it's been around since the late eighties, but PHP is maturing very quickly.

My 2 cents... Start with PHP. Go to Perl if it's not meeting your needs. Once you know PHP I don't think you'll go on to Perl but I've seen many Perl code monkeys come over to PHP.

Vermont

4:42 pm on Aug 20, 2003 (gmt 0)

10+ Year Member



I have to agree - Perl was not spcifically created for the web like PHP.

PHP coupled with MySQL can do anything I have ever needed and I have done alot of programming over the last 4 or 5 years using it.

It seems alot of Perl users end up switching to php for their web work, but you do not see PHP'ers switching to Perl as their major web programming language.

MonkeeSage

5:05 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Timotheos:

Um... no.
PHP = PHP: Hypertext Preprocessor
It's a recursive acronym

What is the second acronym?

I don't know anything about PHP (except what I see posted on the forums here), and from my niave POV is looks exactly like sh script embedded in HTML with XML tag syntax.

Other than the fact that it is directly embeded in HTML and doesn't have to print the HTML explicitly, what are the main differences between Perl and PHP? A different naming (variable) convention? A different method (function) convention? Something else? ... Help out the ignorant if you would be so kind. :)

Jordan

claus

5:19 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good quote from the phpnet. Perladdict myself, but i always find myself among coders doing php and they just don't get it... i mean there's no structure, you'll never know what others have written, collaboration and bug-fixing is so much more difficult, it's so geeky... and where's the cvs? ...sort of things they tell me...

I do run Perl on windows as well as *nix, no problem... don't know the RAD acronym though.. Anyway, if you think that you'll probably be working on projects with others, and if some of these could be big and complicated, go for PHP. If you just plan on writing code for your own use, choose the easiest...hrm..php again i suppose...

Stable? Yes PHP is stable. I usually compare it to ASP and not Perl. ASP seems to have capacity/scaling problems but not PHP. I've seen large-scale sites built with PHP and also with ASP, the first worked. Perl? well, no problems, although bad coding do give bad results and there's always more than one way of doing things... Isn't this forum Perl based btw? at least partly?

No matter what you do in php you will also be able to do it in Perl. I'm not sure if this holds the other way round but you have to do some serious pushing of boundaries before you're even close to being there i guess. Quite impressive stuff can be built (and fast too) with PHP if you're skilled. I think the great benefit to PHP is that it's more like a traditional structured scripting language so you'll be up to speed relatively quick and be able to re-use knowledge from one area in another. It just does the trick and that's it. Perl has a very steep learning curve... it's just hard, and it keeps being hard (for new things) even if it gets easier.

Well, actually i've been considering learning some PHP myself lately, just like the other monkeys... with a basic understanding of Perl, JS, VB, and a bit more, it's not really hard it seems... anyway, using a dot for append is plainly un-civilized so i've postponed it again ;)

/claus


added:

>> different naming (variable) convention?

The word convention is key, imho. In Perl, there are always more than one way of doing things. Of course there's some data types and some operators, but the rest is really rather...well, fluid...

Strings... that would be it. Perl's very good at manipulating strings and i doubt PHP can match it, just consider your basic regexps...

[edited by: claus at 5:39 pm (utc) on Aug. 20, 2003]

rcjordan

5:32 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perl is the lowest common denominator in server-side scripting. If you're assembling tool scripts or snippets that you want to run anywhere/anytime and can count on the possibility of being able to find a perl coder that can comprehend someone else's logic (not an easy task) anywhere/anytime in the future then perl's the way to go. This isn't just an anti-php sentiment either, I've paid good $$$ to have proprietary compiled scripts dumbed-down to perl.

Timotheos

8:22 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP was originally a Perl hack. That oughta tell ya something :-)

I find it's history really interesting - see
www.php.net/history

I love PHP's online manual with user comments. Is there an equivilant in Perl?

jatar_k

8:45 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



learn both

Which is easier to get started with?
probably PHP

Which is more intuitive in a web based environment?
probably PHP, given that it is made specifically for that environment it only makes sense.

Don't get me wrong, perl was built to do anything anywhere, and it can. ASP would be a better choice if you are psecifically a windows/IIS programmer

why? because it was made for that specific environment.

Actually learn some asp while you're at it and maybe a little coldfusion and some jsp. You can never really be familiar with too many languages.

very intuitive answer claus

claus

9:19 pm on Aug 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RAD... if that's Rapid Application Development i agree with Nick_W 100%, PHP is faster - at least for larger applications where more people are involved. Couldn't edit my post above, so i had to repost..

/claus

Jatar_k i've been working alongside PHP-evangelists for some years before i went freelance, so i've seen quite a few miracles and small wonders - i have not joined the church myself as i don't earn my living doing programming, it's just a tool to me ; )

jamesa

9:48 am on Aug 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know both languages but use PHP most of the time for web work (vs command line scripting).

One reason is that you put your PHP code in your HTML page rather than visa-versa. Advantage is not needing to escape quotes or whatever in large blocks of HTML code.

Another PHP advantage is the pre-built functions and features. One example is sending email - it's a one-liner. Another is reading POST or GET variables. I used to write 12 lines of code to do that in Perl - not required at all in PHP (I know there's libs in Perl to do that that but it's still simpler in PHP). And there are tons of things like

nl2br()
which replaces line breaks with HTML BR tags, or
mysql_escape_string()
to prepare a string for insertion in a database, etc... you'd need to do stuff like this manually in Perl.

Documentation. Yes, there is tons of Perl documentation as well (a lot more probably) but I just find PHP's documentation (www.php.net/manual/en/) more centralized and easier to use.

PHP is probably easier to read, though that's really a Perl advantage. With Perl there's more than one way to write so you can shorthand things quite a bit. Convenient if you know what you're doing.

But again with PHP you don't need to set file permissions, you don't need to put the path to PHP on the first line (unless it's installed as a CGI), and you don't need to preface you're browser output with

print "Content-type: text/html\n\n";
.

Ultimately it's down to preference and the type of work you're doing. I just prefer PHP for the majority of the workaday web work.

trillianjedi

11:07 am on Aug 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Slightly off topic, but if you need the power of Perl and want something a little more powerful but easier to use, consider using Borlands Delphi for building webservices. Cross-compatible with Kylix too, their compiler for Linux. And the latter works on freeBSD too.

I've been playing with it quite a bit again lately (used to use it a few years ago). My partner in crime built a nice little database webservice with it the other day in a couple of hours. It's extremely powerful as, being able to develop OS apps, you can actually interface a hell of a lot more than you could in .php. We have an application that reads and writes to .ini files on the server and ports to the website, and queries and sends information to other running applications, again via the web. That got knocked up in about 1/2 hour.

I also built a webserver with it the other day, from scratch, with it's own scripting language (specific to controlling an application online from a web-browser and allowing people who know a little HTML but no .asp or .php to create their own pages and just drop in variables and buttons etc to control a Windows app on the server so they could "skin" it), in about 3 hours.

TJ

claus

11:41 am on Aug 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> is not needing to escape quotes or whatever

You just have to escape these three afaik: @ % $

Just use the command print like this:

print <<"(END HTML)";

Then it will print anything until it meets (END HTML) on a separate line.

/claus

jaski

11:49 am on Aug 21, 2003 (gmt 0)

10+ Year Member



PHP
If you need to become productive within days and web development is all you need to code for.

Perl if you have more time and patience :)

timster

12:37 am on Aug 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There seems to be a bit of vitriol here between PHP and Perl camps. That's silly. (Maybe the fighting is so fierce because the langauges are so similar.)

BOTH languages are guilty of rampant TMTOWTDI (There's More Than One Way To Do It). That tends to make the language easier to write and harder to read. (But smart people like you can still read them. Reallly, no deification is required.)

I learned Perl a while ago for text munging and use it sometimes for CGI. After learning Perl, PHP was easy to pick up. Now I find it very convenient for Web development. And all the cool kids are learning it.

Perl is also very useful for CGI, because it has been there for a long time and there's miles of script that you can download and use.

So my advice is: If you like to build things from the ground up, learn PHP first. If you like to grab existing code and beat to up to suit your needs, learn Perl first. Then learn the other.