Forum Moderators: coopster
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
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.
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.
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.
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
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
>> 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]
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
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 ; )
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.
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
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.