The end of C-like script languages - C script with TCC

L

lovecreatesbeauty

On French genius' TCC page: TCC can also be used to make C scripts,
i.e. pieces of C source that you run as a Perl or Python script.
Compilation is so fast that your script will be as fast as if it was
an executable.

I'll try TCC and use C to replace PHP for web scripting, and Perl for
shell script. No need to bear with all the strange, unneeded and
different syntaxes in Php and Perl. What do you see?
 
T

Tom St Denis

On French genius' TCC page: TCC can also be used to make C scripts,
i.e. pieces of C source that you run as a Perl or Python script.
Compilation is so fast that your script will be as fast as if it was
an executable.

I'll try TCC and use C to replace PHP for web scripting, and Perl for
shell script. No need to bear with all the strange, unneeded and
different syntaxes in Php and Perl. What do you see?

Unless they added string handling ala perl it ain't replacing squat.

Tom
 
B

Ben Bacarisse

lovecreatesbeauty said:
On French genius' TCC page: TCC can also be used to make C scripts,
i.e. pieces of C source that you run as a Perl or Python script.
Compilation is so fast that your script will be as fast as if it was
an executable.

I'll try TCC and use C to replace PHP for web scripting, and Perl for
shell script. No need to bear with all the strange, unneeded and
different syntaxes in Php and Perl. What do you see?

I see much wailing and gnashing of teeth. Why replace a language
designed for the job with one designed for quite another?
 
M

Malcolm McLean

I see much wailing and gnashing of teeth.  Why replace a language
designed for the job with one designed for quite another?
Because everyone who did any serious programming in the past 20 years
can knock up a small script in C. With perl, I find myself scratching
about in the manual for quite simple operations. like sorting a list
of strings by suffix.
 
B

Ben Bacarisse

Malcolm McLean said:
Because everyone who did any serious programming in the past 20 years
can knock up a small script in C.

I can't refute that though I know at least two people who have done
serious programming very recently and who would not be able to write any
C. Did you mean "for the past 20 years" rather than "in the past 20
years"? Anyway, currently this is just another fact that's been stated
before which we are expected submit (or spend time researching
ourselves).
With perl, I find myself scratching
about in the manual for quite simple operations. like sorting a list
of strings by suffix.

I don't see what I am expected to take from this. Do you mean that you
don't know Perl well enough to know how suitable it is for the job? Or
maybe you mean that, since you know C, and everything can eventually be
written in C, that there is no point in knowing any other language?

If all you mean is that you don't currently have the time or the
inclination to learn Perl, that's fine, but it is not much of an
argument in favour of C as scripting language.
 
R

Rui Maciel

Malcolm said:
Because everyone who did any serious programming in the past 20 years
can knock up a small script in C. With perl, I find myself scratching
about in the manual for quite simple operations. like sorting a list
of strings by suffix.

In the scripting world, perl isn't exactly the only choice. In fact, I'm
not aware of a single instance of perl being used as an embedded scripting
language. As Python and Lua are extensively used and even designed for
that purpose, they tend to be better comparissons.

Considering this, I don't believe that a programmer with over 20 years of
experience developing software will have any trouble hacking up simple
Python/Lua scripts.


Rui Maciel
 
R

Rui Maciel

lovecreatesbeauty said:
On French genius' TCC page: TCC can also be used to make C scripts,
i.e. pieces of C source that you run as a Perl or Python script.
Compilation is so fast that your script will be as fast as if it was
an executable.

I'll try TCC and use C to replace PHP for web scripting, and Perl for
shell script. No need to bear with all the strange, unneeded and
different syntaxes in Php and Perl. What do you see?

Are you a developer for this TCC thing?


Rui Maciel
 
S

Stefan Ram

Malcolm McLean said:
like sorting a list of strings by suffix.

I do not know Perl that well, but was able to construct a
solution using results of a web search engine in a few minutes:

#!/usr/bin/perl
#perl 5.8.3

use strict;
use warnings;

sub suffix( $ ){ substr $_[ 0 ], -3; }

print sort{ suffix( $a )cmp suffix( $b )}
qw( alpha.bat gamma.exe beta.bat );

I guess, it cannot become much shorter or more readable
when implemented in C.
 
B

Ben Bacarisse

... I don't believe that a programmer with over 20 years of
experience developing software will have any trouble hacking up simple
Python/Lua scripts.

Is the use of 20 a coincidence? If you were trying to turn Malcolm
McLean's claim around, then I'll point out that he said "*in* the last 20
years" not "*for* the last 20 years".
 
R

Rui Maciel

Ben said:
Is the use of 20 a coincidence? If you were trying to turn Malcolm
McLean's claim around, then I'll point out that he said "*in* the last
20 years" not "*for* the last 20 years".

The claim hasn't been turned around. Either way you put it, considering
someone with 20 years of experience or someone with any serious
programming experience in the last 20 years, the point still stands: no
one with that level of experience will have any trouble hacking up simple
Python/Lua scripts.


Rui Maciel
 
R

Rui Maciel

William said:
Python doesn't embed any better than Perl.

Malcolm McLean's comment referred to how hard it is to write small scripts
in Perl. I've pointed out that there are other scripting languages that
are used as embedded scripting languages and are much nicer to write small
scripts on. No matter how much capable Perl's C API is than Python's, it
won't make writing perl scripts any simpler.


Rui Maciel
 
B

Ben Bacarisse

Rui Maciel said:
The claim hasn't been turned around. Either way you put it, considering
someone with 20 years of experience or someone with any serious
programming experience in the last 20 years, the point still stands: no
one with that level of experience will have any trouble hacking up simple
Python/Lua scripts.

OK, so you'd go further than you did originally. I understood your
point and I think I agree. I just wanted to point out it was not the
same kind of statement as the one to which you seemed to offering a
rebuttal.
 
N

Nobody

Consider, for example, that Python doesn't support multiple interpreter
instances,

It supports multiple sub-interpreters, which is almost the same thing.
There's some shared state, e.g. extension modules are only loaded once
per process rather than per interpreter.
 
M

Michael Press

Malcolm McLean said:
like sorting a list of strings by suffix.

I do not know Perl that well, but was able to construct a
solution using results of a web search engine in a few minutes:

#!/usr/bin/perl
#perl 5.8.3

use strict;
use warnings;

sub suffix( $ ){ substr $_[ 0 ], -3; }

print sort{ suffix( $a )cmp suffix( $b )}
qw( alpha.bat gamma.exe beta.bat );

I guess, it cannot become much shorter or more readable
when implemented in C.

To save calls to sub suffix
link each string with its suffix.

#!/usr/bin/perl
#perl 5.8.3

use strict;
use warnings;

sub suffix( $ ){ substr $_[ 0 ], -3; }

print map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, suffix($_)] }
qw ( alpha.bat gamma.exe beta.bat );
 
J

James Waldby

Malcolm McLean said:
like sorting a list of strings by suffix.

I do not know Perl that well, but was able to construct a solution
using results of a web search engine in a few minutes: ....
sub suffix( $ ){ substr $_[ 0 ], -3; }

print sort{ suffix( $a ) cmp suffix( $b )}
qw( alpha.bat gamma.exe beta.bat );
....
To save calls to sub suffix
link each string with its suffix.

#!/usr/bin/perl
#perl 5.8.3

use strict;
use warnings;

sub suffix( $ ){ substr $_[ 0 ], -3; }

print map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, suffix($_)] }
qw ( alpha.bat gamma.exe beta.bat );

You'll have even fewer calls to the suffix sub if you delete
it, and in place of
map { [$_, suffix($_)] }
write
map { [$_, substr $_, -3] }
 
M

Michael Press

