embedding tcl vs. perl 
Author Message
 embedding tcl vs. perl

I need to add cmd. set for CAD tool. I know PERL quite well, and have
embedded it into an earlier tool (the embedding part was easy, the
harder
part was providing a new set of interfaces to make my c++ code be
useable
from perl). In any case, this time around, I would like to investigate
whether TCL would do the job better. I read Ousterhout's original
paper
on TCL, and the embedding process described in there *seems* cleaner
than the ones described in the perl books (both programming perl, and
adv. perl
programming). I would appreciate any insights into this, or any
pointers
to docs. on the web that discuss pros/cons of embedding tcl vs. perl.

The users of the tool do not care much for the cmd. set syntax, other
than
it be programmable via simple for/if type constructs.

thanks



Thu, 23 Sep 2004 15:06:09 GMT  
 embedding tcl vs. perl

Quote:

> I need to add cmd. set for CAD tool. I know PERL quite well, and have
> embedded it into an earlier tool (the embedding part was easy, the
> harder
> part was providing a new set of interfaces to make my c++ code be
> useable
> from perl). In any case, this time around, I would like to investigate
> whether TCL would do the job better. I read Ousterhout's original
> paper
> on TCL, and the embedding process described in there *seems* cleaner
> than the ones described in the perl books (both programming perl, and
> adv. perl
> programming). I would appreciate any insights into this, or any
> pointers
> to docs. on the web that discuss pros/cons of embedding tcl vs. perl.

 From my experience it is far easier to embed tcl than perl, but I'm not
very familiar with perl. Just tried to embed perl once and found it just
too complex to like it (in contrast to tcl embedding).

Some docs about tcl embedding can be found at:
http://mini.net/tcl/2074.html
http://mini.net/tcl/1819.html

Worth a look would be the book by Brent B. Welch,
http://www.beedub.com/book/3rd/

Man pages you should read:
http://tmml.sourceforge.net/doc/tcl/Tcl_Main.html
http://tmml.sourceforge.net/doc/tcl/FindExec.html
http://tmml.sourceforge.net/doc/tcl/CrtInterp.html
and some more...

Perhaps you should take a look at SWIG:
http://swig.sourceforge.net/

Some general comments on tcl vs. perl:
http://www.tcl.tk/advocacy/perl.html

Michael Schlenker



Thu, 23 Sep 2004 22:19:10 GMT  
 embedding tcl vs. perl
Thanks for the pointers. Looks like the most relevant chapters (for my
needs atleast) from Welch's book are online. Also, the TCL advocacy
document says
that TCL was designed from the ground up to be extended (via c/c++),
and
embedded (in c/c++). This might be true, but one thing I have noticed
is that more users
seem to be familiar/comfortable with perl than tcl, and given an
option of
tcl vs. perl as the cmd. language they would prefer the latter. This
is
not the case for me currently, but seems to be true generally. i.e.
the
perl user community is probably an order of magnitude larger than tcl.

Personally, I would have preferred emacs lisp, since this is the env.
I am
most familiar with, but it has the baggage of the entire emcas, and
not
many people care about lisp programming these days. I know there are
guile/scheme variants that can be embedded, but the learning curve for
a
lisp-like env. is pretty high for end users, relative to perl, tcl (in
that order).

