Pascal and CGI programming 
Author Message
 Pascal and CGI programming

Just found FREEPascal.ORG this weekend - gave it a spin since Pascal was
my first and still one of my favourite languages.

I made an HTML form with a few fields, and wrote two identical programs
that just spat out a page telling the user what they input in those
fields.  The languages I used were Pascal and Perl.  These are my
findings:

1)  Both were equally as simple to write.
2)  On multiple trials, 3 seconds for the Perl script to return results
and <2 seconds for the Pascal program.  That's significant given the
minor task they had to do.
3)  The Pascal program was really small, and used significantly less
memory than a perl interpreter + script.

I think that's pretty sweet.  My question is - are there a lot of people
writing CGI in Pascal?  Is there something I am missing - some reason
why I should stick with my Perl?

(As a follow up... can anybody tell me anything about connecting to a
database using ODBC in Pascal?)



Fri, 28 Nov 2003 11:59:57 GMT  
 Pascal and CGI programming

Quote:

> Just found FREEPASCAL.ORG this weekend - gave it a spin since Pascal was
> my first and still one of my favourite languages.

> I made an HTML form with a few fields, and wrote two identical programs
> that just spat out a page telling the user what they input in those
> fields.  The languages I used were Pascal and Perl.  These are my
> findings:

> 1)  Both were equally as simple to write.
> 2)  On multiple trials, 3 seconds for the Perl script to return results
> and <2 seconds for the Pascal program.  That's significant given the
> minor task they had to do.

Try to load the fastcgi module. That will speed it up repeated access some
more. Most of the time is loading and initializing the binary, not running
it.

Quote:
> 3)  The Pascal program was really small, and used significantly less
> memory than a perl interpreter + script.
> I think that's pretty sweet.  My question is - are there a lot of people
> writing CGI in Pascal?  Is there something I am missing - some reason
> why I should stick with my Perl?

As far as I know, there are quite some people that do this. But most of the
ones that I know, do that for inhouse intranetworks.

Quote:
> (As a follow up... can anybody tell me anything about connecting to a
> database using ODBC in Pascal?)

Depends on the OS. In some cases (e.g. MySQL, Oracle) a direct connection
maybe possible.

FPC doesn't support ODBC at the moment, but it only needs a driver and a
decent interface. So a simple header translation might do the job.

If you want further information about databases, I advise you to subscribe
to the fpc-pascal maillist, because I'm not any good with databases :-)



Fri, 28 Nov 2003 15:50:25 GMT  
 Pascal and CGI programming

Quote:

> Just found FREEPASCAL.ORG this weekend - gave it a spin since Pascal was
> my first and still one of my favourite languages.

> I made an HTML form with a few fields, and wrote two identical programs
> that just spat out a page telling the user what they input in those
> fields.  The languages I used were Pascal and Perl.  These are my
> findings:

> 1)  Both were equally as simple to write.
> 2)  On multiple trials, 3 seconds for the Perl script to return results
> and <2 seconds for the Pascal program.  That's significant given the
> minor task they had to do.

I can't believe that. What webserver are you using? Using
apache/mod_perl shoud speed up your perl program significantly because
compiling Perl takes a lot more time than running the script.

Quote:
> 3)  The Pascal program was really small, and used significantly less
> memory than a perl interpreter + script.

Might be.

Quote:
> I think that's pretty sweet.  My question is - are there a lot of people
> writing CGI in Pascal?  Is there something I am missing - some reason
> why I should stick with my Perl?

Because Perl is a great language (so is Pascal)!
In CGIs you usually have to parse the user's input ("use CGI;"). This is
much more simple in perl because of the built-in RE support (perldoc
perlre). These things are very time-consuming in Pascal. Also execution
speed does not really matter because perl is very fast.
I'd say: Language choice depends on what you want to do and which
language you like best. Small scripts should be written in Perl because
of a faster developing time.

Quote:
> (As a follow up... can anybody tell me anything about connecting to a
> database using ODBC in Pascal?)

Another reason to use Perl! The DBI (including DBD::ODBC) is very
powerful.

Wolf



Sat, 29 Nov 2003 00:08:27 GMT  
 Pascal and CGI programming

Quote:


>> Just found FREEPASCAL.ORG this weekend - gave it a spin since Pascal was

> Because Perl is a great language (so is Pascal)!
> In CGIs you usually have to parse the user's input ("use CGI;"). This is
> much more simple in perl because of the built-in RE support

