PDA

View Full Version : newbie question about internet programming


DSPguru
2nd June 2002, 06:39
can anyone supply a good comparison between : asp,php,jsp,cgi-bin,activex,aspx ?


10x!

Milkman Dan
2nd June 2002, 08:10
Some friends of mine made a messageboard/website using PHP with a dash of Javascript. You can check it out here (http://www.mywang.org) if you want. They picked it up very quickly, and it's Open Source

avih
2nd June 2002, 10:09
don't know much about activex and aspx, but:

all of these are server scripting languages.


cgi-bin:
"Common Gateway Interface - binary". this is a VERY general method and it's the oldest. in cgi, the page is sent to a stand alone application as it's input. the app does whatever it likes, and outputs an html page in return. capabilities depend on the actual language the app is written. but you can use any language u like. the disadvantage is that the http server has to execute the app for every request, and that damages the performance. (the other methods can keep the interpreter loaded in memory all the time. php CAN be used in cgi mode as well). multi platform if the source is portable.

jsp:
"Java Server Pages". never used it. should be quite strong, uses java (or javascript?) as syntax and capabilities. afaik, not the best support in the world. multiplatform.

php:
"PHP: Hypertext Processor". my preffered. EXTREMELY powerful and easy to learn language, syntax similar to c/c++/java/etc with some elements of perl (powerfull variables and loose types, strong regular expressions). has oop, but you don't have to use it. out of the box connectivity to odbc, mysql and more. also file access is VERY easy. all data sources and targets (ftp/http/file/socket/pipe/stdin/stdout/etc) have single file interface with fopen/fseek/fread/etc... supports xml. all in all, VERY powerful, extremely rich set of features, completely free and very easy to learn. multi platform (except if you use odbc or one of the other few os specific features).

asp:
"Active Server Pages". based on m$ architecture. all connectivity, functionality and syntax mostly derived from vbscript/c# (but you can use activex objects of course from the script). windows only with m$ server and tools.


cheers
avi.

Koepi
2nd June 2002, 10:47
Hm, I use php now as well (but I didn't write a single line of php code yet).

I've to say that your critic against perl/cgi-bin (what I usually use) isn't justified. You can build apache and mod_perl that way that mod_perl is in memory so the cgi scripts are executed very fast - at least i never suffered bad performance even back when our router was a k6-233 with 128mb of ram - could serve a few hundred hits/s without problems (yes, and it had to connect to a mysql backend).

So for me it's still easiest to code a small perl-script and put it into my /cgi-bin.

Regards,
Koepi

nikthebak
2nd June 2002, 13:38
Through personal programming experience I would rate PHP and Java Servlets as the most powerful web programming methods. Avih's commens about PHP are true, it is a very easy and powerful web scripting language.

JSP or Java Server Pages are standard Java code embedded in HTML pages. Servlets on the other hand are full blown server-side Java applications. JSPs are actually transformed into Servlets upon the time of execution.

Since Java is already rather mature and powerful programming language (forgive me C++ preachers, I'm already beyond salvation :P), you can accomplish much more with Servlets than with a script language like PHP. I understand I'm already a bit biased towards Java since I have studied it (and web programming languages btw) for several years at my university and I am currently working as software engineer mainly using Java :D.

However features of a full programming language are very seldomly required in web development. And not to mention, Apache Tomcat (required by JSPs and Servlets) is a real pain in the ass to configure. And especially Servlets take huge amounts of processing time and memory.

avih
2nd June 2002, 15:24
@koepi:
you're right, of course ;). mod_perl is loaded into memory by apache. and also, php can be used in cgi mode. i was too lazy to learn perl, but php was a real breeze :) at least for me, so i never used perl..

bottom line, it comes down to a personal taste, and specific needs.

if it works for you, it's good enough ;)

avi

Koepi
2nd June 2002, 15:45
Agreed, it's a matter of personal taste.

Additionally, it has to be said that every language/system has it's advantages/disadvantages when it comes down to what you want to do with it.

PHP should be more suitable for creating complex designs (though you can do that with perl as well). PHP should be easier to learn for people who already are familiar with OO.

Perl is good when you just need to create dynamic pages with a little database backends. The code to achieve that is very fast written and small.

And with java servlets, they are really powerful to create anything you can do with "usual software IDEs", but as already written above it's very CPU and memory intensive - thus only suitable if you have to do very complex things server-side (like banking transactions) with a load-balanced server-farm behind it. I've not yet seen any high-performance java based system. Vodafone etc use them, and they are slow as hell.

my suggestion would be:

small-mid size projects, fast to implement: apache + mod_perl + mysql
small-high complex projects, coding time is not important: apache+ mysql + php

(Just my oppinion, I really didn't write anything in PHP yet to really verify that it takes longer to code it).

ASP and JAVA are slow and propietary (sorry, I don#t really like java ;) ). But you might Give apache + mysql + mod_asp a try as well - should be the easiest way to code pages, but I don't know of the performance.

Hell, and I thought we were mainly quality video addicts here - nice to see that we have some real pro's here as well :)

Best regards,
Koepi

avih
2nd June 2002, 18:34
examples of php's simplicity.
i've implemented:

1. http proxy (with input tests and additional 'banner' for the page). about 1/2 page of php code.

2. web counter, with extensive statistics, browsers, times of day, etc etc etc... with mysql backend. about 1 page of php code. the display php page (view the statistics in various categories etc), including page formatting, tables, etc, about 1/2 page php code.

on top of that, (i didn't try perl so i can't comment about it) the concept of embedded code (html page with php/asp/jsp 'snippests') is very easy to understand and implement, imho, unlike 'external' application. also, php gives direct access to all user variables (forms, cookies, etc), and enforces correct programming paradigm (especially with the latest versions), yet it's VERY forgiving to syntax (parenthases, variables types, undeclared variables, casting (implicit casting works great), etc ). it also has built-in session support, which makes it very easy to programm 'continueos' user experience.

it's arrays are dynamic/associative, with garbage collection. and it can deal with arrays and parse strings very effectively (i think perl is the same here). everything is automatic (if u don't specify otherwise), and all the automatic 'decisions' just hit the spot (initializations of strings to "", numbers to 0, etc)... so it's very easy for newbies to use, yet allows complex programming and features for the advanced.

imo, it's suitible for wide range of complexities, starting from very simple one or 2 lines of 'active' html code, up to quite complex sites, such as this forum..

hehe :)
php is just an amazing language imo... i fell in love with it few hours after i first started to use it ;) i know no ther language that's as elegant and powerfull as php.

avi

nikthebak
2nd June 2002, 22:37
I actually thought about this issue briefly. I came to conclusion that if I would have to build up a web page from scratch, I would probably use Apache + PHP + MySQL unless obligated to choose otherwise. That's what my own little http server uses anyway :D. PHP IMO represents one of the finer programming languages in the business.

When considering that combination it's really heartwarming to see that free, open source solutions like Apache, PHP and MySQL dominate internet programming (Apache is nowadays used in more than 60% of web servers). I guess M$ just can't buy everything.

I love Java as a programming language but I hate it's current implementation. Give me an official, supported and effective Java-to-native-code compiler and I'm in heaven :P.

A little word of warning about PHP however. Direct access of global variables is dangerous. You see, by default a user can directly set or alter values of any global variables. For example, if your password protected page would rely solely on one global "IsAuthorized=1" (yeah right, like anyone would do this, but anyway) variable, a malicious user could override it by typing the URL as ".../mypage.php?IsAuthorized=1", not to mention more sophisticated nuking methods. Filenames as global variables could lead to disasters. Best way to counteract this possible security flaw would be to switch off user-controlled global variables (can be done at the config files) and get form data and such from HTTP header fields. Luckily, this phenomenon is well-documented at the PHP home page.

http://www.php.net/manual/en/security.php.
And especially
http://www.php.net/manual/en/security.variables.php

Sorry if I'm repeating what everyone knows already, but if I can stop one PHP newcomer from making a fatal mistake, it's worth it :D.

avih
2nd June 2002, 23:11
as i mentioned in one of my previous posts, that issue has been handled in the latest versions (4.10 onwards).

from http://www.php.net/release_4_2_1.php
We would also like to attend you on a big change in PHP 4.2.0 concerning variable handling. External variables (from the environment, the HTTP request, cookies or the web server) are no longer registered in the global scope by default. The preferred method of accessing these external variables is by using the new Superglobal arrays, introduced in PHP 4.1.0.

so by default (but can be overriden) these vars are NOT global anymore. so http vars as in your example, won't 'polute' the global scope, or override script variables.

cheers
avi

TheWEF
3rd June 2002, 02:12
just want to mention that with delphi (6 enterprise ed.) you can do A LOT! websnap, bizsnap, datasnap, soap,... many very useful components, now even (some) multi-platform stuff with kylix 2.
you get many advantages like fast compiling, easy debugging, everything is visual and for many things you don't have to write a single line of code.
you can create cgi executeables, isapi dlls or apache shared modules from the same code. and you can connect to any database you like.

i'm not experienced in web development, but if you start something from scratch delphi enterprise is definitely worth a look...

wef.

DSPguru
3rd June 2002, 18:15
i haven't checked delphi 6 yet (don't have it.. :()
so let's assume i go for :
apache+php+mysql

what about developing platforms ?
how do i develop the php code ? how do i debug it :confused:

Koepi
3rd June 2002, 18:28
Setup a linux on a local box.

Write the code, test it with a local apache+mysql+php and a browser using http://localhost/mypage.php.

If it works satisfactury for you, you can upload the stuff to the final location that supports this scripting system.

Regards,
Koepi

avih
3rd June 2002, 18:55
development on windows is ok as well.

i recommend phped ( http://soysal.free.fr/PHPEd/ ) it's free (the newer versions are commercial). you can use a php debugger with it (although i didn't use the debugger myself), and direct help for php commands (after you download the html manual). it has project, syntax highlighting and it's nice to work with. php edit ( http://www.phpedit.com/ ) seems nice as well. there are many more php editors and IDEs, just search the web, and find one that u like.

testing locally, and then uploading is indeed the best method.

also, you don't HAVE to use apache, it's working very well with almost any web server that supports cgi-bin, it might just be a bit slower (but totally unnoticable for up to few 10s hits/sec). installing mysql is recommended if you need a db, or you can just use odbc, to get the feel of db usage.

keep in mind though, when using the web server variables, as some of them are apache specific.

here's your 1st php page, to get information about your environment:
--------------------

<html>
<h3>Before execution of PHP code</h3>

<?php
// prints extensive formatted information about the PHP environment.
phpinfo();
?>

<h3>After execution of PHP code</h3>
</html>

---------------------

save this file as myfile.php into your web server directory, and use your browser to load it using koepi's method (http://localhost/...)