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

Discussion in 'C Programming' started by lovecreatesbeauty, May 20, 2011.

  1. 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?
    lovecreatesbeauty, May 20, 2011
    #1
    1. Advertising

  2. lovecreatesbeauty

    Tom St Denis Guest

    On May 20, 3:50 am, lovecreatesbeauty <>
    wrote:
    > 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
    Tom St Denis, May 20, 2011
    #2
    1. Advertising

  3. lovecreatesbeauty <> writes:

    > 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?

    --
    Ben.
    Ben Bacarisse, May 20, 2011
    #3
  4. On May 20, 2:36 pm, Ben Bacarisse <> wrote:
    >
    > 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.
    Malcolm McLean, May 20, 2011
    #4
  5. Malcolm McLean <> writes:

    > On May 20, 2:36 pm, Ben Bacarisse <> wrote:
    >>
    >> 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.


    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.

    --
    Ben.
    Ben Bacarisse, May 20, 2011
    #5
  6. lovecreatesbeauty

    Rui Maciel Guest

    Malcolm McLean wrote:

    > 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
    Rui Maciel, May 20, 2011
    #6
  7. lovecreatesbeauty

    Rui Maciel Guest

    lovecreatesbeauty wrote:

    > 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
    Rui Maciel, May 20, 2011
    #7
  8. lovecreatesbeauty

    Stefan Ram Guest

    Malcolm McLean <> writes:
    >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.
    Stefan Ram, May 20, 2011
    #8
  9. On May 20, 9:19 am, Rui Maciel <> wrote:
    > lovecreatesbeauty wrote:
    > > 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?


    No. I just became days agao a reader of Mr Bellard's site: bellard.org
    lovecreatesbeauty, May 20, 2011
    #9
  10. Rui Maciel <> writes:

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

    <snip>

    > ... 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".

    --
    Ben.
    Ben Bacarisse, May 20, 2011
    #10
  11. lovecreatesbeauty

    Rui Maciel Guest

    Ben Bacarisse wrote:

    > 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
    Rui Maciel, May 21, 2011
    #11
  12. lovecreatesbeauty

    Rui Maciel Guest

    William Ahern wrote:

    > 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
    Rui Maciel, May 21, 2011
    #12
  13. Rui Maciel <> writes:

    > Ben Bacarisse wrote:
    >
    >> 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.


    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.

    --
    Ben.
    Ben Bacarisse, May 21, 2011
    #13
  14. lovecreatesbeauty

    Nobody Guest

    On Fri, 20 May 2011 13:41:29 -0700, William Ahern wrote:

    > 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.
    Nobody, May 21, 2011
    #14
  15. In article <-berlin.de>,
    -berlin.de (Stefan Ram) wrote:

    > Malcolm McLean <> writes:
    > >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 );

    --
    Michael Press
    Michael Press, May 28, 2011
    #15
  16. lovecreatesbeauty

    James Waldby Guest

    On Sat, 28 May 2011 12:11:57 -0700, Michael Press wrote:

    > In article <-berlin.de>,
    > -berlin.de (Stefan Ram) wrote:
    >
    >> Malcolm McLean <> writes:
    >> >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] }

    --
    jiw
    James Waldby, May 29, 2011
    #16
  17. In article <irs5j8$oer$>,
    James Waldby <> wrote:

    > On Sat, 28 May 2011 12:11:57 -0700, Michael Press wrote:
    >
    > > In article <-berlin.de>,
    > > -berlin.de (Stefan Ram) wrote:
    > >
    > >> Malcolm McLean <> writes:
    > >> >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?

    --
    Michael Press
    Michael Press, May 29, 2011
    #17
  18. lovecreatesbeauty

    Phil Carmody Guest

    Michael Press <> writes:
    > In article <irs5j8$oer$>,
    > James Waldby <> wrote:
    >
    > > 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.

    > * 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
    --
    "At least you know where you are with Microsoft."
    "True. I just wish I'd brought a paddle." -- Matthew Vernon
    Phil Carmody, Jun 14, 2011
    #18
  19. In article <>,
    Phil Carmody <> wrote:

    > Michael Press <> writes:
    > > In article <irs5j8$oer$>,
    > > James Waldby <> wrote:
    > >
    > > > 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.

    > > * 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.


    Ah, I missed that.

    --
    Michael Press
    Michael Press, Jun 19, 2011
    #19
  20. On May 21, 3:42 am, Rui Maciel <> wrote:
    >
    > 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.
    Malcolm McLean, Jun 19, 2011
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jsnX

    What is .tcc?

    jsnX, Apr 5, 2005, in forum: C++
    Replies:
    1
    Views:
    880
    Malte Starostik
    Apr 5, 2005
  2. Replies:
    3
    Views:
    309
    Jack Klein
    Apr 19, 2006
  3. Replies:
    1
    Views:
    1,650
    Ian Collins
    Aug 4, 2008
  4. lovecreatesbeauty

    Web programming in C lang with TCC

    lovecreatesbeauty, Jun 16, 2011, in forum: C Programming
    Replies:
    79
    Views:
    2,019
  5. Malcolm McLean

    Tcc won't link libraries.

    Malcolm McLean, Jun 18, 2011, in forum: C Programming
    Replies:
    3
    Views:
    658
    Shao Miller
    Jun 19, 2011
Loading...

Share This Page