Why? For several Pascal compilers, Regex units exist.

Quote:
> perlre). These things are very time-consuming in Pascal.

No.

Quote:
>Also execution
> speed does not really matter because perl is very fast.
> I'd say: Language choice depends on what you want to do and which
> language you like best. Small scripts should be written in Perl because
> of a faster developing time.

Only if you never plan to extend them. Look e.g. at the Latex2Html script
:-)

Quote:
>> (As a follow up... can anybody tell me anything about connecting to a
>> database using ODBC in Pascal?)

> Another reason to use Perl! The DBI (including DBD::ODBC) is very
> powerful.

De ODBC coupling will not be made in Perl itself, and the libraries it is
based on, will probably be usable in a suitable pascal compiler too.


Sat, 29 Nov 2003 00:49:18 GMT  
 Pascal and CGI programming
I do, but note that CGI is sharply limited by the server it runs on. Ie.,
if you are running your web page on a remote server, you need to
compile a program that runs there. Now there are a lot more servers
that run Windows than used to, but most still run Sun/Unix. That means
that you need to compile for that platform, and the hoster may or may
not appreciate you attempting to set up a full compiler on his system.

This is why TCL/Perl is popular. Its interpretive, so runs anywhere without
a compiler. After that would be a shell for Unix, then C itself, based on the
simple fact that virtually all servers have a compiler for that installed.

Another possibility, that I have not tried, is to run a translator, PtoC, on
either your machine or the server, then compile and run in C.

Quote:

> I think that's pretty sweet.  My question is - are there a lot of people
> writing CGI in Pascal?  Is there something I am missing - some reason
> why I should stick with my Perl?

> (As a follow up... can anybody tell me anything about connecting to a
> database using ODBC in Pascal?)

--
"I'd like to see cpp abolished" - Bjarne Stroustrup
[cpp is the original name of C PreProcessor]


Sat, 29 Nov 2003 01:54:16 GMT  
 Pascal and CGI programming

Quote:


> > Because Perl is a great language (so is Pascal)!
> > In CGIs you usually have to parse the user's input ("use CGI;"). This is
> > much more simple in perl because of the built-in RE support

> Why? For several Pascal compilers, Regex units exist.

I know. But it is simpler to write
  print 'test passed ' if /abc\dxyz$/;
than
  var re: TRegExpr;
...
  re:=RegExp.Create('abc\dxyz$');
  if re.Match(_) then Write('test passed');
  re.Free;

1 Line Perl, 3 Lines Pascal!

Quote:
> >Also execution
> > speed does not really matter because perl is very fast.
> > I'd say: Language choice depends on what you want to do and which
> > language you like best. Small scripts should be written in Perl because
> > of a faster developing time.

> Only if you never plan to extend them. Look e.g. at the Latex2Html script
> :-)

use strict; use warnings; use diagnostics;
# and your Perl will look like Pascal... :-)

also extending is not a language-specific problem, it's more a problem
of your personal programming style!

Quote:
> >> (As a follow up... can anybody tell me anything about connecting to a
> >> database using ODBC in Pascal?)

> > Another reason to use Perl! The DBI (including DBD::ODBC) is very
> > powerful.

> De ODBC coupling will not be made in Perl itself, and the libraries it is
> based on, will probably be usable in a suitable pascal compiler too.

True. But there are even books about Perl-DBI/DBD modules ("Programming
the Perl DBI") and these modules are standard. Are there any units in
pascal that provide all the features of the Perl-modules? And even if
there was a unit, a lot less people use pascal for this purpose. And
very few people know the unit -> maybe more bugs?
And what if you change your database? In Perl, you simply change the
driver name. Is there a pascal unit like DBI?

Maybe I'm getting a bit OT here...

Wolf

PS: I also like Pascal, especially FreePascal and Delphi! But working
with Strings in Pascal is horror if you know how simple it is in Perl.



Sat, 29 Nov 2003 02:16:43 GMT  
 Pascal and CGI programming

Quote:

> Another possibility, that I have not tried, is to run a translator, PtoC, on
> either your machine or the server, then compile and run in C.

The last time I tried p2c the output wasn't really useable. I don't
think p2c | cc is a good idea especially if you make use of certain
pascal-dialects.

Wolf



Sat, 29 Nov 2003 02:21:30 GMT  
 Pascal and CGI programming

Quote:



>> > Because Perl is a great language (so is Pascal)!
>> > In CGIs you usually have to parse the user's input ("use CGI;"). This is
>> > much more simple in perl because of the built-in RE support

>> Why? For several Pascal compilers, Regex units exist.

> I know. But it is simpler to write
>   print 'test passed ' if /abc\dxyz$/;
> than
>   var re: TRegExpr;
> ...
>   re:=RegExp.Create('abc\dxyz$');
>   if re.Match(_) then Write('test passed');
>   re.Free;

> 1 Line Perl, 3 Lines Pascal!

Typing is never limiting. Thinking is. And IMHO Pascal has a clearer syntax
than Perl.

The idea to compare the power of programming languages on how much you can
stuff on one line is ridiculous.

The typing is rarely limiting. Debugging is, and a clear syntax avoids bugs
:-)

