Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Javascript Vs Perl RegExp

Reply
Thread Tools

Javascript Vs Perl RegExp

 
 
phal
Guest
Posts: n/a
 
      09-23-2005

Hi all;


I code Perl for CGI, I using regular expression to check the validation

of user input, because the form is small and it run only from my own
computer, anyways if many people using my form, do you think it will be

slow due to Perl is run under server. How about using JavaSCript to
check validation for user input? Do you think it a bit faster?


Thank very much


Phal


Reply

 
Reply With Quote
 
 
 
 
Erwin Moller
Guest
Posts: n/a
 
      09-23-2005
phal wrote:

>
> Hi all;
>
>
> I code Perl for CGI, I using regular expression to check the validation
>
> of user input, because the form is small and it run only from my own
> computer, anyways if many people using my form, do you think it will be
>
> slow due to Perl is run under server. How about using JavaSCript to
> check validation for user input? Do you think it a bit faster?
>
>
> Thank very much
>
>
> Phal
>
>
> Reply


Hi Phal,

Javascript in general is slow.
I expect regexp from perl are much faster.
You can of course add the regexpr to JS, but you have to validate them again
on the server of course, since it is easy to circumvent JS and make your
own posting to the server.

Regards,
Erwin Moller

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      09-23-2005


phal wrote:

> I code Perl for CGI, I using regular expression to check the validation
>
> of user input, because the form is small and it run only from my own
> computer, anyways if many people using my form, do you think it will be
>
> slow due to Perl is run under server. How about using JavaSCript to
> check validation for user input? Do you think it a bit faster?


If you implement server-side validation first and then add client-side
validtion then yes, for those visiting with browsers with script
enabled/supported the validation does not require the trip back to the
server and initial checks are faster. But don't rely on client-side
validation and give up on the server-side validation.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Jim Davis
Guest
Posts: n/a
 
      09-23-2005
"phal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>
> Hi all;
>
>
> I code Perl for CGI, I using regular expression to check the validation
>
> of user input, because the form is small and it run only from my own
> computer, anyways if many people using my form, do you think it will be
>
> slow due to Perl is run under server. How about using JavaSCript to
> check validation for user input? Do you think it a bit faster?


I assume you mean "slow" because of the request, not the general speed of
the check, right?

On equal footing JavaScript will almost always be slower than PERL -
JavaScript carries a lot of baggage and is not as optimized for RegEx's as
Perl is. However in practice Perl runs on the server and is doing many more
tasks while the client is sitting spinning it's wheels - so JavaScript seems
much faster (it has a whole machine sitting there to do this little script
while the server might be doing dozens, or hundreds of requests at the same
time).

So - purely from a performance standpoint - JavaScript may be "faster". You
may eliminate a server request and provide the interface "instant feedback"
(although remember that you'll be delivering more script to the client which
slows things down some).

However it's not safer. Script can be disabled - which would eliminate your
checking completely. Since it runs on the client-side it can also be
modified to return incorrect results. In general you should consider
validations at every level of your application:

1) Client-side (JavaScript) validations improve the user experience but do
not protect the application. These are optional, but can greatly improve
the usability of your application.

2) Server-side (Perl, ColdFusion, ASP, etc) validations protect the
application from "bad" data. These prevent common attacks (SQL injection,
cross-site scripting) and prevent your application from failing due to bad
data (out of range numbers and dates for example). These are not optional
because no other layer of validation is assured to run. In other words the
application must protect itself because it can't trust anything else to do
it.

3) Persistence-layer (Database, LDAP, etc) validation protect the system
from storing "bad" data and allowing it to accumulate. This is needed to
protect your permanent information storage - there are few things so
damaging to a company than to discover that their data is corrupt. Many
people ignore this and say "the application will do it" but this is a
mistake: data has a way of getting around. Your application may very well
not be the only thing accessing the data - another application may need it
for example or somebody may use some provided management tool (SQL Server
Enterprise Manager for example). The data system should therefore protect
itself as much as possible.

Sorry for the lecture... but this stuff is commonly misunderstood. It's
best to get started on the right track in the first place than try to
retrofit things later.

Jim Davis





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
new RegExp().test() or just RegExp().test() Matěj Cepl Javascript 3 11-24-2009 02:41 PM
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
Ruby 1.9 - ArgumentError: incompatible encoding regexp match(US-ASCII regexp with ISO-2022-JP string) Mikel Lindsaar Ruby 0 03-31-2008 10:27 AM
Programmatically turning a Regexp into an anchored Regexp Greg Hurrell Ruby 4 02-14-2007 06:56 PM
RegExp.exec() returns null when there is a match - a JavaScript RegExp bug? Uldis Bojars Javascript 2 12-17-2006 09:59 PM



Advertisments