PHP, Perl, Java Servlets - What's Right For You? 254
Sean writes "Take a look at this comparison of Server-side scripting languages. The article explains how PHP scripts, Perl CGIs, and Java servlets work. It can help you decide whether to use PHP scripts, Perl CGIs, or Java servlets for your next Web development project. It also covers the issues that separate the three languages and provides all the source to test their differences." Right tool, right situation. That's all I have to say.
Re:PHP rocks... (Score:1)
CF on Unix? No thanks. (Score:1)
I've seen CF tie into JavaScript a lot, yeah. However, this brings with it the requirement that JavaScript be present. While I realize JavaScript being present is a safe assumption for most users, I don't consider it a safe assumption in web app development. Even if it is there, it's very difficult to do anything meaningful in JS without writing it once for each browser you want to support.
I've also seen whole application suites written in CF (A first mistake) that use _only_ JavaScript for data validation (A second mistake). As a result, if JavaScript is off, or if it isn't written correctly for each browser, the app either simply breaks, or data gets send to the queries (Or in this case, sprocs) unvalidated, creating messy DB error messages.
CF does have one last gasp at a future, though. They're working on converting the language into a set of JSP custom tags, which would free it of the poorly designed CF server, and tie it to a language that does have a solid future (Regardless of if we like it or not, Java is indeed not going anywhere for quite awhile).
Re:Crappy article (Score:1)
Re:Perl vs PHP - the answer is easy for me (Score:1)
What the hell is wrong with the PHP interpreter?
It is not as widely-distributed on the systems I work on as PHP. And unless I'm mistaken, #!/usr/bin/php is a fairly recent thing; before the generic interpreter was available you had to use phpcgi or some damn thing.
Re:Perl vs PHP - the answer is easy for me (Score:1)
No offense, but you seem to have a fairly loose understanding of PHP at best.
This may be; I haven't seriously looked at the language in over a year now.
If your programming is good, modular, and loosely-connected, your script will not care whether it's running on the web or on the command line.
Okay; I've got Perl installed on all systems I work on. PHP is (was) installed only where it made real sense: on the webservers. Why would I write Perl modules to do some fairly generic work and then rewrite them in PHP to take advantage of them for the webservers? Or why would I write a PHP class which did something great only to find out later that I can use it on another system without PHP and have to rewrite it in Perl? I simply settled on one scripting language which I feel is more superior.
And I'm not sure where you got the idea that perl doesn't use an interpreter...
Actually I didn't say that. As I wrote to another person who replied, #!/usr/bin/php is a fairly new development IIRC. Before that you had to use phpcgi or some damn thing which I'd written off as a hack to make PHP more useful outside of webspace. If it indeed has gotten a generic interpreter that's great. In my eyes I've crossed that bridge. It's too little, too late. The languages are too similar to me to warrant "perfecting" both.
Don't get me wrong, I like perl as much as the next guy...but this holy war assumed-condescension is silly.
Agreed. PHP makes some things easy that Perl doesn't either. And the general syntax is cleaner IMO as well (I come from a C background). But this entire article seemed to be the breeding grounds for a holy war and it was late, so I thought I'd fan the flames a bit. :-)
The DBI argument gets more specious by the day, too. Check out PEAR. Or PHPLib. Or Metabase.
I can create a connection, run commands and get results generically with DBI. Yes there are vendor-specific extensions, but the base calls are the same. A year ago PHP did not have this. There were pg_* calls for Postgres, mysql_* calls for MySQL, msql_* calls for mSQL, etc. Yes there were generic ODBC drivers but hardly anyone uses them if they're working on a high(er) performance system because vendor ODBC drivers are notoriously slow. DBI fixed that.
There are lots of valid reasons one could give to prefer perl over PHP, or PHP over perl, or emacs over vi, or milkshakes over spaghetti...but what you've written are not among them.
I don't see how my post didn't give any valid reasons. I stated my own reasons and here I've backed them up further.
As I'd said, I started out as a PHP guy. Loved it. Then I started wondering why I was learning two languages that were very similar, did pretty much the same jobs but one was more targetted to web apps. So after some careful consideration and a few posts to various Ask Slashdot's I made my choice. And I really don't miss PHP, which indicates to me that it was a good choice to settle on one scripting language, and (IMO) the more versatile and powerful one. That's not meant as a flame against PHP; it's just a direct observation on my part. I've not been able to prove that PHP is significantly easier, faster or different to warrant learning it.
Perl vs PHP - the answer is easy for me (Score:1)
Perl. Why learn two languages when one does 99.9% of it without breaking a sweat? Seriously. PHP has umpteen number of DB interfaces. Perl has DBI. No matter what you talk to it's all DBI and it's fast. Regexps? OO? Parsing? PHP and Perl both have them but why write your modules once in PHP and then have to redo them again in Perl just because you want to use it outside of the web?
Yeah I know about the PHP interpreter but that's just plain old hokey. And to think I was once a really avid PHP guy. If all you're doing is web, PHP is really sweet. But really when you think of it you have other things to do too... parsing logs, reformatting, search and replace... things that get done on a daily basis and are beyond the scope of "just the web". Write the module once, write it good and use it in all situations!
Re:Perl vs PHP - the answer is easy for me (Score:1)
Actually, most hosting companies I've dealt with use PHP as a CGI, not mod_php, so they must have the /usr/bin/php someplace, but they may not make it available to you that way (they probably don't give you shell access anyway).
I thought PHP, like Perl, got most of its speed when run as mod_php (like mod_perl) -- I thought a lot of the overhead was loading up the interpreter for every script access? Have I really missed something here?
Actually, it's not terribly new, afaik. I was using it a couple years ago at least, so I know it's not 'new'. I'm not sure if it was available like that in PHP2, but from mid versions of 3 on I can attest that it's been like that.
Hmmm.. I remember reading about having to do some hoop-jumping to get it to run as CGI. I could be mistaken though. I appreciate your response and maybe in the future I'll take another look at PHP.
Re:PHP rocks... (Score:1)
So its pretty clear. PERL users like leatherman tools, PHP users prefer traditional single purpose tools. Or maybe not.
Definately maybe not. :-)
I hate leatherman tools except as a "where is my... oh fuck it, I'll use my leatherman" type of scenario. Proper pliers, proper screwdrivers and proper nailclippers are essential to me. Hell I can't even stand the dozen-in-one screwdriver sets half the time!
To me, PHP is tailored to the web and is breaking into the generic system interpeter market. Perl owns the generic system interpreter market but has uses in the web world. In my opinion Perl has a better chance at the web market than PHP does in the system interpreter market, but as I said, it's my opinion. I really haven't seen much of a speed difference between mod_php and mod_perl, I happen to love Perl's OO setup (10000000x better than C++) and although it causes me headaches from time to time, Perl's regexp abilities are far more flexible than PHPs.
Re:Perl vs PHP - the answer is easy for me (Score:1)
The brunt of my objection is against the propagation of the notions that a) PHP doesn't make sense other than on the web, and b) that PHP has no database abstraction layer. Of course, the fact that it works fine as a general tool language and has database abstraction doesn't mean that you should use it if you'd rather use something else, since other tools will do it all fine too.
Alright. At the time I was looking at PHP, it didn't make sense for anything but the web. After looking at some of my older systems and seeing that PHP was indeed available as a generic interpreter I do have to apologize; it was ignorance rather than solid fact that led me to the conclusion that PHP is just for the web.
Regarding the abstraction of database access -- I had never heard of nor was there mention of Metabase or Pear::db in the online documentation regarding database interaction when I was learning about PHP. This has changed and this is a good change in my opinion. It will bring more people to use PHP.
In the end, I do feel rather foolish with my previous "sentence by sentence" comment. I was (still am) in the tub and the tone of your comment set me off. I don't ever think I'll look at PHP for my own use but these changes will make it a better language for others to decide to use.
Re:ASP? (Score:1)
Re:ASP?? (Score:1)
Re:ASP is doubleplus ungood? (Score:1)
ColdFusion and thinking far inside the box (Score:2)
ColdFusion is a joke for anything beyond the stereotypical database plug-in-dynamic-text-here site. Which is fine, that's exactly the market Allaire (Now Macromedia) targets CF to. The guy with the little static website describing his car repair shop and what sort of services he offers. CF to the rescue! Or something.
But let's say you want to pass around relatively complex data with CF. Well, CF arrays are limited to three dimensions, and you have to declare how many dimensions you want ahead of time. ColdFusion's idea of a list is a delimited string. As a PHP coder, I literally laughed when I read through a book of CF's support for "complex" data types. It was utterly pathetic. But, CF gets away with it because people that CF appeals to don't need that sort of power.
Me, I do. So CF can go collect dust next to the NT server I don't need either.
Re:Use what you know (Score:2)
Besides, I think it helped get me my new job :-).
Eric
--
Re:Use what you know (Score:2)
I'm also wondering why this article compared PHP and Perl to Java Servlets, rather than JSPs (which are a little closer in concept). In practice, Venice uses a combination of both--servlets for front-end processing, and JSPs for easy output formatting.
And, of course, the Java architecture leaves me open to employ new techniques at a later time, such as object relational mapping (using projects like Osage [sourceforge.net] or ObjectBridge [sourceforge.net], both of which are similar in concept to the commercial product TopLink), embedded scripting (using an engine like Rhino or Jacl, or, yes, Jython), XML/XSLT rendering (using Xalan or something similar), and other techniques, both those that are part of J2EE and those that aren't.
But, in the end, I agree with you; use what you know, and use what you think works best. Other people may prefer something other than Java for a Web site project. Fine by me; I'm not running their projects, and they're not running mine.
Eric
--
Re:JavaServlets (Score:2)
Python, which similarly has REs as a set of procedures (well, classes) instead of being part of the syntax, does this much better. It's a nearly trivial addition to the language: you put a r before the string, and \'s don't get substituted, like r"\w+\s+\w+". It makes a big difference, and really easy to add to a language.
Another annoying part is that PHP doesn't document their regular expressions -- merely says "oh, read the Perl manual, or POSIX definition or whatever." That's just intensely dumb, it makes it look like PHP is just a poor copy of another language. They really ought to fix that.
Python/Webware (Score:2)
I've been using Webware [sourceforge.net] lately, which is a Python servlet engine. Very similar to the Java servlets, except without a lot of the verboseness that Java demands. For Python there's Zope [zope.org] as well, but I found it unwieldy, and not very Pythonic.
Re:Perl vs PHP - the answer is easy for me (Score:2)
Then it's irresponsible of you to be spreading myths about something you admittedly don't understand fully.
Okay, I'll call you on that one. Where am I spreading any myths? I gave my opinion and several reasons behind why I have that opinion. But let's take my original post on a point per point basis and you show me where I'm spreading myths. I don't even think you read the second comment after the first sentence.
So now... Show me where I'm spreading myths. If you can't, then please retract your statemnt that I'm spreading myths. After all, anything else would be irresponsible.
ASP gets unmaintainable pretty fast (Score:2)
developerWorks focuses on Open Source tech (Score:2)
As a writer for IBM's developerWorks [ibm.com], I have a good reason why Microsoft's ASP and Allaire's Cold Fusion products weren't mentioned in that article. The editors reject references to non-open source applications.
Also, ASP is, at best, a weird framework for CGI development. It supports a number of languages like ActiveState's PerlScript, but the default language is the demon-haunted VBScript. If there's one language that demonstrates ad hoc design, it's this one. Two incompatible assignment operators? Thanks!
Lest you think I'm casting aspersions wontanly, I do help maintain the ASP XML-RPC library [sourceforge.net]. My ASP pain is real.
Re:Of course no ASP (Score:2)
--
Re:Computer scientists like Java??? (Score:2)
And that's exactly the point - purists. I have come up against a number of these fascinating creatures in my time. Their ideology is so fixed you just give up and ignore them. One project I was lucky not to be on, one such purist wanted to send radar feeds over RMI "because that is the way it must be done in an OO world". Let's try tracking 1000 different objects at 20hz and shuffle that over the ideologically pure way. This project ended up being 2 years late (from an original 18month timespan) and went on to use C++ and raw sockets as the communication mechanism.
You wonder why languages like C++ and Java are winning the mindshare of the developers over "pure" languages like Eiffel and Smalltalk? Stupid comments like this, and the people that make them are the bane of a commercial software developer's life. I have yet to see one actually produce a real, working system (and I've run across probably a couple of dozen or more in my code-development life). The reason - complete inflexibility. There is only one "true" way and all others are punishable (and yes, I've seen them try that trick with management).
So, use the right tool for the job. That tool is the one that gets things up and running and maintainable in the fastest amount of time.
Re:I don't hire "Java Programmers", even for... (Score:2)
--
Re:Sorry, one more thing . . . (Score:2)
The typing is too strong? I pulled out my copy of the Revised Report on Algol 60 and looked again. There are three types in Algol 60 - Boolean, Integer and Real, and arrays on those. Since it automatically converts between Real and Integer as neccessary, and doesn't check the type of an array you pass in to a function, I don't know how you know the language and can claim the typing is too strong.
In any case, do you oppose all old languages for their misfeatures? It's not like any one really uses Algol anymore . . .
Language choice depends on a lot of issues, and there are several strong choices
Like what?
It was the right choice then, although not today.
Proof by assertion. Very convincing.
I know of financial stuff done in many other languages, so I think that's phoney, anyway.
Understand Turing machines? Of course you emulate Binary Coded Decimal in other languages! The legal issue is that the interest on $103,355,883,888.97 must be accurate to one cent. That's longer than a C long on 32 bit machines and doubles would introduce illegal rounding. In COBOL you define a BCD type with two digits to the right of the decimal point, and 18 to the left, and go on with your life.
Hm, very narrow-minded (Score:2)
Re:PHP vs Perl vs JSP (Score:2)
Re:PHP vs Perl vs JSP (Score:2)
Re:Apples and oranges (Score:2)
I started my own comparison of various programming languages at my own personal web site. I go over perl, php, asp/VB (some), java, javascript, C and C++. I compare a few different things. Mainly I discuss the basic similarities / differences of these languages like the for loops, while loops, if statements, functions, types, and then I get into how each has its own definition of an 'object'. Yes C sort of has objects they are structure. Not a 'real' object like C++ or Java but it is similar.
The point is that anyone can learn any language once they have learned one language. The big differences in the languages are the 1) syntax, 2) garbage clean up (or lack of) and 3) the ease of programming. Lets face it pointers are not easy and objects can be difficult as well.
Personally I think what language you pick should be more dependant on what you feel comfortable with. JSP has the drawback that it is not part of apache, so if you are running apache each JSP page needs to have a call made to tomcat (or whatever you use) which means you have to have a socket call outside of apache. Perl / CGI meanse you have a new process forked for each page (why the hell did he not say mod_perl instead). Neither php nor perl have string 'types' but you can 'force' types if need be.
In case you want to see my review go here -> http://www.mindspring.com/~joeja/programming_myth. html .
I'd love constructive critism on this so I can improve the comparison and correct any mistakes that I may have made.
I don't want a lot, I just want it all!
Flame away, I have a hose!
Re:Code-in-html vs. html-in-code debate is over (Score:2)
Re:PHP rocks... (Score:2)
No, I have no intention of substantiating this claim. I don't need to because I only made the determination for myself. I tested PHP and Perl about 2 years ago, and found PHP to be slightly faster when you combined all the time factors (time to learn, time to develop, time to deploy, time to run). I didn't keep the result data because I didn't need to as I got the answer I needed and no body was offering me money to publish an article with the results. So I summarized into my own memory what those results are, and found PHP to be slightly faster overall.
Re:ASP? (Score:2)
Thanks. These are good links with good info. Now I can see better what I am up against with with I am developing. While I don't expect to be as grand as they are, it's good to be able to see other points of view on those other web tools.
BTW, for others doing cut & paste on the URLs, there is a space in the middle of each one that needs to be deleted first.
Re:Sorry, one more thing . . . (Score:2)
I use long long in C. It handles up to $92,233,720,368,547,758.07. Even Bill Gates would dream of having that much money.
Re:Sorry, one more thing . . . (Score:2)
Algol did not let me tweak any of the types.
You're still using 32 bit integers?
Re:CGI is not a scripting language (Score:2)
I guess people just quit using it. Maybe it exited.
Re:ASP? (Score:2)
Then write a better article that covers ASP along with the others. And while you're at it, toss in some more languages. I'd really like to see a solid, well written, point by point comparison, from someone as experienced as yourself, about all these language choices (although I have made my own choice already). Such an article would surely find hosting space almost anywhere, but if not, contact me.
Re:Sorry, one more thing . . . (Score:2)
I happen to be doing most of my web stuff in C (and the rest in PHP). If I needed arbitrarily recursive macro substitution, I wouldn't be using C. Guess what: I don't need that. That's not to say that someone else won't, and if they do, they should have access to good language choices.
Part of what goes into language choice is the way you think about problems and how their solutions are implemented. I happen to think strongly procedural. Don't try to justify why I should think some other way, because it won't happen ... I'm referring to my human nature. We're all different in one way or another. If you've chosen Scheme for your programming language, or for a particular project, and you have experience and information to back that up, then I'm sure the choice is the correct one, especially for you. And not everyone does, or can, tackle every kind of problem, either. Again, thats most likely part of our own styles of thinking (that we're mostly born with, or acquire in the early phases of life).
What language was Scheme implemented in? I promise not to use that against Scheme. BTW, I'm not against most languages (exceptions include Algol, COBOL, Pascal), but I do think people need to make choices with good, and unbiased, information.
Re:What about Redmond? (Score:2)
Oh really? You say "peddles" so I assume it's not for free. So how much would it cost me to buy the BSD/IRIX/Linux/Solaris versions?
Re:Code-in-HTML and HTML-in-code are both dead! (Score:2)
vanza [mailto] wrote:
Great. Now how do I plug modules of other languages in there? Or more to the point, why was this designed to be specific to just one language? My prior post [slashdot.org] did say "and total pluggability".
Re:I don't hire "Java Programmers", even for... (Score:2)
I've found that C programmers who come from a heavy assembler background tend to know how to handle pointers a lot better than those for whom C was their first language. So I certainly agree with you about the "first programming language" syndrome. There being no one language that uses all technologies (intentionally), a programmer who knows only one is essentially inexperienced in computers, no matter how many years they've been doing it (for the most part ... surely there are a few exceptions, though most would have picked up another language within a few years).
CGI is not a scripting language (Score:2)
CGI is not a scripting language. It is an environmental programming interface which many languages can use. If you want to make comparisons validly, you would compare languages to languages (e.g. ASP vs PHP vs others) and environments to environments (mod_whatever vs CGI in Apache, or Apache vs Roxen vs iPlanet vs IIS).
Re:PHP rocks... (Score:2)
Did I say it had anything to do with Java?
Re:PHP rocks... (Score:2)
I guess we're reading this from different contexts. I wish I had the time to go through the whole thing with a point by point explanation. But I don't. Maybe another day.
Re:PHP rocks... (Score:2)
I'll let Woofcat go into the speed differences more, since he said it first. But I do find PHP to run faster than Perl, and from what I read, it therefore must be faster than Java.
If you're doing DB backed stuff, then Java is probably not going to be your bottleneck unless you improperly misbalance the machines. I do agree with you that speed of development is secondary (although try convincing most project managers or CTOs/CEOs). And yes, separating logic/process/application from presentation/content is the way to go for anything short of little one day PHP knockoffs like I did with http://linuxhomepage.com/ [linuxhomepage.com]. I'm currently building up my own toolkit to do that in the language I now do my web stuff in (which is faster than PHP).
Re:Sorry, one more thing . . . (Score:2)
No. I'm opposed to a failed attempt to create such a language but making it have a screwy data model (typing is too strong). If your assumption were true, then I'd be opposed to C, C++, Java, and many others (even though some have goto, they provide enough to avoid using it).
COBOL has stayed around because so much legacy stuff is built in and around it, and there's still a sufficient supply of programmers to continue working it, that managers in the companies that use it aren't going to jump ship just yet to change things until they have to.
I'll make no one specific recommendation for a "replacement" since that would be inappropriate. Language choice depends on a lot of issues, and there are several strong choices today as compared to when COBOL was created for the lack of any others, and the lack of knowledge about computers in general. It was the right choice then, although not today. Remember Grace Hopper [wic.org]?
As for the legal issue, I've never heard of such a thing. In fact I know of financial stuff done in many other languages, so I think that's phoney, anyway.
Re:ASP?? (Score:2)
Because someday I might need to run my code on a non-Microsot platform. ASP is a dead end.
Re: One has little to do with the other (Score:2)
SERIOUS web businesses run Java.
Re:Python/Webware (Score:2)
PHP & Servlets is like apples and oranges (Score:2)
<%
String title = "My First Script";
String greeting = "Welcome to my first script.";
%>
<html>
<head>
<title><%= title %></title>
</head>
<body>
<h1><%= title %></h1>
<p><%= greeting %></p>
</body>
</html>
Re:Of course no ASP (Score:2)
Re:CDO My arse (Score:2)
The ampersands are just the tip of the iceberg. VB sucks ass as a language. It's obvious you have never done string manipulation with perl or php. Once you learn that then you'll see what I mean.
Re:No hashes in Java? WRONG! (Score:2)
Re:Of course no ASP (Score:2)
You can call activeX objects from PHP or perl too and you can use perl in ASP.
In the context of this article I'd say ASP has no place. It's not a language, it's not platfrom independent, and it's on it's way out. ASP will be replaced by
Re:CDO My arse (Score:2)
Here is the best reason NOT to use ASP.
SQL = "Select " & fieldlist & " from " & tablename & " where " & fieldname & " = " & fieldvalue & " ORDER by " & sortfield & ";"
in PHP
$sql= "select $fieldlist
from $tablename
where $fieldname = $fieldvalue
order by $sortfield"
Which would you rather maintain?
After the 10 thousandth ampersand I want to just smash my monitor to pieces. In my job I have switch from php or perl to VB very frequently and I just want to stick needles in my eye whenever I am forced to use VB. Yes I am forced to use VB in my asp pages because
1) MS says it's prefered and the management believes them.
2) The idiots that manage the web site don't know anything else.
I could give you a hundred other examples but really that one reason is enough.
Re:Reboot? (e:ASP is doubleplus ungood?) (Score:2)
You can pick up PHP in a couple of days. Using ASP + MTS + COM+ requires a developer with at least two years under his belt.
You can not compare the two technologies. You should compare MTS to J2EE that would be a closer technology.
Re:ASP?? (Score:2)
Re:What about CF? (Score:2)
Re:JavaServlets (Score:2)
In that case you haven't any experience worth talking about. If you run PERL scripts as CGIs without mod_perl, then you have the full overhead of starting up the PERL interpreter for each service. This is much the same as writing CGI in Java and starting up a new JVM for each service - yes, you can do it on a very lightly loaded site, but it isn't good engineering.
No CGI scripts - no matter what language they're written in - can compete with in-process technologies, whether it be Servlets (my personal choice), PHP, or mod_perl. CGI is just inherently inefficient, and the larger the binary you have to start each time, the more inefficient it is. PERL is a pretty big binary.
Speaking of object database... (Score:2)
Re:PHP vs Perl vs JSP (Score:2)
Nope, just the main file. Here's what I use. It might be different from you.
#!/usr/local/bin/perl -w
use CGI;
use DBI;
use CGI::Carp qw{fatalsToBrowser};
do "SubsCommon1.pl"; #has some subs
do "CGIStuff.pl"; #and mo' subs
I don't get Server Error messages that often at all.
Re:Crappy article (Score:2)
All this article did was cloud the decision making process for neophites even more.
Where the article should (or could) have gone is into detail on when to choose the various technologies. Why and when would I choose PHP over PERL over JAVA? What are the performance trade offs for using each? What language features does is support?
Paying a little more attention to meat rather than trying to get something published would have benefited us all a lot more.
RD
Re:Code-in-HTML and HTML-in-code are both dead! (Score:2)
Since Perl was a local favorite, we did something that I assume is similar to "Velocity" referenced elsewhere. Basically separate engines produce HTML (either through flat pages, or through cached perl-scripts (similar to FastCGI or Apache::Registry)), and then a template merger will take important parts of the various pages and produce the final HTML. The approach is generic enough to allow side-content to be applied (kind of like a static layered HTML).
In this, a template is specified for a directory (via putting a file and possibly munging a config), then throwing cgi's or htm's all over the place.. Exec's can use Front Page, or artists can use Photoshop, and us guru's blow in complex perl code. The best part is that it's transparent... Nobody need learn anything new.
Well, unfortunately that only seems to work efficiently with perl.. So basically you'd have to reinvent the wheel for each language, since there would be a different problem set.. Java wouldn't be too bad (a la Velocity, I'm sure), PHP would probably be a b*tch, and so on.
One slight addition was going to be the general piping of HTML to the merging engine. Thus non-Perl CGI's could just be exec'd and passed through. I'm sure through post-filtering in Apache you could accomplish this just fine with any other language.
The problem mostly arises in how you generate the HTML around the actual data you're trying to display (i.e. the table or pretty printed dynamic forms). Creative uses of templates could work. But mostly we resort to language and package specific methods: CGI.pm, embperl macro's, PHP thingies, etc. Don't really have an answer for that..
Another idea could be the micro-translation of data-types into HTML widgets... The recreation of the document (a la XML descriptions) with an associated style sheet could be ideal. Especially if this is all passed to the browser for final construction.
Other issues come from sidebars and dynamic menus.. The graphics designer will make all the reall cool button graphics, but how do they implement the switching logic without doing any code. I'm a big fan of static (non context sensative) menus, but on bigger sites that's just not practical. The only solutions I've come across require definate communication between developer and artist.
I'd be more than happy to learn what other's have found.
-Michael
Re:JavaServlets (Score:2)
Re:JavaServlets (Score:2)
My point is that regular expressions are very natural and easy in Perl (assuming you understand regular expressions conceptually, and find them easy on that level). In Java, to my knowledge, they aren't. According to some other peoples' posts, there are some Java libs for REs, but they're written in Java, so aren't as fast as the Perl and PHP RE functions that are written in C and compiled to machine-specific code.
You don't truly NEED regular expressions in a language, because you can parse them yourself using your own stack. In this way, you could do regular expressions in Fortran (and hell, they'd be damn fast if you coded them well). At issue is convenience features in a given language, and how well documented they are, and how streamlined their use is. REs in Perl work great. I can't speak for PHP, because I don't know the language. Heck, as much as I despise the syntax of ASP (BASIC), I'd be surprised if you can't do REs fairly easily in that Microsoftish language (please, someone - surprise me!!!)
Re:Disappointed... (Score:2)
Re:PHP rocks... (Score:2)
Do you have any intention of substantiating this claim? Okay, I know you're just responding to someone who was attempting to create facts using anecdotal evidence, but you're adding credence to his claim here.
If you want to make a statement which is definitely not obvious (Personally it goes against my intuition, I would think Java is the fastest, but who cares what I think), then please make some justification.
All three are subjugate to.... (Score:2)
And who says you can't teach old dogs (or mainframe jockeys) new tricks?
Re:Use what you know (Score:2)
Come on folks, you can pick up PHP in a day. You can read the entire online documentation guide in four hours.
If you're going to hold this party line of avoiding new tools, just keep it in mind next time you crack on a forty-something who insists on doing the job in COBOL.
Computer scientists like Java??? (Score:2)
Code-in-html vs. html-in-code debate is over (Score:2)
Re:Crappy article (Score:2)
I agree completely. The article does not explain the basic difference between these three approaches, it gives no guidelines when to use them. Just publishing examples is simply not enough.
And the problem is not only the Java examples. Just like the missing JSP pointer, I would have expected pointers to embedded Perl scripting, too. And to template-based systems, for those who want to do real work.
Re:developerWorks focuses on Open Source tech (Score:2)
This is the most elegant explanation of ASP that I have ever seen. Thank you!
Re:ColdFusion and thinking far inside the box (Score:2)
And what is this "Windows world" you speak of? CF runs on Linux, HPUX, Solaris, and Windows officially. FreeBSD and others unofficially.
CF is by no means the best for all jobs (what is?), but I think people on Slashdot focus too much on it's simplicity and it's early version performance issues and don't give it the credit that it deserves.
Re:JavaServlets (Score:2)
Re:Perl vs PHP - the answer is easy for me (Score:2)
If you're bouncing from system to system, yeah, Perl will probably be more of a constant right now. But my guess is that many admins that have PHP on their box would either have it as a CGI, or give you access to it anyway - it's actually easier to make PHP safe in a multiuser environment that way than mod_php, imo.
Actually, it's not terribly new, afaik. I was using it a couple years ago at least, so I know it's not 'new'. I'm not sure if it was available like that in PHP2, but from mid versions of 3 on I can attest that it's been like that.
R
Re:ASP?? (Score:2)
If your example is the VBScript code, two strikes against it. One, it's not terribly standard. I worked at a web integrator that was 95% MS and only two people there even KNEW about the VBScript method, and both wouldn't use it, not let us use it, because of stability and security questions (didn't have time to test and audit it, and if a component broke from someone else we could at least call them up and bitch about it). The second strike is just that it leaves MS shops without 'support' (see above). I realize not all shops were/are like where I was, but the attitude seems prevalent enough from other MS people I've talked to ("come on, it's just a few bucks", etc.)
Re:Perl vs PHP - the answer is easy for me (Score:2)
What the hell is wrong with the PHP interpreter?
#!/usr/bin/perl is OK but
#!/usr/bin/php is 'hokey' ? I don't have to redo my PHP modules in Perl to use them 'outside of the web' as you say. I simply include() them and use them. Doesn't seem a whole lot different from Perl, from where I'm sitting.
Use whatever you're comfortable with (Score:2)
The way to create the best application possible is to take a langauge you know well, and use it. Period. Suddenly going and studying "Language X" because you think it might be best for a client while doing work for said client likely will create a lot of headaches and long hours for everyone involved. If you find out in the end that it wasn't the langauge you should have used for the project, you're screwed.
Optimize the code you know how to optimize, and use (properly coded) external tools to handle requests you can't handle well on your own. Breaking up large programs into a series of smaller ones is acceptable; look at KDE. One tool that I am surprised does not get more publicity is FastCGI [fastcgi.com]. It is the only langauge and web server independant (more or less) way I have found to speed up CGI scripts. Perl scripts coded for mod_perl more or less port easily to FastCGI, with most of the performance boost. And here's the real kicker; unlike mod_perl or PHP, which take up huge chunks of memory, mod_fastcgi for Apache does not. A small handler simply hands off control to one or more copies of your program running on the side, possibly even on another server!
I've used FastCGI extensively on systems that otherwise could not serve the load they had to handle. While it is not used as much as mod_perl or PHP (it no longer is in the core Apache distribution because it evolved too rapidly), I strongly encourage people to consider it a choice.
Re:PHP rocks... (Score:2)
First, forget all this 'scripting language $x is faster than scripting language $y' bullshit. Speed comparisons are so incredibly task-dependant that there's no hard and fast rule at all. mod_php and mod_perl can basically be assumed to be equal in terms of speed, because the scripting language is extremely unlikely to be the limiting factor.
Where PHP wins out for my is when you're doing a site that's either simple or a complex site that relies heavily on databases. Database interaction is far easier. Where Perl wins is the thousands of modules avaliable; PHP has a hell of a lot built in a quite a few classes avaliable, but it's never likely to match Perl in this respect. IMO you're very unlikely to actually need most of these modules for doing a website, but if you do, then Perl is the way to go.
To be honest, Perl and PHP are so close in terms of speed and feature-set that I'd tend to argue that it's probably just as much a matter of picking what the developer (this means YOU!) is more comfortable with.
--
Nobody uses Java Servlets to create HTML any more! (Score:2)
Sindri Traustason
"It takes two to lie, one to lie and one to listen"
Re:Holy Shit. (Score:2)
They forgot a few things. (Score:2)
Re:CDO My arse (Score:2)
Re:Of course no ASP (Score:2)
Of course no ASP (Score:2)
ASP in 2 years will have no relation to what it is now.
---
close... no cigar (Score:2)
IMHO that article nor can any other give a definitive insight as to what someone should use to manage their site.
Example, I was using PHP before for my site, and chopped up a random image script for chick pictures, and my server load would go sky high, from loading nothing more than pictures... Now php for content was fine but the pics killed me.
Over to embedded perl. Works well I even use it for certain tasks here and there, but nothing major. Python, well its fine but not suitable for me, since my site is small. I wonder why eperl wasn't mentioned, nor was the latest entry Curl [curl.com].
Java is a morbid joke under most *nixes, at least in my experiences. SSI is ok but again for heavy content, sites with massive interaction from the server to client, it can become cumbersome too.
Anyways enough ramblings... I do however think I have thee ultimate old school solutions for fixing my site without using any of the above!@!@... Combos of sed/for [antioffline.com] scripts which till this date have done me more justice maintaining my site
P.S. nice colors going on here maybe that shit looking brown over yellow should be changed to this too
© GBonics 101 [antioffline.com]
Re:Crappy article (Score:2)
While I know the answers to a couple of these questions, I would have liked to see a really thorough side-by-side comparison (at least of performance.) Anyone know of anything like this?
No hashes in Java? WRONG! (Score:2)
import java.util.Hashtable;
Hashtable numbers = new Hashtable();
numbers.put("one", new Integer(1));
numbers.put("two", new Integer(2));
numbers.put("three", new Integer(3));
System.out.println( numbers.get("two") );
The above code will, of course, output "2". The Hashtable supports having ANY object used as a key, not just a String. As well, Java has a Properties class which pretty much has the same functionality, but can be loaded and saved from a file.
Also, those who are interested in developing web applications should have a look at Velocity [apache.org]. It's much cleaner than JSP in that it more closely enforces the separation between code and design. I'm currently using Velocity in a web application project I'm working on and it's working out wonderfully!
Re:No hashes in Java? WRONG! (Score:2)
I have looked at Enhydra. It looks quite good, and I was thinking that we may use it for another part of the application (the 'application' in question is actually 3 web applications linked together with a common interface).
We will likely add Enhydra to our configuration in the coming months. For the present time, however, Velocity offered a good solution for us because it was simple to install, performed surprisingly well and we were able to make templates straight out of HTML editors. I generally code HTML by hand, but my time is better spent doing the back-end code, so often I have someone else do the design work.
I also liked the way that Velocity 'merges' data (in a Context object, which is basically a hash) with the template. Because of the way it loads templates, I found it to be a piece of cake to be able to load different templates by language (we support French), and by customer (some of our customers want customized looks and/or functionality).
We've had some bad experiences in the past with ASP. The bad part was that while things worked reasonably well, the developers were too often tempted to put code directly into the ASP page instead of the COM objects which were called. The production server, only shut down very infrequently, was not making it easy to update COM objects (bloody things got stuck in memory often and we couldn't reload them without rebooting the server sometimes). Hence, the developers became accustomed to putting code in the ASP part of the app, since it could be updated on the fly. After a while, we end up with hundreds of ASP pages with all sorts of code in there, and you can't easily read them to modify the presentation if you have to.
Enter JSP. While I like the technology and its abilities, I don't appreciate that it's just as easy to make the same mistakes. JSP allows you to embed Java code directly in them, which normally shouldn't be a problem, but maintaining an application over some years, you're bound to find situations where somebody is going to stick code in there and lots of it. Pretty soon, your JSP page is not as simple as it was when you started. What we needed was a way to enforce the separation of code and presentation, and an easy way to customize the look for our customers and to be able to handle multiple languages.
I found Velocity fit these needs well. I was able to write a small, customized template loader which searched for templates appropriate to the customer and language (if it can't find it, it loads the generic English one). Velocity does not allow you to embed Java code in the template. There are a few basic ifs and loops available, but generally you're forced to keep the code in the classes, and just send the template the resulting data to display.
For the data/functionality part, I've also implemented similar ideas for the classes. At runtime I load classes specific to the logged-on customer and try to run those to process forms (they just extend the generic form handler for that function and override a method or two). If they don't exist, then naturally the generic handler class processes the next action.
The main requirement for me was maximum flexibility with minimal effort. Velocity fit these needs well. I'm sure that Enhydra will fit our future needs too, so no, I am not rejecting it as a viable platform.
webobjects (Score:2)
Code-in-HTML and HTML-in-code are both dead! (Score:3)
Actually, BOTH HTML-in-code and code-in-HTML are dead. The one and true answer is separation of content vs. application, and total pluggability between the two. The ultimate solution will work with any content/information form (HTML, XML, etc) and application form (C, C++, Perl, Java, Scheme, etc). This is organization and the web still majorly lacks it.
Don't get me wrong here. I love PHP. I did LinuxHomePage.Com [linuxhomepage.com] in PHP in one day as my very first PHP project. It was great and PHP was very easy to work with.
In the long run, mixing content and application is bad as systems get far more complex. One critical need will be the ability to change one or the other. By having them be fused together, it becomes more cumbersome to make those changes.Some people are inherintly more program/application development oriented. Other people are more information/content development oriented. And still others are graphical/artistic oriented. Few people have the capability to be all that and good at all of it at the same time. So it will be necessary to divide the development (and change) functions and thus also necessary to divide up the entities these different people work with to implement and deploy the components they do.
An author of an article can't write the page layout, but she does need to write the article. She can't concern herself with what tag needs to be inerted at the top to get the properly rotated ad banner inserted. She can't concern herself with how to lay out the menus on the left side or the right side.
The very model of dividing things up at the page boundary is what is wrong. We got fooled into thinking of that with HTML itself because the tags were (at least early on) easy enough for even a non-techie document writer to work with. But today's web applications bear little resemblence to a hierarchy of documents for which HTML was designed. Our thinking needs to be along the lines of keeping separate, and dynamically merging in the appropriate way, the various components that make up what it is we are accessing. That is where we are headed and we best be prepared to deal with it, regardless of what our preferences are for things like content language or programming language.
Re:PHP rocks... (Score:3)
PHP is faster than Perl or Java, but there are other choices out there which are even faster than PHP. I'd bet that speed is not your only reason for choosing a language to develop web applications in, but rather, you're just pointing out this reason because it is aligned with what your choice is. In reality, emotion often plays a big part in the choices we make, and we feel better when we see some non-emotional justification for our choices.
Cocoon (Score:3)
Apache's cocoon [apache.org] is a basically jsp done right using XML/XSLT.
Re:PHP rocks... (Score:3)
I'll use Perl here, as it is my personal preference for language of choice. I'm using Perl in only the web context here, as that is the scope of the discussion.
As a language itself, Perl is just as fast as PHP, if not faster. As far as the process goes, yes CGI has a larger overhead and slighty longer time to initiate, but the once the processes are going the actual script execution time is no longer for a Perl script.
Plus, if someone is actually a programmer, as opposed to a kiddie that's been programming for 2 weeks and thinks they know Perl (or whatever language for that matter), they can actually program properly and create programs that execute fast enough, and effieciently enough, that the slight ding caused by the CGI overhead is negligable.
And don't forget to compare apples to apples. PHP against mod_perl is the proper comparison, not PHP vs Perl via CGI. People forget [or don't know...] that PHP is mod_php and compiled into the server (usually). PHP can be run as a CGI process, but doesn't (well, on NT it may). With mod_perl running and maintaining persistant database connections, PHP is not faster. And compare a well programmed mod_perl script to a poorly written PHP scripts and, well... you get my point.
PHP may be "easier to learn" but that's because it's Perl with training wheels. People that aren't adept enough to properly comprehend Perl, LOVE that they can go to PHP instead. But PHP is quite like Perl, but a subset of it. So claiming it's harder then PHP seems silly to me, as they are both fairly similar in terms of the language.
Bottom line, PHP is a good web language. Perl is a more robust general language. Scripts done properly will run fast and effiecent. Blanket calls of "PHP is better/faster" are unwarrented. It all depends on what is needed for the job, and using the proper tool.
Hell, perl.com uses PHP for some areas of the site. It's all about what is right for a situation.
Access to databases? (Score:3)
No one uses scripting languages to display static text. The comparisons were meaningless.
A really good article comparing any server- side technology would compare:
Re:What about Redmond? (Score:3)
Re:I don't hire "Java Programmers", even for... (Score:4)
I've found that java developers who come from a heavy c/c++/unix background tend to know what's going on underneath the language -fairly- well, and understand how to do things like work in a debugger, work with a profiller (and interpret the results from said profiler!) - as well as handle a lot of things outside of direct development, i.e. system maintenance, development environment tuning, etc... etc... etc...
I find that developers for whom java is their first programming language, tend to be very weak all the way around. (Then again, i've found that to be true for most developers who are on their 'first programming language').
(I do want to get back into doing regular C++ programming, it's been about 2 years for me, hrm, perhaps its time to re-install that BeOS cd...)
Re:ASP? (Score:4)
You've got to consider the source. IBM simply has no vested interest in ASP. I'm sure you can even find a lot of ASP in use within IBM. But as long as Microsoft plays corporate bully (not that IBM doesn't) and doesn't want to let someone else share in the benefits of ASP, then you can't expect someone else to sing the praises of ASP. For them to do that, they have to have some interest in it. Individuals can when their benefit is a job and income, and they know and like ASP, or any other language.
Probably the biggest reason for ASP not being there is the fact that it isn't (as) portable. IBM has vested interests in non-Microsoft operating systems for which these languages are more readily available and marketed.
Also, Java is currently heavily pushed in academia (which also tends to care less about issues important to business).
Why don't I see C, or C++, or Pike, or Scheme, or any of a number of other languages in here? There's a combination of reasons, varying from ignorance to disinterest. But probably the biggest one is because the authors do have a vested interest in showing off a subset (for which they have an interest) against a subset (for which they have no interest and see as a threat to their interests). The languages I just mentioned have little threat to their interest because few people use them (reasons vary, and not always technical). But if they did, I'd bet you would see them mentioned.
Crappy article (Score:4)
Also, that business about having to be careful not to confuse the class names is hogwash: that's what packages are for.
Use what you know (Score:4)
I've done sites with perl, JSP and servlets. Experience has taught me that you're usually better served using what you're most comfortable with -- it's easier to learn new tricks with an old language. Admittedly, it is less fun, but when the boss is yellin', you need to get it out fast.
The difference, I think, is mostly that these options are reflections of certain approaches to programming. Whichever approach you feel most comfortable in, that winds up being what you use the most. Hardcore *nix will like Perl because it reminds them of long summer nights with sh and awk. Computer scientists will like Java since it's "clean" and "pretty" and "portable" <snicker>.
Use what's best for the job and leave the flamewars for Happy Hour.
Disappointed... (Score:5)
I love it, it means our java developers can concentrate on logic, and our HTML designers only need to learn a small handful of JSP tags, but can concentrate on their display.