Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which one is better: PHP, Perl or JSP?

Status
Not open for further replies.

littlegirl

Programmer
May 28, 2000
2
0
0
HK
Hi all,<br>I'm going to develop an application with IPlanet as the web server and Oracle8i as the db server, both on solaris platform. I've not yet decided which lang to be used for implementation. I'm new to the 3 langauages. Could anyone please give me advice on which one to use based on their compatability, performance and learning curve on the above platform? Thanks!
 
I can't comment on PHP or JSP but I use Perl to read and write Oracle databases all of the time. I use the DBI (DataBase Independant) module to connect to the Oracle database and I've found it to be completely reliable and very easy to use.<br><br>You can get DBI from <A HREF=" TARGET="_new"> you'll also need the Oracle backend (The DBD, DataBase Driver) for Oracle.<br><br>You won't have any difficulties running Perl scripts on one machine that connect to a DB on another.<br><br>There's an excellent mailing list for users of DBI, just follow the links from <A HREF=" TARGET="_new"> to the DBI web site.<br><br>Obviously you'll need to check out PHP and JSP to see if they meet your needs, sorry I can't help you with either (never heard of them actually &lt;grin&gt;).<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Please -- Don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
Well here is my thought on it.
I would definatelly go with php. Ok, first of all Java Script is ok, but as you know it takes forever to load, basically you have to transfer all the material and execute it on your local machine. That is not much an issue on the machines with faster connections, but 56k just won't cut it. Regardless I don't suggest JSP. As for Perl, its not bad, but it has certain limitations. For example, search (any kind) is always going to be slower in Perl, and in general its slower than PHP. Also depending on your server (and this is the case in 99% of the cases) you have to execute scripts under a cgi-bin directory, and it has to be enabled by a sys admin, and that can be lengthy timewise. Also you will have big long urls, something like
stuff.cgi)
Most of the web servers won't (at least the ones Ive worked on, won't let you execute a perl script (stuff.pl), you have to change it to stuff.cgi (minor thing, but annoying). Also most modules need to be installed by the sys admin, so that consumes time too. As for php, you can execute it anywhere, its very quick and great if you are ever going to deal with databases or big searches. And you can just execute it in exactly the same fashion as the index.html, just instead of html extention, it need a .php or php3, or similar extention. Basically your server needs to support php scripting language, that is it.

I hope this helps
 
I'd go with perl. I don't believe that perl is slower at anything, it's got capabilities that far outreach any other language I've ever worked with, and it's not that hard to learn (although most perl programmers never stop learning about it). The DBI and DBD modules are very easy to use (a few basic statements and SQL), and if your ISP won't install them you may be able to install them in your own cgi directory. I disagree with yuflesh about the .pl vs .cgi issue too. I've worked with a number of ISPs and never had to rename a perl program to .cgi (but so what if you do). You should be able to upload any program you want to your cgi directory and execute it. As for the long url issue, so what? It may be a few extra characters to type, but the additional capabilities are worth it. Granted, I've never used PHP, but then again, I use perl, so I have never needed anything else. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Littlegirl:

Like tsdragon, I don't think that perl is slower than PHP.

First of all, perl has the ability to do extremely fast regular expressions. I have never seen a language come near the power that perl has with regular expressions.

I have worked with both PHP and Perl, and both of them are nice, easy languages to learn.

PHP is chock full of built in functions (over 1800, I believe), so if you are just getting started, its nice, while perl has a little of 200.

But it also depends on what you are doing.

If you are going to be doing hardcore database interaction, then Perl might be better. PHP has basic SQL functions for almost any database, but like tsdragon said, the perl DBI has not been matched by any language yet.

Well thats just my input.

Hope this helps,
-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
Hey. Just learned Perl about 3 months ago, and just learned PHP (basics) about a week ago. As everybody else pretty much said, they're both pretty easy to learn.

