Forum Moderators: coopster & phranque

Message Too Old, No Replies

do perl scripts stay in memory?

         

ocelot

3:11 am on Dec 7, 2004 (gmt 0)

10+ Year Member



I'm trying to figure out what the differences are between perl and php. I started web scripting years ago on coldfusion and have since moved to php, but a lot of people seem to think perl is nicer.

Something I really don't like about cfm and php is how the scripts don't stay in memory, which sort of forces you to break it up into smaller scripts that can load and execute quickly. I would much rather just have all the code for a particular site in one script that stays in memory, and whenever I want it to do something, I just call it.

coopster

5:21 pm on Dec 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



HTTP is a stateless protocol. The server-side processing doesn't "stay in memory". In a nutshell, the browser requests a page by "connecting" to a server via the request, the server accepts the request, loads the required pieces into memory and processes the request, sends the information back to the browser, freeing the resources from memory and the connection is closed. To maintain state, we see folks employ cookies, sessions, databases, hidden form fields, ... any number of practices for maintaining state.

You can create subroutines or functions which can reside in a single file or files that you simply include or require in your scripts that can be used over and over again. Is that something you have looked into yet?

DrDoc

9:46 pm on Dec 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you're describing can be done, though... but it would bog your server down to the point of not being worth doing. If you really need stuff to live in memory I would recommend looking into compiled languages.

moltar

9:51 pm on Dec 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_perl can keep scripts/modules compiled in the memory.
It can also keep mysql connections open all the time.
It can keep many shared things in the memory. Look at the documentation.

jollymcfats

10:38 pm on Dec 7, 2004 (gmt 0)

10+ Year Member



Ditto what moltar said. Keeping the code in memory is the whole point of mod_perl.

Mod_perl is easy to work with. There is a simple mode where most normal CGI scripts are pulled into memory and "just work". And there are more advanced modes of integration that are less CGI-like and more and more plugging code directly into the web server.

ocelot

1:36 am on Dec 9, 2004 (gmt 0)

10+ Year Member



ok, but then does it "bog down the server"?

compiled languages so sound really nice to me though...I was thinking of picking up JSP

I just find it really annoying to work with most of these web scripting langs. I wish they were more like regular services.

jatar_k

4:33 am on Dec 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try #18

[infoworld.com...]

imstillatwork

4:28 am on Dec 13, 2004 (gmt 0)

10+ Year Member



WHAT? You CAN cache all and any CFML script into servers ram? switch languages just because of that?
CFML Rocks!

imstillatwork

4:30 am on Dec 13, 2004 (gmt 0)

10+ Year Member



and that YEARS AGO version of cfm does not reflect the current versions quality AT ALL.

moltar

6:49 am on Dec 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok, but then does it "bog down the server"?

Perl by itself does not "bog down the server". It's up to programmer to make sure that it does not happen.

Perl has very good garbage collection (GC) system.

compiled languages so sound really nice to me though...I was thinking of picking up JSP

Perl will keep compiled version of the script in memory. So we really are comparing apples to apples.

I just find it really annoying to work with most of these web scripting langs. I wish they were more like regular services.

What you consider "regular services" might not be the same for others. For me Perl is pretty regular, every day life.