why should i use tcl?

From: Jan Tomka (judas_at_linux.sk)
Date: 03/07/04


Date: Sun, 07 Mar 2004 20:03:56 GMT

hello!

i must say, i don't know tcl, i only wrote several short scripts years
ago. recently, a need for event-driven scripting appeared in my job, so
i'd like to ask about tcl.

i agree this is quite vague (maybe even offtopic) post. please, bear
with me and try to answer my questions. thank you in advance.

  background
============
i've been working for some time on an embedded linux system whose job
was to monitor and control the energy consumption.

basicaly, the application (currently a c monolith) can be logically
divided into three subsystems:

  * in-core structure-based database

  * communication with various consumption measuring devices; the
retrieved values are stored in the database

  * several simple alhorithm implementations, like consumption prognose
calculation; results are used to determine whether some gadgets should
be turned on/off

  * tcp/ip server for odbc to connect and retrieve/update database
tables and records

  need for change
=================
i've been quite happy with the design till now, but some new possible
applications of the system came up recently, which raise the need of
splitting my monolith.

mainly the algorithm subsystem should be easily replaced depending on
application, while database and communication may be left common to all
applications.

this requirement makes the use of embeddable scripting language the best
choice, i think.

  new design
============
after searching the net, asking people and reading various software
design-related books, i came up with this solution:

  * berkeley db as a replacement for my in-core database; despite only
the bdb library is about 5-times bigger than my whole system now, i can
trade off this space for stability, transaction-awareness and
recoverability properties

  * modular plugin-based library responsible for handling individual
communication protocol implementations

  call for a language
=====================
the sripting language i'd like to use should fit some requirements.
because, once the database/communication framework is up and running, i
need to take some actions anytime the data recieved from, say,
electromer is writen to database. it could be new consumption prognose
calculated and its value in database updated.

in short, i need to script what is called a database trigger, while not
degradating my system's scripting abilities to database-related
operations only, as i would by using sql or such.

as i searched through various languages documentation, i found tcl's
event loop and commands like trace, vwait or fileevent along with its
embeddability very suitable for my needs.

but, as i said, i don't know tcl, so i'd like to get some questions
answered.

  questions
===========
  * do you think tcl is suitable for my needs? or is there any language
i should use instead?

  * how can i get a tcl procedure called anytime i change a row in a
table? i mean, i can provide a hook in my database layer for such event,
but it's not quite clear to me how do i pass it to a script. can someone
explain this to me, or even provide an example?

  * does libbdb_tcl provide some additional tcl/event-related
capabilities or is it just a raw tcl binding?

  * i've heard of virtual filesystem support in tcl. would it make sense
to utilize it and implement database the way e.g. subversion does? would
it make things easier using fileevent on files of such filesystem?

  * do you know anything closely resembling the system i'm going to
write, that i could take a look at or even use right away?

i appreciate all answers and advices making the stuff better before i
start writing it. thank you

        judas



Relevant Pages

  • Re: why did these companies choose Tcl over Python
    ... I used to work on a project which was written mostly in Tcl. ... which was written in Tcl (or, at least, has Mimic as its scripting ... I know you can extend/embed Python, but it's a LOT easier in Tcl. ... scripting language. ...
    (comp.lang.python)
  • Re: is tcl/tk dying out?!
    ... scripting level. ... Tcl, and it solves the problem most of the time. ... would make the language very attractive and more powerful is many ways. ... Python is even better as an example. ...
    (comp.lang.tcl)
  • Re: TCL vs. Perl
    ... "Tcl was never developed as a general-purpose scripting language, ... Perl than in Tcl. ...
    (comp.lang.tcl)
  • Re: Goodbye TCL
    ... > language for driving scriptable subsystems, and to be honest that is ... > is possible to write quite large software modules in Tcl, ... Because it is vastly more efficient in terms of programmer time to ... write the whole application in a scripting language, ...
    (comp.lang.tcl)
  • Re: TIP#308 Published: Tcl Database Connectivity (TDBC)
    ... Tcl's database access has for years been in a mild state of disarray. ... The trouble is not that Tcl can't talk to databases. ... "doesn't Tcl have anything like JDBC?" ... specifies a "connection string" to specify the database instance, ...
    (comp.lang.tcl)