Finally, apologies for the bad grammar in my first line. I mean to
write
`I need to add *a* cmd. set for *a* CAD tool'.

thanks

Quote:


> > I need to add cmd. set for CAD tool. I know PERL quite well, and have
> > embedded it into an earlier tool (the embedding part was easy, the
> > harder
> > part was providing a new set of interfaces to make my c++ code be
> > useable
> > from perl). In any case, this time around, I would like to investigate
> > whether TCL would do the job better. I read Ousterhout's original
> > paper
> > on TCL, and the embedding process described in there *seems* cleaner
> > than the ones described in the perl books (both programming perl, and
> > adv. perl
> > programming). I would appreciate any insights into this, or any
> > pointers
> > to docs. on the web that discuss pros/cons of embedding tcl vs. perl.

>  From my experience it is far easier to embed tcl than perl, but I'm not
> very familiar with perl. Just tried to embed perl once and found it just
> too complex to like it (in contrast to tcl embedding).

> Some docs about tcl embedding can be found at:
> http://mini.net/tcl/2074.html
> http://mini.net/tcl/1819.html

> Worth a look would be the book by Brent B. Welch,
> http://www.beedub.com/book/3rd/

> Man pages you should read:
> http://tmml.sourceforge.net/doc/tcl/Tcl_Main.html
> http://tmml.sourceforge.net/doc/tcl/FindExec.html
> http://tmml.sourceforge.net/doc/tcl/CrtInterp.html
> and some more...

> Perhaps you should take a look at SWIG:
> http://swig.sourceforge.net/

> Some general comments on tcl vs. perl:
> http://www.tcl.tk/advocacy/perl.html

> Michael Schlenker



Fri, 24 Sep 2004 01:58:05 GMT  
 embedding tcl vs. perl

Quote:

> perl user community is probably an order of magnitude larger than tcl.

I wonder if this is true even when you start counting embedded Tcl
programmers, such as people using CAD programs, Vignette, Scopus, and so
on...

--
Darren New
San Diego, CA, USA (PST). Cryptokeys on demand.
      Remember, drive defensively if you drink.



Fri, 24 Sep 2004 04:50:15 GMT  
 embedding tcl vs. perl

Quote:

>I need to add cmd. set for CAD tool. I know PERL quite well, and have
>embedded it into an earlier tool (the embedding part was easy, the
>harder
>part was providing a new set of interfaces to make my c++ code be
>useable
>from perl). In any case, this time around, I would like to investigate
>whether TCL would do the job better. I read Ousterhout's original
>paper
>on TCL, and the embedding process described in there *seems* cleaner
>than the ones described in the perl books (both programming perl, and
>adv. perl
>programming). I would appreciate any insights into this, or any
>pointers
>to docs. on the web that discuss pros/cons of embedding tcl vs. perl.

>The users of the tool do not care much for the cmd. set syntax, other
>than
>it be programmable via simple for/if type constructs.

>thanks

An alternate to SWIG when you want more of a DIY approach hooking into C++

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tomasoft/cpptcl/TclAda...

A simple example of its use would look like this:

#include "TclAdapter.hpp"

class MyExtension : protected Tcl::Adapter<MyExtension>
{
public:
    MyExtension(Tcl_Interp *interp) : Tcl::Adapter<MyExtension>(interp)
    {
        NewTclCmd(interp, "test", TestCmd);
    }
    ~MyExtension() {}
    virtual void DoCleanup() {}
private:
    int TestCmd (int objc, struct Tcl_Obj * CONST objv[])
    {
        Tcl_SetObjResult(interp, Tcl_NewStringObj("testing 1.. 2.. 3..", -1));
        return TCL_OK;
    }

Quote:
};

// tell the EXTERN macro we want to declare functions for export.
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT

EXTERN int
Myext_Init (Tcl_Interp *interp)
{
#ifdef USE_TCL_STUBS
    if (Tcl_InitStubs(interp, "8.1", 0) == 0L) {
        return TCL_ERROR;
    }
#endif
    new MyExtension(interp);
    Tcl_PkgProvide(interp, "myExt", "1.0");
    return TCL_OK;

Quote:
}

But that is just an extension, and is one half of embedding.  One question I ask
myself when looking at an application to embed Tcl into, is what model am I
going for?  Do I want a persistent interp for the application's lifetime and do
job as events, or a macro style where it's a fire and die approach.

Macro style isn't that hard.

once init: Tcl_FindExecutable
each run: Tcl_CreateInterp,Tcl_Init,Myext_Init,Tcl_Eval[File],Tcl_DeleteInterp
at exit: Tcl_Finalize

Persistent, I think, is more fun (yet complicated) and allows the use of Tk.
Mixing the Tcl event loop in an existing GUI application can be tricky, but not

http://prdownloads.sourceforge.net/tomasoft/tes-1.4.zip
--

[species: human; planet: earth,milkyway,alpha sector]
Please be aware of the 7.5 year ping times when placing a call from alpha centari



Fri, 24 Sep 2004 07:33:49 GMT  
 embedding tcl vs. perl

Quote:

> This might be true, but one thing I have noticed is that more users
> seem to be familiar/comfortable with perl than tcl, and given an
> option of tcl vs. perl as the cmd. language they would prefer the
> latter. This is not the case for me currently, but seems to be true
> generally. i.e.  the perl user community is probably an order of
> magnitude larger than tcl.

Sure, Perl is popular, but then again, it's ceding a lot of users to
Python, which is the latest 'big thing' in scripting languages,
although there are 'newcomers' like Ruby which are really starting to
get some critical mass.

Basically, Tcl has a nice, clean efficient syntax that will allow your
users to cleanly do things with it, as well as understand their
colleagues' code.  It is good, solid code, and will stand the test of
time.

--
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/



Fri, 24 Sep 2004 08:04:26 GMT  
 embedding tcl vs. perl

Quote:

> Thanks for the pointers. Looks like the most relevant chapters (for my
> needs atleast) from Welch's book are online. Also, the TCL advocacy
> document says that TCL was designed from the ground up to be extended
> (via c/c++), and embedded (in c/c++).

See also LUA, which is designed to be a hyper-cut-down language, and which
almost has to be extended and/or embedded to do anything substantial.

Quote:
> This might be true, but one thing I have noticed is that more users
> seem to be familiar/comfortable with perl than tcl, and given an
> option of tcl vs. perl as the cmd. language they would prefer the
> latter. This is not the case for me currently, but seems to be true
> generally. i.e. the perl user community is probably an order of
> magnitude larger than tcl.

That really depends on where you look.  Tcl's really well established for some
tasks, Perl for others, and I'm sure we can find niches for virtually any other
scripting language we can name.  Since none of us are going away (well, I'm not
yet bored of Tcl, and while I'm interested I can guarantee it won't disappear
completely) this must be diversity and hence A Good Thing.

Donal.
--

make: *** No rule to make target `war'.  Stop.



Fri, 24 Sep 2004 18:53:08 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. embedding tcl vs. perl

2. Crash when running perl-Tk from embedded Tcl

3. Q: perl vs Tcl: complementary, orthogonal or competition?

4. Q: perl vs Tcl: complementary, orthogonal

5. perl vs tcl (was Re: New version of C-like interpreter available)

6. tcl vs. perl

7. tcl vs. perl

8. perl vs tcl

9. Expect/TCL vs Perl

10. System Administration - Perl vs Tcl.

11. Perl and-or-vs TCL

12. TCL Speed vs PERL

 

 
Powered by phpBB® Forum Software