Quote:
>> >Also execution
>> > speed does not really matter because perl is very fast.
>> > I'd say: Language choice depends on what you want to do and which
>> > language you like best. Small scripts should be written in Perl because
>> > of a faster developing time.

>> Only if you never plan to extend them. Look e.g. at the Latex2Html script
>> :-)

> use strict; use warnings; use diagnostics;
> # and your Perl will look like Pascal... :-)

Then I have never seen Perl that uses those :-)

Quote:
> also extending is not a language-specific problem, it's more a problem
> of your personal programming style!

I don't know Perl that well, but the problem I have with a lot of non-typed
languages, is that it introduces hard to trace errors.

Quote:
>> >> (As a follow up... can anybody tell me anything about connecting to a
>> >> database using ODBC in Pascal?)

>> > Another reason to use Perl! The DBI (including DBD::ODBC) is very
>> > powerful.

>> De ODBC coupling will not be made in Perl itself, and the libraries it is
>> based on, will probably be usable in a suitable pascal compiler too.

> True. But there are even books about Perl-DBI/DBD modules ("Programming
> the Perl DBI") and these modules are standard. Are there any units in
> pascal that provide all the features of the Perl-modules?

I don't know Perl well enough, but Delphi + spinoffs seem to gather around
TDataSet'ish abstractions for database support.

Quote:
> And even if there was a unit, a lot less people use pascal for this
> purpose. And very few people know the unit -> maybe more bugs?

You are suggesting Delphi is less used than Perl? Bold statement. Maybe in
nunber of programmers, but not in lines.


Sat, 29 Nov 2003 02:58:29 GMT  
 Pascal and CGI programming
Perl is a write-only computer language :-)

Quote:



> > > Because Perl is a great language (so is Pascal)!
> > > In CGIs you usually have to parse the user's input ("use CGI;"). This is
> > > much more simple in perl because of the built-in RE support

> > Why? For several Pascal compilers, Regex units exist.

> I know. But it is simpler to write
>   print 'test passed ' if /abc\dxyz$/;
> than
>   var re: TRegExpr;
> ...
>   re:=RegExp.Create('abc\dxyz$');
>   if re.Match(_) then Write('test passed');
>   re.Free;

> 1 Line Perl, 3 Lines Pascal!

> > >Also execution
> > > speed does not really matter because perl is very fast.
> > > I'd say: Language choice depends on what you want to do and which
> > > language you like best. Small scripts should be written in Perl because
> > > of a faster developing time.

> > Only if you never plan to extend them. Look e.g. at the Latex2Html script
> > :-)

> use strict; use warnings; use diagnostics;
> # and your Perl will look like Pascal... :-)

> also extending is not a language-specific problem, it's more a problem
> of your personal programming style!

> > >> (As a follow up... can anybody tell me anything about connecting to a
> > >> database using ODBC in Pascal?)

> > > Another reason to use Perl! The DBI (including DBD::ODBC) is very
> > > powerful.

> > De ODBC coupling will not be made in Perl itself, and the libraries it is
> > based on, will probably be usable in a suitable pascal compiler too.

> True. But there are even books about Perl-DBI/DBD modules ("Programming
> the Perl DBI") and these modules are standard. Are there any units in
> pascal that provide all the features of the Perl-modules? And even if
> there was a unit, a lot less people use pascal for this purpose. And
> very few people know the unit -> maybe more bugs?
> And what if you change your database? In Perl, you simply change the
> driver name. Is there a pascal unit like DBI?

> Maybe I'm getting a bit OT here...

> Wolf

> PS: I also like Pascal, especially FreePascal and Delphi! But working
> with Strings in Pascal is horror if you know how simple it is in Perl.

--
"I'd like to see cpp abolished" - Bjarne Stroustrup
[cpp is the original name of C PreProcessor]


Sat, 29 Nov 2003 04:03:19 GMT  
 Pascal and CGI programming

Quote:

> Perl is a write-only computer language :-)

