Re: Obstacles for Tcl/Tk commercial application development ?



briang42@xxxxxxxxxxxxxx schrieb:

I disagree. The type-less nature of Tcl combined with event based
programs results is some bizarre bugs. Usually it can be traced to
poor program design, but not always. But simple typos are a big
problem as well and it's not easy to catch these. With C/C++, you
can't even get past the compile/link phase when you have a typo.

The static vs dynamic typing issue is discussed a lot... there are people who like it this or the other way.
I can say from experience in both, static and dynamic languages, that dynamic typing has /never/ been a problem in my programs. Whenever there was a problem (bug) in a Tcl program, it was not related to the type system and would have occurred in any static language as well - but eventually much worse.
And, "Simple typos" will come back to you as soon as you run your procedure the first time for testing.

Regarding other bug sources: Consider a procedure with an out parameter:

In Tcl:
proc fun {out} {
upvar $out lclOut
set lclOut ...
...
}

In C:
int fun (int *outPtr) {
*outPtr = ...
}

Called in Tcl:
fun out

Called in C:
int out;
fun(&out);

You do not know whether out is initialized with a meaningful value in both languages - static typing does not help here. out must be declared as int in C, but does not have to be initialized. It's better to initialize it (int out = 0), but so is in Tcl:
set out 0
fun out

You still don't know whether out has a good value after the call to fun, so you need to check afterwards. In Tcl you can do:
if {[info exists out]} {...} (if you haven't initialized it before). In C you must check the value somehow. Different typing paradigms, same problems.


- Eckhard
.



Relevant Pages

  • Re: Fibonacci via binrec combinator
    ... including 0 ms collecting ... (define (fun x) ... int main; ... struct rectangular; ...
    (comp.lang.scheme)
  • Re: questions
    ... will it default to int??? ... char fun() ... there is a sequence point after evaluation of the left operand. ... Since 'i' is non-zero, the right operand of the && expression must be evaluated, resulting in a recursive call to fun. ...
    (comp.lang.c)
  • Re: Somebody stop me
    ... > It wasn't just the typos, or even mostly the typos, but the whole ... > hands was the primary focus of fun; the typos just added the little ... Sumbuddy pleez hep me!!! ... Thanks for our affirmation, Dweeb:) ...
    (misc.invest.stocks)
  • Re: Best way to pass c++ pointer to tcl
    ... straightforward with simple types like int, long, etc., but I do not ... Creating and Using Tcl Handles in C Extensions: ... So my Ext_Init allocates a struct like: ... The performance with this method is superior to a hash table, ...
    (comp.lang.tcl)
  • history access via tcls C API?
    ... The access to the tcl command history is only possible by using tcl ... And the history command does not return normal tcl values, like lists, ... int Tcl_HistoryAddEventObj ...
    (comp.lang.tcl)