It kinda comes down to what you want to do with your site and how you'd like to maintain it. The main difference between Perl and PHP is that PHP seems to have been designed specifically as a tool to build powerful websites, whereas Perl has been adapted to that purpose. Thus PHP is probably a slightly higher level language than Perl, and so the code looks just a bit cleaner--mainly because of (as Vic said) the gobs of built-in functions. In order to reap strong performance from Perl, you must know how to write and optimize these functions, otherwise you'll find yourself constantly complaining on sites like this that your query takes ten minutes to run and can anyone explain why. Bottom line - if you can hire a good Perl person, you're better off using Perl, but if you are starting from zero with both languages, PHP will be easier.

We decided to use PHP for a couple of reasons. First, using both Perl and PHP to connect to an Oracle 8.1.6 database, PHP was noticeably faster for us. PHP also has a very decent Oracle/OCI8 library, that is useful for hiding low-level details. Second, none of the folks in my company have a huge amount of experience with this, but cgi scripts are rumored to be less secure than PHP. Of course, whether or not it's at all possible to build a &quot;secure site&quot; is arguable, but PHP has gotten less of a bad rap.

Both are extremely enjoyable languages, and very useful. I recommend learning Perl anyway, as it can do just about anything!!!

Good luck! Brad Gunsalus
Cymtec Systems, Inc.
bgunsalus@cymtec.com
 
Funny seeing this thread pop up again.

Anyway -- since May last year...

Under some circumstances standard Perl is slower when used for building a web site - not really anything to do with Perl being slow, just the overhead of starting a Perl process everytime a Perl script is run.

However, Apache has a way around that with a builtin Perl interpreter that is always in memory.

I can't comment on whether it's faster or slower than PHP but, as long as a language isn't *dog* slow, that's a secondary consideration.

More importantly

-- Why wouldn't you use what you use at the moment? You already know about that....

-- Which development environment will give you the best results in terms of speed of development and supportabilty?

Having said all that, it would still be Perl for me. :) Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Well, having come from the PHP direction but enjoying (immensely) learning Perl, here's my $.02:

I know very little about JSP, other than what seems to be a consensus out there: it has many powerful possibilities, and it comprises a more formally &quot;proper&quot; way to handle things, but it is a resource hog. However, when it comes to PHP vs Perl, I like to think of it in terms of PHP+Perl, because each has it's strengths, and they tend to complement each other well.

