Web programming in C lang with TCC

M

Malcolm McLean

TCC seems to add the ability to use the source file
directly, which might be convenient, but I don't see that it's that big
an advantage.
It means the source can never get out of synch with the executable,
or, even worse, get lost.

That can often be a huge advantage if you need to hardcode strings.
The alternative of "softcoding" - writing a settings file parser in C
which turns into a little language all of its own - is a route fraught
with problems.
 
M

Malcolm McLean

Um - no. C *is* great for many things, but there are also many tasks
for which other tools are better suited. One-language-rules-the-world
nonsense has no place in the world of a professional developer.
There are far too many languages, all doing similar things.

When you use several, it becomes difficult. For instance I've been
using mainly Matlab for eighteen months now. But when I parse a file I
still have to look up the help for textscan - it behaves in one way if
you give it a format string with a newline, another way if it is
omitted, and you wouldn't know that from a brief description.
 
I

Ian Collins

It means the source can never get out of synch with the executable,
or, even worse, get lost.

That can often be a huge advantage if you need to hardcode strings.
The alternative of "softcoding" - writing a settings file parser in C
which turns into a little language all of its own - is a route fraught
with problems.

But it also the way to provide a client with an application who's
behaviour they can can modify without understanding the code. I have
one which is basically a very complex rules processing engine and the
rules are written by the client in OpenOffice.
 
M

Mel Smith

Love ... said
No more weird languages like Perl, Pythod, Ruby, PHP, ..blah..

Hi Love...


As I've noted before on this group before I was "boo'ed away", I use
the (x)Harbour language -- (a high level version of C which compiles into C,
etc) to run (as CGI executables) all three of my web sites from my own
Apache Server.

My advantage is that the Harbour language has its own built-in xBase
database power (or SQL, or ...) with all the familiarity and functions of C
including superb and easy string-handling functions and much, much more
(even inline C-Code, bit-twiddling, etc, etc if you wish).

You may wish (or not) to visit the sites below, and note that *all* the
power presented by each of these sites is handled solely by a CGI executable
made from C. Most of the pages shown are built 'live' by the C-based CGI,
and then passed to Apache for transmission to the client browser. All of
the pages (or templates) are read in :

cForm := memoread("c:\mysite\forms\somepageor template") //
Read in the actual page (or a template)
cForm := filloutpage(cForm) // call some function to fill out
fields in the page (if needed)
SEND cForm // send the page to Apache (where send is a
pre-definition for outstd(...)
Return nil // quit this thread (of perhaps 100s
of them)



-Mel Smith
webmaster
www.whosaway.com
www.mesaeastpark.com
www.frostdelay.com
 
K

Keith Thompson

Mel Smith said:
No more weird languages like Perl, Pythod, Ruby, PHP, ..blah..

As I've noted before on this group before I was "boo'ed away", I use
the (x)Harbour language -- (a high level version of C which compiles into C,
etc) to run (as CGI executables) all three of my web sites from my own
Apache Server.
[snip]

cForm := memoread("c:\mysite\forms\somepageor template") //
Read in the actual page (or a template)
cForm := filloutpage(cForm) // call some function to fill out
fields in the page (if needed)
SEND cForm // send the page to Apache (where send is a
pre-definition for outstd(...)
Return nil // quit this thread (of perhaps 100s
of them)

Your (x)Harbour language is not "a high level version of C".
It's just a different language. It might well be the greatest thing
since sliced bread, but it's not C. I'm sure there are plenty
of places where you can find people who are intersted in talking
about it. comp.lang.c is not one of them.

(Do you post to comp.lang.fortran and claim that it's a high level
version of Fortran?)
 
D

Dr Nick

Mel Smith said:
Love ... said


Hi Love...


As I've noted before on this group before I was "boo'ed away", I use
the (x)Harbour language -- (a high level version of C which compiles into C,
etc) to run (as CGI executables) all three of my web sites from my own
Apache Server.

My advantage is that the Harbour language has its own built-in xBase
database power (or SQL, or ...) with all the familiarity and functions of C
including superb and easy string-handling functions and much, much more
(even inline C-Code, bit-twiddling, etc, etc if you wish).

You may wish (or not) to visit the sites below, and note that *all* the
power presented by each of these sites is handled solely by a CGI executable
made from C. Most of the pages shown are built 'live' by the C-based CGI,
and then passed to Apache for transmission to the client browser. All of
the pages (or templates) are read in :

