Re: [HACKERS] web-based front end development

From: "D'Arcy" "J(dot)M(dot)" Cain <darcy(at)druid(dot)net>
To: dms(at)wplus(dot)net (Dmitry Samersoff)
Cc: lockhart(at)alumni(dot)caltech(dot)edu, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] web-based front end development
Date: 1999-07-30 12:02:45
Message-ID: m11ABN7-0000cIC@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thus spake Dmitry Samersoff
> On 29-Jul-99 Thomas Lockhart wrote:
> > (for obvious reasons) and I was wondering if anyone had suggestions
> > for a good approach to app development for brower-based user
> > interfaces.
>
> You begin the star war ;-))
>
> I use three different interface for different tasks

[PHP3, Perl and C++ discussion ellided]

Or, use Python for everything.

> Firstly, I use php3 to make web based interface

I use Python over PHP because, like PHP, Ican embed it into the web
server but I can reuse the code in non-web applications so I don't
have to reinvent each wheel.

> http://www.piter-press.ru is an example (not the best, but the only public
> available)
> PHP3 code looks like
>
> $qu = pg_exec($conn, "select * from users where (uid = '$uid');" );
> $nm = pg_numrows($qu);
> if ($nm > 0)
> {
> $data = pg_fetch_object ($qu, $i);
> $xpin = crypt($pin, $data->pin);
> if ($xpin == $data->pin)
> { BlueEcho("PIN of user '$uid' is valid");
> }
> else
> { RedEcho("Sorry, you enter incorrect PIN for user '$uid'");
> }
> }
>
> pg_close($conn);

for data in db.query("select * from users where uid = '%d'" % uid).dictresult():
if crypt(pin, data.pin) == data.pin:
print "PIN of user '%d' is valid" % uid
else:
print "Sorry, you enter incorrect PIN for user '%d'" % uid

I assume that BlueEcho and RedEcho are simply functions that wrap the
strings in font color tags. Such functions can easily be added to Python.
See http://www.druid.net/rides/ for a real example.

> Secondly, I use Perl every time as I need write anything for five minits
> just because I use Perl about five years.

I use Python over Perl because I find it to be a cleaner and more logical
language. This is a personal preference thing, of course.

> Third, I use C++ for really hard tasks (By historical reasons, I use my own
> library, not libpq++)

I hardly do anything in C (never cared much for C++ except for a few
specific features) any more as Python gives me the ability to do anything
I could do in C and, if needed, I can always write low level code in C
and link it in.

Check out http://www.python.org/ for more information. For a PostgreSQL
interface for Python see http://www.druid.net/pygresql/ or look in the
PostgreSQL source tree.

> IMHO, PHP3 is the best choice for Web it self, but bakground programs
> should be written in C/C++

As I said, one language for all makes code reuse easier. I find that my
projects generally require web interfaces, CLI interfaces as well as
scheduled background tasks and I can write modules that get imported into
all of them saving me much development time.

> So, make your choice and good luck ;-))

Can't argue with that.

--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message D. Jay Newman 1999-07-30 12:29:05 Re: [HACKERS] web-based front end development
Previous Message The Hermit Hacker 1999-07-30 11:48:56 Re: [HACKERS] cvs log for libpq-int.h ...