The main benefit of PHP over traditional Perl(CGI/mod_perl) is that you can embed your code right into your HTML documents. If you've spent a lot of time working in a cgi-bin environment, and that's what you are used to, the benefit of this might not be immediately obvious. The main point is flexibility. I can use any server-side or client-side condition I want to affect not only the data available to a document, but how any individual HTML element gets displayed. I know you can do this with SSI, combined with CGI scripts, but imagine the overhead of having 35 server-side includes sprinkled in your HTML document (or you could just choose to output all of your HTML from CGI). But PHP accomplishes this with effortless grace. (In fact, there are some hints that on some occasions, with the Zend Optimizer, PHP can output HTML with variable interpolation faster than Apache can output a flat HTML document. This ease of embedded code, combined with a very clean syntax (similar to Javascript) makes PHP a very natural language to learn for those coming from a web-design background. I am aware that there are a couple of efforts at providing a Perl &quot;HTML preprocessor&quot; system (embperl, Mason), but they just haven't really caught on.

However, I agree that when it comes right down to it, There is no programming task that cannot be accomplished (in more than one way) with Perl. Especially anything needing regular expressions. In the last project I worked on( we used PHP for most of our &quot;front-end&quot; type routines, but when we had a serious piece of work to accomplish, we rolled out Perl. MyStickyWeb is a web-based web design studio, which uses Javascript/DHTML to handle client-side WYSIWYG design in IE5. Once IE gets its hands on HTML, it tries to make it IE-only, so of course we had to do a lot of *fixing* of the HTML output to be DOM-compliant, and cross-browser. I ended up using PHP to handle tasks such as dynamically filling in user data, etc... and rewriting the document based on conditionals, but to process the HTML files being saved from the browser, we used Perl. We didn't even need to use Perl as a CGI executable, since we just exec()'d the standalone Perl script and passed the HTML to the script, which in turn parsed the HTML, fixed it, saved it to the right directory, fixed any problems involving absolute/relative URLs, and copied the images to the appropriate directory. We found this to be an excellent synergy.

So my recommendation is: learn both PHP and Perl (they are not too different). It's a good world for a web developer right now. With Perl/PHP/Apache, you can make anything happen ;-).
 
Wonderful posts, folks. I'm quite thrilled to be a participant. So here are my thoughts.

It's kind of funny to me how JSP is obviously the odd-man-out in this thread. JSP is the infant language to web application development and was born upon paradigms vastly different from those of PHP and Perl; object oriented as opposed to procedural or functional, strictly typed as opposed to contextually typed, etc. And as people who have apparently been in the web business for a length of time and have befriended the adult (or at least adolescent) languages, Perl and PHP, I think we tend to look upon this newcomer as a sniveling, perhaps contemptable, child. But, taking into account that object oriented programming was acknowledged by the ACM as a vital skill and promotion of it is thus required among their accredited universities, and that most of these universities (at least in America) have adopted Java over other OO languages like Python or C++ to fulfill this requirement, I think it's quite reasonable to assume we'll be seeing much more JSP on the web as time goes on and the virtual machines get faster. Therefore, it would seem that it's an important language to learn. In regards to present practicality, however, it's likely not your best choice unless you've grown up on the OO paradigm... And then it's still probably not the best choice, because Python has a similar structure, but moves a lot faster. The only time I would consider it your best choice is when:

a) You already know the Java API better than the back of your hand; better than the front, even.
b) You intend to program your application with a lot of room for error (I think it goes without saying that Java has some of the best exception handling available).

That said, let me offer up my comparison of PHP and Perl.