cForm := memoread("c:\mysite\forms\somepageor template") //
Read in the actual page (or a template)
cForm := filloutpage(cForm) // call some function to fill out
fields in the page (if needed)
SEND cForm // send the page to Apache (where send is a
pre-definition for outstd(...)
Return nil // quit this thread (of perhaps 100s
of them)

That's not C. The sites in my sig are also produced using a program
written in C that does all the clever stuff.

But
database input '../canal.sqlite'
for i=place '.*'
print i.name,i.canal
end for i

which prints around 13000 places and the waterway that they are on is no
more C than your := stuff.
 
M

Mel Smith

Keith said:
(Do you post to comp.lang.fortran and claim that it's a high level
version of Fortran?)

Not yet -- but my Masters Thesis had a significant portion of it based
on Fortran IV on an old IBM 370 at ther University of Alberta in 1973 :))


All the developers of (x)Harbour are C experts (and there are dozens of
these Open Source guys), and usually code *only* in C, using primarily
MinGW's gcc or Borland's 5.5.n versions of C.

So, if these people are asked if the Harbour language Hi-C, they'd
probably say: "Yes"


-Mel
 
L

lovecreatesbeauty

I don't think anyone has ever suggested that it's not possible.
And for generating static content, as your program does, it probably

I think again. And I think the content generated by TCC is dynamic, or
TCC can generates dynamic content.
For other purpose, scripting languages offer much easier string
handling, which is a considerable advantage in this context.

What good is in other script languages string handling which can't be
made in C? C has regex, strcmp, strncat, strncpy, strstr. In case
there's no one, just write one. It's C way. Can you tell more about
this?
 
A

Angel

What good is in other script languages string handling which can't be
made in C? C has regex, strcmp, strncat, strncpy, strstr. In case
there's no one, just write one. It's C way. Can you tell more about
this?

Try writing a C program that can read and store a string of arbitrary
length from stdin. How many statements do you need?

In Perl, it's only one. C's string library completely pales in
comparison to what Perl can do. C is a great language for many things,
but its handling of strings is subpar at best.
 
K

Keith Thompson

lovecreatesbeauty said:
I think again. And I think the content generated by TCC is dynamic, or
TCC can generates dynamic content.


What good is in other script languages string handling which can't be
made in C? C has regex, strcmp, strncat, strncpy, strstr. In case
there's no one, just write one. It's C way. Can you tell more about
this?

Not here. Study a scripting language if you want to learn about it.
 
M

Mel Smith

Joe said:
No Mel. The (x)Harbour language is Clipper, a dialect of dBASE. It is not
remotely related to C. You're only annoying the regulars here.


Wrong Joe !

The harbour language is *not* a dialect of Clipper/dBase but a
completely new re-write, and it has completely subsumed the old Clipper
language, and was written purely in C and new Harbour functions over the
past ten years.

Clipper had only 18 source modules written in C, and only *one*
sizeable one (sdx.c) which implemented a certain off-the-wall and now
forgotten database driver.

The remainder of the 18 were very short C routines similar to the one
that follows at the bottom here

OTOH, Harbour has at least 626 complex and sizeable C routines that make
up its extensive base of source code. From those C routines, there are
about another 200 Harbour routines made from them to complete the source
code

So, Joe, thanks for being trying to keep me straight.

... and I emphasixe that Harbour is *more C* than anything else except C
itself.

-Mel



**** an old function from 1993 written in C in as a small part of the old
Clipper Language ****

/*
* YesNo( lExpr ) -> cValue
*
* Given a logical expression, returns the
* string "Yes" if true, and "No " if false.
*
* Copyright (C) 1993, Computer Associates, Inc. All Rights Reserved
*/
#include "clipdefs.h"
#include "extend.api"
#include "item.api"

CLIPPER YesNo( void )
{
ITEM itemLughi, itemCRet;

// Warning: "Yes" and "No " strings use DGROUP!
// In general, this is a bad practice, but ... 6 bytes?
// I doubt if the universe will explode (unless this is a
// Doug Adams program)

itemCRet = _itemPutC( NULL, "No " );

if (PCOUNT > 0)
{
itemLughi = _itemParam( 1 );
if (_itemGetL( itemLughi ))
itemCRet = _itemPutC( itemCRet, "Yes");

_itemRelease( itemLughi );
}

_itemRelease( _itemReturn( itemCRet ) );
return;
}
**************************************
 
K

Keith Thompson

Mel Smith said:
Keith said:

Not yet -- but my Masters Thesis had a significant portion of it based
on Fortran IV on an old IBM 370 at ther University of Alberta in 1973 :))