Also, you have to do quite a lot of scripting to justify learning another
language +libs if you already know Pascal (or C for that matter).

It may be different for newbies, but for people with foundation in Pascal
learning some scripting language is a *lot* more work, with marginal
benefits at best while doing those tasks in the language they know
strengthen the knowledge they have about that language.



Sat, 29 Nov 2003 04:47:40 GMT  
 Pascal and CGI programming


Quote:
> True. But there are even books about Perl-DBI/DBD modules ("Programming
> the Perl DBI") and these modules are standard. Are there any units in
> pascal that provide all the features of the Perl-modules? And even if
> there was a unit, a lot less people use pascal for this purpose. And
> very few people know the unit -> maybe more bugs?
> And what if you change your database? In Perl, you simply change the

Well, I think this is the point that I was getting at to begin with,
actually.  Don't get me wrong - I have had a love affair with Perl since
I started learning it a few months ago - it's solved numerous problems
for me, and will still be my language of choice for many things.

However, I am sure that Pascal would be better suited than Perl for some
CGI tasks, especially if (ok... point finally coming up...) the Pascal
community were as "together" as the Perl community.  I'm sure there are
no Perl modules that couldn't just as easily be Pascal Units if the
community were to take the time.

If Pascal had the same kind of Units available to it as Perl has
Modules, then which do you think would be better for CGI?

BTW, I don't run Apache for many good reasons and so I only have
straight CGI available to me.  An aside, but one that nonetheless covers
most of the responses to me ;)



Sat, 29 Nov 2003 07:02:42 GMT  
 Pascal and CGI programming

Quote:
> (As a follow up... can anybody tell me anything about connecting to a
> database using ODBC in Pascal?)

Have you considered using Irie Pascal to write your CGI programs?
It's shareware so you can try it out first to see if you like it.
Irie Pascal has built-in support for ODBC (on Windows) and
MySQL on (Linux/FreeBSD,Solaris/Sparc, and Solaris x86).

The website is   http://www.irietools.com



Tue, 02 Dec 2003 00:56:44 GMT  
 Pascal and CGI programming

Quote:

>> (As a follow up... can anybody tell me anything about connecting to a
>> database using ODBC in Pascal?)

> Have you considered using Irie Pascal to write your CGI programs?
> It's shareware so you can try it out first to see if you like it.
> Irie Pascal has built-in support for ODBC (on Windows) and
> MySQL on (Linux/FreeBSD,Solaris/Sparc, and Solaris x86).

> The website is   http://www.irietools.com

Does Irie support include support for webtools (e.g. interpreter remains
resident) ?


Tue, 02 Dec 2003 06:21:31 GMT  
 Pascal and CGI programming

Quote:
> Does Irie support include support for webtools (e.g. interpreter remains
> resident) ?

I'm not sure what you mean by "support for webtools", but the interpreter
does not remain resident across multiple "hits" (i.e. if you write a CGI
appliction with Irie Pascal then the interpreter is re-loaded everytime
your application is executed).


Wed, 03 Dec 2003 12:57:31 GMT  
 Pascal and CGI programming

Quote:

>> Does Irie support include support for webtools (e.g. interpreter remains
>> resident) ?

> I'm not sure what you mean by "support for webtools", but the interpreter
> does not remain resident across multiple "hits" (i.e. if you write a CGI
> appliction with Irie Pascal then the interpreter is re-loaded everytime
> your application is executed).

That is a bit of a problem, since it makes it a bit slow (or high load on
the machine).

For the script languages that have Apache module support, the interpreter
remains resident, and for binary CGI one can use the FastCGI module.



Wed, 03 Dec 2003 18:28:09 GMT  
 
 [ 18 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Delphi CGI Problem - CGI Program Only Runs When Delphi Also Runs

2. CGI - How to use Delphi for CGI programming

3. Q: CGI programming in Turbo Pascal?

4. Using Turbo Pascal for Stdin and Stdout CGI programs:

5. A CGI program using with IIS

6. how to make cgi program in tpw?

7. CGI programming in TP 6.0, please help

8. Programming CGI from TP6

9. How to use Delphi to write CGI program

10. TP - CGI Script Programs

11. CGI Programming in TP?

12. Cgi programming

 

 
Powered by phpBB® Forum Software