As rycamor noted, PHP and Perl have a similar syntactical structure and may, indeed, compliment one another. They both have database abstraction layers (PEAR DB and DBI), they are both portable and they both have an extensive set of functions for web applications (even if Perl's was a bit of an afterthought). By all means, learn them both!

But here are a couple of warnings.

It has been said that one of the major benefits of PHP is the ability to embed the code within your HTML. I believe that this is trivial (that's polite, actually I totally disagree). The problem with doing this is that people get in a habit of coding poorly. HTML is a linear language -- you open a tag, write some text then close the tag, always in that order -- and too often, people extend this linearity to their PHP code. Application directed languages shouldn't be treated like that. A resulting program would probably require the tracking of numerous operations and variables that are most likely all in the same scope and even more likely are overwriting one another. Managing this type of code later is an unbelievable nightmare. Therefore, the best way to treat PHP is as a functional language -- lots of subroutines and very little logic within the html itself, almost templatized if you will. Therefore! Since Perl is commonly used in this way, PHP is essentially the same and the benefit is null.

PHP has poor (read: no) debugging and precautionary measures. With Perl, you have &quot;use strict&quot;, &quot;use warnings&quot;, &quot;#!/usr/bin/perl -w&quot;, &quot;use diagnostics&quot;, &quot;perl -d&quot;... These modules/commands not only assist you with tracking down problems, but also enforce good coding habits (not using global variables, creating prototypes, using references). While PHP may get you by in many cases, Perl is more likely to help you become a better programmer.

Okay, so with everything on the table, my suggestion is this: Learn Perl first. With it, obtain some good habits. Always, always &quot;use strict&quot;. Now learn PHP. It really is a wonderful language, despite the arguments I've made against it in this post. Use the knowledge that you've earned through Perl to write awesome PHP applications. Now learn Java and its subsets JSP, Javabeans and Java servlets so that 3 years down the road, you have a job waiting for you and can point and laugh at us poor Perl programmers sitting on the sidewalk with guitars, harmonicas and change jars.

Hope this helps,

brendanc@icehouse.net
 
&quot;poor Perl programmers sitting on the sidewalk&quot;

Hmmm..... <smile> Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
what a thread!

I've done Perl/CGI stuff for several years now and recently picked up PHP to play and learn. I basically agree with sophisticate's views on Perl vs. PHP. I have found Perl to be extremely flexible, object oriented when I needed it to be, and very powerful (talking to various databases, playing with regex's, cooperatiing with mod_perl, etc...).

I share sophisticates reservations about PHP. If your web pages will be well defined up front and are not likely to change much, then HTML/PHP is a very valid choice. There are indeed sites that behave that way. However, my experience is that no client ever really knows what they want their site to do. Rather, there is a struggle to identify and pursue ever changing goals. Consequently, I have not used much PHP. It does not seem to lend itself to swapping/adding/deleting chunks of functionality as easily as I would like.

Again, I second sophisticate's suggestion. Learn Perl/CGI/mod_perl/DBI::DBD and then learn PHP. You may/will find instances where the PHP is well used. But, you can't make good decisions until you have some alternatives.

humbly submitted for your consideration
or
my 2 cents


keep the rudder amid ship and beware the odd typo
 
I agree with Sophisticate's point that a program should separate it's presentation layer from it's application layer. The presentation layer (HTML and images) can then be designed by an art-minded HTML designer, while the application layer (the logic and input/output) can be worked on by a programmer.

It also makes systems a million times easier to debug, upgrade, and reuse. The benefit of PHP is lost then, from what I know.


I had to learn Java as well as a big steaming pile of other languages in college. I thought Java was too strongly typed, requiring a lot of coding to do something relatively small. I've been using Perl for 3 years now in the web business, first on Unix and now on win32. Perl is the best so far for dealing with strings, and that's what web pages and web database work is mostly about.



-k
 
This may be just me, but isn't it odd that littlegirl has not responded or said thanks for the help?

I dunno, kinda is odd that people spend a long time (especially on these massive posts) and the author does not come back and say thanks.

Is anyone else annoyed by this?

-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
Not particularly. If you look at the initial thread date, it's May of 2000. We're about a year late and I doubt she really cares. Hopefully this thread is useful to other passerbys, though.

brendanc@icehouse.net
 
..... it appearently took a new member to resurrect this thread.....:~/
I hate it when that happens..


keep the rudder amid ship and beware the odd typo
 
Yes, PHP can blur the line between logic and presentation. Obviously something a lot of hardcore programmers don't like. I will say though, for me that feature has been a lifesaver at times, because it simply gives me a little more control.

However, in further discussion, applying to any web scripting language, I am not so confortable with the typical &quot;separation of presentation and logic&quot; argument I keep hearing. Templates are great for large websites which will have many pages of similar data outputted, for example: e-commerce websites, online product catalogues, etc... I agree that for most dynamic websites, separation of presentation and programming is the goal, but I also wonder if that approach isn't sometimes a little limiting.

My interest is in specialized web application programming and intranet software. In other words, I'm not talking about the typical e-commerce website, weblog or online product catalogue, where a templating system is of obvious benefit. Also, in the kind of work I do, there is not so much need of an &quot;artist&quot; or designer using a WYSIWYG editor to handle the front end, because the front end is not a web design but a GUI interface. Ergo, in this situation, the programmer is also the designer.

For example, how could I efficiently use a templated presentation system to handle cross-tabulated table output? Also, what if I need every aspect of the HTML output to be conditional, such as &quot;only display this textbox if that record has not been updated&quot;, etc...?

I have found that for my purposes, it's much more beneficial to go the &quot;other way&quot; and make everything a function of programming logic (as much as possible). Just about every type of output involving a database, or anything involving forms is wrapped up into object methods. Eventually, I plan to use an O-O approuch to output all the &quot;static&quot; HTML for my applications. In these situations, once my library of routines is in place, I can control *everything* through programming, with no need of HTML WYSYWIG design. I have made progress in this area using PHP, but I am now researching how to do similar things with Perl. Fortunately Perl has a large library of modules that already handle similar functions.

Some may say this will place unnecessary processing loads on the server, since all output will be parsed. I say that in return for speed of coding applications, I will take the trade-off. (this is also another plus for PHP, by the way, because with products you can pre-compile and cache your code for more efficiency).

Any thoughts on these ramblings ;-)?
 
Let's just say each has it's own advantages as well as disadvantages. -Honestly, I would go with Perl since PHP has no text file databases and they need to use SQL all the time...
Anyways, here's some info i got it from the web:


Perl
Perl is not only a Web-scripting language, and looking at is as such only shows a microcosm of its true nature. Perl is, at its most basic level, a text-manipulation language. It provides powerful features that allow the user to easily do some operations that are very complex in C, and also complicates some other things that are easy in C! Perl, in conjunction with CPAN (the Comprehensive Perl Archive Network) offer an enormous amount of &quot;ready-made&quot; modules, that allow code to be reused and shared- database interface modules, CORBA modules, scientific calculation modules, network programming modules, SGML/XML/HTML modules, and so much more. Obviously, because of Perl's powerful and easy text manipulation functions, it was quite natural for web developers to expand their toolbelt to include Perl. Perl can be embedded within HTML documents, run as an SSI (Server-Side Include), or run as its own application (CGI, or Common Gateway Interface). Perl, as applied to CGI and web application design, is designed for the programmer who wants to &quot;output&quot; webpages. A Perl Web application is nothing more or less than a backend program, that interacts with the browser using HTML.

PHP
PHP is an embedded scripting language. A PHP-aware webserver parses HTML documents looking for PHP code, processes it, and sends the results back to the browser. PHP's popularity lies in the fact that it is easy to use, and is readily embeddable into HTML documents. Using PHP in conjunction with your favorite HTML editor is an increasingly popular way to provide dynamic web content, with minimal programming. In effect, PHP separates web design from application design. I've worked on a couple large PHP projects where the HTML designers were not even part of the application design team. PHP is developed with the web, and web development in mind.


 
I never thought I would see the day someone referred to a text database as an advantage over SQL ;-), but PHP can easily read and parse text files, and even has a built in function called fgetcsv() which &quot;Gets line from file pointer and parse for CSV fields&quot;. (
I will agree that the question of &quot;better&quot; is kind of like asking &quot;which is more important, eating or drinking?&quot;. I do firmly believe that between Perl and PHP you have the best of all possible worlds in web scripting. For 99.9% of what you do, either one will produce great results. For that .1% (which is often the most difficult), you have to weigh the advantages of each. The real question is which feels more comfortable to you in what you are doing, since the most important thing is getting your job done.

(But there is just that magical something about Perl that no other language has...)
 
No, i'm not saying that text databases are better than MySQL. I'm just saying that perl will even gives a newbie programmer chance to use the database by using the text files as databse. Again, each has it's own advantages and disadvantages.
 
Well the original poster was using Oracle :eek:) so neither MySQL nor flat-file db access are an issue here... but not like anybody should care, because she asked the question about a year ago :eek:)<br><br>I have one thing to say, and one thing only, in defense of JSP, something that I haven't seen above (although I must admit I haven't read this thread as thoroughly as possible -- it's just too long).<br><br>JSP has been mentioned as a resource hog. Also, it has been mentioned that Perl can be a bit slow, as CGI requires that each server request causes the script to be executed from scratch. I haven't heard anybody mention that JSP doesn't have this problem... if you've already executed a command, the overhead is rather low from there on out. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top