[PHP] Modularity--Optimizing Includes and Libs

2001-09-19 Thread Bora Paksoy

Hi;

I have a question regarding includes and writing
library modules in PHP. 

In one of the replies to my previous e-mail,I was told
that PHP parses/compiles pages everytime a new request
comes in. So, does this mean we have to minimize the
amount of code per page (which also means to minimize
number of includes) to improve response time? I mean,
usually in many programming languages, it is a common
practice to gather shared functions in a library and
include/import them from individual scripts. But, in
case of PHP, given that this library will also be
parsed/compiled per every request, is this a bad
practice? What is the alternative to this? Replicate
functions that are used in scripts in every page?

Thanks,
Baho

__
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] PHP vs. PERL (Functional Comparison)??

2001-09-16 Thread Bora Paksoy

Hi;

I am planning to implement a new site which will be
using mysql db heavily, and I am in the middle of (and
stuck:) deciding what I should use for implementation.
I would definitely prefer Java Servlets, but it is
very expensive to host servlets, so I am only
comparing PHP vs. Perl. 

I have been hearing very good things about PHP for a
long time, and I started reading the manual/tutorial
posted on php.net. To be honest, I didn't see much
difference from perl. It is almost identical (I have
to admit, there are some practical advantages, but not
a huge difference), even the syntax is almost same to
perl.

Comparing basic functional stuff:

1.Speed: If you use mod_perl or fastcgi kind of deals
(which are based on threadding instead of forking), I
don't think PHP is considerably faster than perl? Is
that the case?

2.Database Connection: What is the BIG advantage of
PHP here? Using DBI packages for perl, and fastcgi for
db connection pooling, you can achieve the same thing,
I guess. It just looks like PHP has some of these
libraries embedded in the core language, but the idea
is same--implementing the native db protocol over
sockets?

3.Shared Memory, global variables, etc: I was
expecting a better interface for this in PHP, and I
was really disappointed to see that developers have to
use O/S level shared memory. First of all, this is not
available on Windows And, it is kind of messy and
hard to use, especially when you compare this to
Java's static variables.

4.Session Management: If you use files to manage
sessions, same thing can be achieved in perl.
Regarding in memory session management, as far as I
know, FastCGI can share variables among sessions, so
it shouldn't be hard to write a session manager in
perl as well.

5.Architecture: I couldn't find any doc about how PHP
works. And any answer to important questions, like 
-How does compilation process work? Does the PHP
engine compile htmls first time a request is made to
that html and use that compiled code later on(just
like JSPs), or does it compile everytime? Is PHP
engine an interpreter, jvm-like byte-code
generator/executer or a compiler? 
-How does threadding work? How can you cache stuff,
etc.?
-What is the generic lifecycle of a request/response?

6. Embedding scripts in HTML: Well, I mean, this is
similar to JSP, but what the hell, you can use AA
. AA; syntax and embed any string you want at any
point by mixing and matching HTML and perl code. I
mean, yeah PHP is easier, but it is not considerably
easier, I believe.


I have been searching the internet to find some
serious comparisons, but all I found was a stupid page
which compares the syntax rather than functionality. 

As I said, I really need to start developing soon, and
I would appreciate comments regarding this issue.

Thanks in advance,
Baho.


__
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP vs. PERL (Functional Comparison)??

2001-09-16 Thread Bora Paksoy

 Why on earth would you prefer java servlets?

Hmm... Let's see;Java is a full-fledge, totally OOP
and awesome programming language but not a scripting
language. Speed (will be mentioning this later),
having total control over whatever you want (exception
handling, db pooling, caching, syncrhonization,
threadding, etc. etc.), ease of use, etc. etc. I mean,
come on;)

 veins as well), therefore its imho much easier
 to do web programming with php.

That is what I saw, but as I said, I didn't see a lot
of difference between perl and php, I mean, C++ and
perl are very different, likewise java and perl or
other languages, but PHP has a very similar syntax.

 FYI, JSP is the slowest to my knowledge.

The first request is slow since JSPs are compiled into
servlets (java classes)... But, then it is not bad...
In fact, I saw some comparisons showing that servlets
are kicking ass! But, again, I mean, this all depends
on how you design/configure the system, one simple
example:java used to crap out (before 1.2, don't know
the latest situation, but heard that it is better)
after 40-50 threads per jvm, so if  you have more than
40-50 concurrent requests, starting couple of servlet
engines on different jvms and using apache dispatching
improves the speed a lot! Likewise, tricks like using
caching, staying away from classic traps (i.e. using
StringBuffers instead of Strings when needed),
minimizing garbage collection, etc. etc. Also, with
the introduction of JIT and hotspot capable JREs, java
is doing pretty well these days...You can check
comparisons at rasin servlet engine page.

 No, its not available on Windows, but then
 again, why on earth would you want to use Windows?
;) 

Same here;) I am supposed to implement this sytem on
windows 2000...But I totally agree! I would definitely
prefer linux or other unix systems over windows...

If you really need
 shm on windows, submit a patch, hint, its just a
mmap() :)

Well, what I meant was something like ease of sharing
data in java (using static variables) and dealing with
synchronization is extremely easy in java... Also,
FastCGI is not that hard as far as I could see, but I
am not an expert in that area;)

 You can use Files or SHM management, or write
 your own custom session backend using for example
MySQL.

Using a database in the backhand is what huge sites
are doing, but they have huge boxes to run these
databases and very fast network infrastructure. Do you
think overhead of serializing/de-serializing session
for every request via the database is a lot? Files
again is??? I don't know... As you specified SHM is
not very nice either (dealing with synchronization
might be messy).

 No.  Its compile and execute everytime

??? Don't you think using perl and printing out html
from the code is faster than this? I mean, parsing the
whole html doesn't seem very good???Actually, this is
what I was scared of. I mean, for example say you have
an html that consists of blocks... Making every block
an include is clean, but this time, php engine has to
read all of these includes, and parse the html+php and
compile/run php everytime a request is made??? I am
not sure about this?

 Yes, but do you want your web designer going
 through your perl code

Hmmm, good point, hehehehe...



Thanks a lot for your time and I appreciate your
comments.

Baho...

__
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP vs. PERL (Functional Comparison)??

2001-09-16 Thread Bora Paksoy

 Threading instead of forking?  None of these do
 either.  Apache is a
 pre-forking multi-process server and both PHP and
 mod_perl are part of
 these pre-forked processes.  Neither mod_perl nor
 PHP do any threading nor forking. 

??? I didn't get this? Aren't these pre-forked
processes handle requests using threads internally?
Say you configure apache to pre-fork 5 server
processes, what you are saying implies that you can
only handle 5 concurrent requests?? can you please
explain this more?

 Again, the architectural difference makes this a lot
 easier to do in a
 single-process JVM scenario.  Note that such a
 single-process JVM
 architecture which maintains static objects is very
 hard to scale cleanly.

Actually, as far as I know, you can configure tomcat
or other servlet engines to start multiple servlet
engines (JVMs) and the dispatcher code makes sure that
every user goes to the same JVM for subsequent
requests. So, you can scale with this architecture...

 The lifecycle of a request/response matches the
 lifecycle of an HTTP request/response.

Actually, I was asking the low-level information, I
mean something like web server receives the request,
hands this over to mod_php, that requests a thread
from the worker threads, so on so forth...

Anyways, once again, thanks for your time...
Baho.

__
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]