All the developers of (x)Harbour are C experts (and there are dozens of
these Open Source guys), and usually code *only* in C, using primarily
MinGW's gcc or Borland's 5.5.n versions of C.

The language used to implement (x)Harbour is irrelevant.
So, if these people are asked if the Harbour language Hi-C, they'd
probably say: "Yes"

(You left out several words, but I'll assume you mean "if the
Harbour language is a high level version of C". Hi-C is a drink.)

Fine, ask them. If they know anything about programming languages,
I expect you'll be surprised by their answers.

You've had multiple C experts tell you that Harbour is not a version
of C. Why do you not believe us?
 
M

Mel Smith

Keith muttered:

"> The language used to implement (x)Harbour is irrelevant.

If it wasn't mostly all C and Harbour itself, I wouldn't have come back
here to post. Because my life is now mostly web development with xHarbour, I
replied to this particular post. But it *is* relevant because C is the
underpinning of all of Harbour.
(You left out several words, but I'll assume you mean "if the
Harbour language is a high level version of C". Hi-C is a drink.)

Yes, thanks for correcting the typo.
Fine, ask them. If they know anything about programming languages,
I expect you'll be surprised by their answers.
I don't think so. They spend most of there lives using C to create
higher level functions and statements. So they would probably say something
like:

"I build C functions all day. I manipulate them and massage them to
create hi-level functions for the app/language called xHarbour. But xHarbour
is basically a set of rebuilt C functions to implement and ease features
that others find difficult in C or non-existent in C. "
You've had multiple C experts tell you that Harbour is not a version
of C. Why do you not believe us?

To correct you, I didn't say Harbour is a version of C, but simply a
much higher level version of C, and is totally implemented by C. Also,
because I'm a bit stubborn.

Also, I forgot to mention that two flavours of Harbour exist with
competing groups of developers: Harbour and xHarbour.

If you visit www.whosaway.com, use password HB for Harbour, and XHB for
xHarbour.

I'll drop away for awhile now ...

-Mel
 
J

James

Mel Smith said:
Keith muttered:
[...]
You've had multiple C experts tell you that Harbour is not a version
of C. Why do you not believe us?

To correct you, I didn't say Harbour is a version of C, but simply a
much higher level version of C, and is totally implemented by C.

Isn't a higher level version of C a version of C?
 
J

James

Angel said:
Try writing a C program that can read and store a string of arbitrary
length from stdin. How many statements do you need?

In Perl, it's only one.

After I create an "all-in-one" function for the task, I can do it in one
statement as well; right? I kind of think it's silly to compare C-style
strings with the strings that belong to another language that has much
better "native" string handing resources.

C's string library completely pales in
comparison to what Perl can do. C is a great language for many things,
but its handling of strings is subpar at best.

Fair enough.
 
S

Seebs

As I've noted before on this group before I was "boo'ed away", I use
the (x)Harbour language -- (a high level version of C which compiles into C,

I think the only complaint here is that this is not a "higher level version of
C" but "a totally different language", which compiles into C. C does not have
a := assignment operator. A language which does is not a version of C, but
some other kind of language.

-s
 
S

Seebs

Seebs said:
Um, things like Apache expect both characters and most platforms do
not turn \n into two characters. Indeed sizeof("\n") is 2 ...
always. Where things differ is what \n DOES.
Pretty sure it'll be sizeof(char *), not sizeof(char[2]). :)
sizeof "\n" == 2 from 6.3.2.1 p3 (and 6.4.5 p5).

Woah.

That I could be wrong about this for twenty years without noticing sort
of suggests that it's esoteric, but it's still pretty basic stuff. *sigh*

-s
 
O

Oliver Jackson

The language used to implement (x)Harbour is irrelevant.


(You left out several words, but I'll assume you mean "if the
Harbour language is a high level version of C".  Hi-C is a drink.)

It's true that the Minute Maid division of The Coca-Cola Company
markets a soft drink with the name "Hi-C." However, let's not forget
that the original Hi-C, pioneered in the early twentieth century, is
an enema formula rich in vitamin C and other nutrients essential for
colon health.
 
K

Keith Thompson

James said:
After I create an "all-in-one" function for the task, I can do it in one
statement as well; right?

Not necessarily. Typically both the function and the caller have
to deal with memory management.
I kind of think it's silly to compare C-style
strings with the strings that belong to another language that has much
better "native" string handing resources.

By saying that one language has much better "native" string handing
resources than another, you've just compared them. I don't find that
silly at all.

[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,224
Latest member
Gwen068088

Latest Threads

Top