James Waldby said:
like sorting a list of strings by suffix.

I do not know Perl that well, but was able to construct a solution
using results of a web search engine in a few minutes: ...
sub suffix( $ ){ substr $_[ 0 ], -3; }

print sort{ suffix( $a ) cmp suffix( $b )}
qw( alpha.bat gamma.exe beta.bat );
...
To save calls to sub suffix
link each string with its suffix.

#!/usr/bin/perl
#perl 5.8.3

use strict;
use warnings;

sub suffix( $ ){ substr $_[ 0 ], -3; }

print map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, suffix($_)] }
qw ( alpha.bat gamma.exe beta.bat );

You'll have even fewer calls to the suffix sub if you delete
it, and in place of
map { [$_, suffix($_)] }
write
map { [$_, substr $_, -3] }

Yes. The idea was to conceptually isolate
the substring finder.

* It may be used elsewhere, so there is one code to change.

* It may need ancillary information,
or be somewhat more complicated.

* How do we know that the interpreter is no slower
with the subroutine call than the inline code?
 
P

Phil Carmody

Michael Press said:
James Waldby said:
sub suffix( $ ){ substr $_[ 0 ], -3; }

print map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, suffix($_)] }
qw ( alpha.bat gamma.exe beta.bat );

You'll have even fewer calls to the suffix sub if you delete
it, and in place of
map { [$_, suffix($_)] }
write
map { [$_, substr $_, -3] }

Yes. The idea was to conceptually isolate
the substring finder.

Yup, and as such a canonical Schwartzian Transform.
* It may be used elsewhere, so there is one code to change.

* It may need ancillary information,
or be somewhat more complicated.

* How do we know that the interpreter is no slower
with the subroutine call than the inline code?

In particular as the calls to the subroutine are theta(N), and the
expected cost of a sort are omega(N). Such inlining can never be more
than a micro-optimisation.

Phil
 
M

Michael Press

Phil Carmody said:
Michael Press said:
James Waldby said:
On Sat, 28 May 2011 12:11:57 -0700, Michael Press wrote: ...
sub suffix( $ ){ substr $_[ 0 ], -3; }

print map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [$_, suffix($_)] }
qw ( alpha.bat gamma.exe beta.bat );

You'll have even fewer calls to the suffix sub if you delete
it, and in place of
map { [$_, suffix($_)] }
write
map { [$_, substr $_, -3] }

Yes. The idea was to conceptually isolate
the substring finder.

Yup, and as such a canonical Schwartzian Transform.

Which bears a striking resemblance to the celebrated X-macro.
In particular as the calls to the subroutine are theta(N), and the
expected cost of a sort are omega(N). Such inlining can never be more
than a micro-optimisation.

Ah, I missed that.
 
M

Malcolm McLean

Malcolm McLean's comment referred to how hard it is to write small scripts
in Perl.  I've pointed out that there are other scripting languages that
are used as embedded scripting languages and are much nicer to write small
scripts on.  No matter how much capable Perl's C API is than Python's, it
won't make writing perl scripts any simpler.
I've just written an NCBI sample text parser in C.

The format of the files is quite simple. You have a certain number of
tables, consisting of a header line giving "integer", "text",
"boolean", or "float" for each column, then a line giving the name of
the table, and the name of each column. Then you have data lines, tab
separated. The data, except the last table, is terminated by a line
containing an asterisk.
My C code to read that into a structure weighs in at about 400 lines,
including code to clean up if a memory allocation fails halfway
through reading one of the tables, and very simple parse error
handling.
I have to use MATLAB for most of my work, but MATLAB's text import
facilities, though very sophisticated, aren't flexible enough to
really handle the format.

I could have done it in Perl, but Perl isn't installed on my Windows
machine. I can get it, of course, but then it's got to be installed
and I've got to learn how to use it again. I think Perl is basically
the tool for this job, but I'm not installing it just so I can read a
few files.
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top