Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

feedback wanted on reasons for converting a java application using swing to Tcl/Tk and C

6 views
Skip to first unread message

Dan Fabrizio

unread,
May 22, 2002, 3:05:30 AM5/22/02
to
Hello All,

I would like to get opinions from all tcl gurus about this.

I have been working on a Java application (part time) for years. It is a
graphical
CAD type program for engineers. There are multiple type of drawings that are
made and displayed in a tabbed window. In Java I use an abstract class that
is
the parent for each type of drawing class so I don't have to duplicate the
common
functions between each drawing class. Can this be done in Tk?

One problem is that I would like to use the Graphics2D libraries to get some
more
advanced drawing functions but it is very slow on Linux and Unix machines.
I haven't looked at optimizing for performance which is something
I know I need to consider. I need line draw styles ( dashed, thickness )
and
filling of polygons with images, and publishing quality images and fonts.

Another problem is that Java is a memory hog. My application can eat up 20M
bytes
at times.

One other problem is that I need to convert the drawings into publishing
quality images
that can be cut/pasted into Windows apps and Unix apps. I have a 3rd party
EPS
image encoder but it only works with the Graphics library not the
Graphics2D.

The main reasons why I started with Java

1) With Tcl/Tk/C, I would need each platform (Solaris, Mac, HP, ...)
to compile the C parts.
2) Java class libraries looked more complete including printing
classes.

I would appreciate any feedback from Tcl/Tk gurus which would help me decide
whether
to convert this app from java to Tcl/Tk/C or any derivative of Tcl/Tk that
might be better.

Thanks in advance,
Dan

Cameron Laird

unread,
May 22, 2002, 12:12:52 PM5/22/02
to
In article <_qHG8.86076$e66.7...@bin6.nnrp.aus1.giganews.com>,
.
.
.
These are good questions, and ones on which you deserve help.

It might take several days before we're able to address them
all.

Are you able to find consistent JVM environments for your
Swing deployment on Solaris, MacOS, and HP-UX? That would
surprise me a bit. Myself, I find it easier to work with C
*and* Tcl/Tk across that combination, rather than Java. Per-
haps you're experiencing better results with Java.

Swing *is* a memory hog. And it just gets worse. One of
the classic folktales about Java is that it's a good
language for "enterprise-class" applications--the language
"scales" well. Myself, I have trouble saying this with a
straight face. Swing gets soooo clumsy, *particularly*
with large applications, that I find it almost unusable.
I'll say this more succinctly: I, also, find Swing a memory
hog, and it's quite discouraging in the way memory usage
continues to mount as you work to enrich and deepen your
application.

Some of the other frequent readers here (KBK?) have found
relatively more fulfillment with Swing.

I can understand your desire to exploit Java's advertised
Print capabilities. This is indeed an area in which Tcl/Tk
hasn't been a leader. Has Java met your requirements? I'm
quite out-of-date in familiarity with Java Print.
--

Cameron Laird <Cam...@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html

David Gravereaux

unread,
May 22, 2002, 12:48:06 PM5/22/02
to
cla...@starbase.neosoft.com (Cameron Laird) wrote:

>I'm
>quite out-of-date in familiarity with Java Print.

I'm slightly OT as usual, here.

I was at Borders book store last evening in Union City, CA. 2 and a half
racks worth of Java books and only one Tcl book I saw, but didn't dig
around further. It was "Mastering Perl/Tk" in the "web programming"
section of all things.

:(

But I did find the network programming book I was looking for and was
eyeing an assembly language book I hadn't seen. I'm convinced that the
only *real* technical book store in the world is one in the basement of
the Mcgraw-Hill headquarters in NYC on 6th Ave across from radio city
music hall.

And I've had it with HomeDepot, too :)

Ok, I'll stop...
--
David Gravereaux <davy...@pobox.com>
[species: human; planet: earth,milkyway,alpha sector]
Please be aware of the 7.5 year ping times when placing a call from alpha centari

Cameron Laird

unread,
May 22, 2002, 1:59:23 PM5/22/02
to
In article <kcgneushnn99fua67...@4ax.com>,
David Gravereaux <davy...@pobox.com> wrote:
.
.

.
>I was at Borders book store last evening in Union City, CA. 2 and a half
>racks worth of Java books and only one Tcl book I saw, but didn't dig
>around further. It was "Mastering Perl/Tk" in the "web programming"
>section of all things.
>
>:(
.
.
.
For those playing along at home, note that "Mastering Perl/Tk"
has to do with many things, (essentially--the exception isn't
worth arguing) none of which is "web programming". It's one
of the more frequent topics in comp.lang.perl.tk, by the way:
"I'm new to Web programming, so I'll ask you comp.lang.perl.tk
folks a question." "Go away."

Authors hate this stuff, too. One of the hardest parts about
being an author is going into book stores and seeing your book
on the wrong shelf. Drives us wild. Worse is not finding it
all all. Worst of all, though, is finding your baby--on the
remaindered shelf.

I can't figure out a better "Subject:" line.

Maurice Diamantini

unread,
May 22, 2002, 3:31:41 PM5/22/02
to
In article <_qHG8.86076$e66.7...@bin6.nnrp.aus1.giganews.com>,
"Dan Fabrizio" <dfabr...@comcast.net> wrote:

> I have been working on a Java application (part time) for years. It is a
> graphical
> CAD type program for engineers.


> There are multiple type of drawings that are
> made and displayed in a tabbed window. In Java I use an abstract class that
> is
> the parent for each type of drawing class so I don't have to duplicate the
> common
> functions between each drawing class. Can this be done in Tk?

(I let the question for others)


> The main reasons why I started with Java
>
> 1) With Tcl/Tk/C, I would need each platform (Solaris, Mac, HP, ...)
> to compile the C parts.
> 2) Java class libraries looked more complete including printing
> classes.

did you have tried jacl (tcl 100% in java)?
(I'm currently testing it, by I'm beginer in Java)

starting URL:
http://tcl.activestate.com/software/java/
(last version should be get from cvs)

Also there is Java SWT lib (Standard Windowing Toolkit) from the IBM
eclips project, which seems to
merge the avantages from swing (the design) and from AWT
(native implementation)
I've read that it could be compiled natively with gcj
I'd like to test it too:

URL:
http://www-106.ibm.com/developerworks/java/library/j-nativegui/?loc=dwman
http://www.eclipse.org


Imagine:
Langage Java + jacl + swt based Swank (= Tk onto Java)
+ GCJ for native compilation!
No more need for C++!


P.S.
I'm not realy a guru in any of theses langages,
but it's the dierction I'd like to go

Maurice Diamantini.

Mo

unread,
May 22, 2002, 4:10:34 PM5/22/02
to
Dan Fabrizio wrote:
>
> Hello All,
>
> I would like to get opinions from all tcl gurus about this.
>
> I have been working on a Java application (part time) for years.
> It is a graphical CAD type program for engineers. There are
> multiple type of drawings that are made and displayed in a
> tabbed window. In Java I use an abstract class that is
> the parent for each type of drawing class so I don't have to
> duplicate the common functions between each drawing class.
> Can this be done in Tk?

Yes, you could combine low level drawing functions implemented in C with Itcl
and get the same "OO style" that you are used to in Java. I am assuming that you
have some really complex drawing needs that will require a custom widget. If you
are doing really simple stuff, you might be able to get by just using the canvas
widget. As far as memory goes, a Tcl/Tk + some custom C is going to require far
less memory than a Swing based application.

...

> The main reasons why I started with Java
>
> 1) With Tcl/Tk/C, I would need each platform (Solaris, Mac, HP, ...)
> to compile the C parts.

This is not really the big deal it is made out to be. Tcl/Tk is already ported
to all of these systems. Yes, you will have to deal with compiling and testing
for these platforms. Java only get you past the compile problem, you still need
to spend huge amounts of time testing on each platform. If you think all Java
implementations are the same you are kidding yourself.

> 2) Java class libraries looked more complete including printing
> classes.

You might run into some printing issues with Tk. There is some postscript
support in core widgets like the canvas, but it is an area that will no doubt
need some work.

> I would appreciate any feedback from Tcl/Tk gurus which would help me decide
> whether to convert this app from java to Tcl/Tk/C or any derivative of
> Tcl/Tk that might be better.

A swing based application is going to be slow and it will suck up system memory
like there is no tomorrow. It might take you a little longer to get a Tk based
version going, but it will work.

cheers
Mo

Dan Fabrizio

unread,
May 22, 2002, 5:42:03 PM5/22/02
to
Hi Cameron,

Thanks for you feedback. I put some responses below.

"Cameron Laird" <cla...@starbase.neosoft.com> wrote in message
news:11A878370A1F6DF2.8AEB0449...@lp.airnews.net...

I know you can generate postscript files from the canvas drawings but how
does
Tk deal with ps fonts across the various platforms. What ps fonts come with
the
standared Tk canvas?

Yes, the printing options work for me. I'm working on this
feature currently.

With Tk, I would consider just printing the postscript images of the
canvas. Is there a way to encapsulated ps ???

Dan Fabrizio

unread,
May 22, 2002, 5:47:48 PM5/22/02
to
Hello Maurice,

I have added some responses below.

"Maurice Diamantini" <di...@mac.com> wrote in message
news:diam-ED93BB.2...@news.chello.fr...


> In article <_qHG8.86076$e66.7...@bin6.nnrp.aus1.giganews.com>,
> "Dan Fabrizio" <dfabr...@comcast.net> wrote:
>
>
>
> > I have been working on a Java application (part time) for years. It is a
> > graphical
> > CAD type program for engineers.
>
>
> > There are multiple type of drawings that are
> > made and displayed in a tabbed window. In Java I use an abstract class
that
> > is
> > the parent for each type of drawing class so I don't have to duplicate
the
> > common
> > functions between each drawing class. Can this be done in Tk?
>
> (I let the question for others)
>
>
> > The main reasons why I started with Java
> >
> > 1) With Tcl/Tk/C, I would need each platform (Solaris, Mac, HP,
...)
> > to compile the C parts.
> > 2) Java class libraries looked more complete including printing
> > classes.
>
> did you have tried jacl (tcl 100% in java)?
> (I'm currently testing it, by I'm beginer in Java)
>

I have looked at jacl, but I don't think it solves the problems I have
mentioned.
I still end up with a Swing app that is memory hog and runs slow on Linux
and Unix.

> starting URL:
> http://tcl.activestate.com/software/java/
> (last version should be get from cvs)
>
> Also there is Java SWT lib (Standard Windowing Toolkit) from the IBM
> eclips project, which seems to
> merge the avantages from swing (the design) and from AWT
> (native implementation)
> I've read that it could be compiled natively with gcj
> I'd like to test it too:
>

Yes, I read an article on IBMs developerworks website explaining how to
completely native applications using GCJ and SWT, but I don't think GCJ
supports Windows yet. This might be a way to go once this happens. I have to
look into SWT and see how much work it is to convert from a Swing app.

> URL:
> http://www-106.ibm.com/developerworks/java/library/j-nativegui/?loc=dwman
> http://www.eclipse.org
>
>
> Imagine:
> Langage Java + jacl + swt based Swank (= Tk onto Java)
> + GCJ for native compilation!
> No more need for C++!

>
> P.S.
> I'm not realy a guru in any of theses langages,
> but it's the dierction I'd like to go
>
> Maurice Diamantini.

Thanks for your feedback.
Dan


Dan Fabrizio

unread,
May 22, 2002, 6:00:41 PM5/22/02
to
> Yes, you could combine low level drawing functions implemented in C with
Itcl
> and get the same "OO style" that you are used to in Java. I am assuming
that you
> have some really complex drawing needs that will require a custom widget.
If you
> are doing really simple stuff, you might be able to get by just using the
canvas
> widget. As far as memory goes, a Tcl/Tk + some custom C is going to
require far
> less memory than a Swing based application.
>

> > The main reasons why I started with Java


> >
> > 1) With Tcl/Tk/C, I would need each platform (Solaris, Mac, HP,
...)
> > to compile the C parts.
>
> This is not really the big deal it is made out to be. Tcl/Tk is already
ported
> to all of these systems. Yes, you will have to deal with compiling and
testing
> for these platforms. Java only get you past the compile problem, you still
need
> to spend huge amounts of time testing on each platform. If you think all
Java
> implementations are the same you are kidding yourself.

Yes, I agree now but didn't realize that in the beginning.

> > 2) Java class libraries looked more complete including printing
> > classes.
>
> You might run into some printing issues with Tk. There is some postscript
> support in core widgets like the canvas, but it is an area that will no
doubt
> need some work.
>
> > I would appreciate any feedback from Tcl/Tk gurus which would help me
decide
> > whether to convert this app from java to Tcl/Tk/C or any derivative of
> > Tcl/Tk that might be better.
>
> A swing based application is going to be slow and it will suck up system
memory
> like there is no tomorrow. It might take you a little longer to get a Tk
based
> version going, but it will work.
>
> cheers
> Mo

I have conceded to the fact of compiling/debugging on each platform will be
needed.

My main concerns are:

publishing quality diagrams ( ps or eps images ) that can be
used in Windows and Unix with programs like Framemaker, Word,...
What ps fonts does Tk have for each platform. Do I need to install
fonts on
each platform??

cross-platform printing

I have found the Java Collections library to save a lot of time for
commonly
used data structures. ( hashtables, link lists, vectors, ... ) and nice
things like
built in sorting

Is there any equivalent or close substitute for Tcl/Tk/C??


Thanks for your feedback,
Dan


Michael Schlenker

unread,
May 22, 2002, 6:33:41 PM5/22/02
to
Dan Fabrizio wrote:
> I have conceded to the fact of compiling/debugging on each platform will be
> needed.
>
> My main concerns are:
>
> publishing quality diagrams ( ps or eps images ) that can be
> used in Windows and Unix with programs like Framemaker, Word,...
Word can use EPS in a decent way? Thats new..., mostly you only get the
bad tiff preview.

> What ps fonts does Tk have for each platform. Do I need to install
> fonts on each platform??

Does Java install postscript fonts?

This may shed some light into your question (read about side effects).
From "tk/generic/tkFont.c":
* Tk_PostscriptFontName --
*
* Given a Tk_Font, return the name of the corresponding Postscript
* font.
*
* Results:
* The return value is the pointsize of the given Tk_Font.
* The name of the Postscript font is appended to dsPtr.
*
* Side effects:
* If the font does not exist on the printer, the print job will
* fail at print time. Given a "reasonable" Postscript printer,
* the following Tk_Font font families should print correctly:
*
* Avant Garde, Arial, Bookman, Courier, Courier New, Geneva,
* Helvetica, Monaco, New Century Schoolbook, New York,
* Palatino, Symbol, Times, Times New Roman, Zapf Chancery,
* and Zapf Dingbats.
*
* Any other Tk_Font font families may not print correctly
* because the computed Postscript font name may be incorrect.

It is used by tk to determine the font to use for building ps from a
canvas..., so you may have a problem (other fonts can be added easy, if
you take a look at the source...)

> I have found the Java Collections library to save a lot of time for
> commonly
> used data structures. ( hashtables, link lists, vectors, ... ) and nice
> things like
> built in sorting

Hmm.
hashtables -> tcl arrays
vectors -> bltextension vectors
some other structures -> tcllib

Michael Schlenker

Dan Fabrizio

unread,
May 22, 2002, 8:37:05 PM5/22/02
to
> >
> > publishing quality diagrams ( ps or eps images ) that can be
> > used in Windows and Unix with programs like Framemaker, Word,...
> Word can use EPS in a decent way? Thats new..., mostly you only get the
> bad tiff preview.
>
> > What ps fonts does Tk have for each platform. Do I need to install
> > fonts on each platform??
> Does Java install postscript fonts?
>

I have the same concerns with Java. I just want to understand how
Tk deals with the fonts.

Good. This helps.

> > I have found the Java Collections library to save a lot of time for
> > commonly
> > used data structures. ( hashtables, link lists, vectors, ... ) and
nice
> > things like
> > built in sorting


> Hmm.
> hashtables -> tcl arrays
> vectors -> bltextension vectors
> some other structures -> tcllib
>

I was looking for similar data structure functions in C also.
My intentions are to put everything in C, except the GUI user interface.

I have been able to compile Tcl/Tk8.3.4 on Windows and Linux and have
started the conversion of java app. I don't have a lot of C background so
it take me a longer to get things working like link lists.

Currently, I'm working on this problem in C.

Given a variable number of names in a text file that are shown vertically
with
one character of each name in each line, how can I build up the names in a
structure like:
Inbetween each character is a space, and a period is used instead when the
names are
completed as shown below. The number of names and number of lines it takes
to build
the names varies. The number of lines is equal to the number of characters
in the largest
name.

struct name_list {
char name[128];
int name_index;
char *p1;
int length
}

The file might look like:

D J B G
a o i e
n h l o
. n l r
. . . g
. . . e
-----------

Thanks for your feedback. Any help with the C problems would be great.

Dan


lvi...@yahoo.com

unread,
May 23, 2002, 7:59:29 AM5/23/02
to

According to <lvi...@yahoo.com>:
:
:According to Dan Fabrizio <dfabr...@comcast.net>:
::My main concerns are:

::
:: publishing quality diagrams ( ps or eps images ) that can be
:: used in Windows and Unix with programs like Framemaker, Word,...
:: What ps fonts does Tk have for each platform. Do I need to install
::fonts on
:: each platform??
:
:I suspect that you are now venturing into some of the less traveled parts
:of Tcl/Tk. What do you mean by 'publishing ps or eps images that can be
:used in Windows and Unix? You want your application to create these files?
:The PS creation support in Tk may or may not be up to your needs. However,
:I don't think there is much support out there, yet, for eps creation.
:


P.S. The BLT extension (again, see
<URL: http://www.purl.org/NET/Tcl-FAQ/part5.html> for a pointer) has
the ability to display encapsulated postscript on a canvas...

--
Support Internet Radio <URL: http://saveinternetradio.org/ >
Join Tcl'2002 in Vancouver http://www.tcl.tk/community/tcl2002/
<URL: mailto:lvi...@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting

lvi...@yahoo.com

unread,
May 23, 2002, 7:56:45 AM5/23/02
to

According to Dan Fabrizio <dfabr...@comcast.net>:
:My main concerns are:

:
: publishing quality diagrams ( ps or eps images ) that can be
: used in Windows and Unix with programs like Framemaker, Word,...
: What ps fonts does Tk have for each platform. Do I need to install
:fonts on
: each platform??

I suspect that you are now venturing into some of the less traveled parts
of Tcl/Tk. What do you mean by 'publishing ps or eps images that can be


used in Windows and Unix? You want your application to create these files?
The PS creation support in Tk may or may not be up to your needs. However,
I don't think there is much support out there, yet, for eps creation.

Tk doesn't 'have' ps fonts. It's up to a system to provide its own
fonts and Tk will then use which ever fonts it finds installed.


: cross-platform printing

Tcl/Tk has no specific support for printing. For that matter, there
seems to be a range of functionality people think of when they think printing.
There are several extensions listed in
<URL: http://www.purl.org/NET/Tcl-FAQ/part5.html> relating to printing -
perhaps one of them will be of help. There may be other tools there to
help you as well.

: I have found the Java Collections library to save a lot of time for


:commonly
: used data structures. ( hashtables, link lists, vectors, ... ) and nice
:things like
: built in sorting
:
: Is there any equivalent or close substitute for Tcl/Tk/C??

:

Yes, there is a C++ extension called Containers that provides some common
data structures.

Donal K. Fellows

unread,
May 23, 2002, 8:20:43 AM5/23/02
to
Cameron Laird wrote:
> Swing *is* a memory hog. And it just gets worse. One of the classic
> folktales about Java is that it's a good language for "enterprise-class"
> applications--the language "scales" well. Myself, I have trouble saying
> this with a straight face. Swing gets soooo clumsy, *particularly* with
> large applications, that I find it almost unusable. I'll say this more
> succinctly: I, also, find Swing a memory hog, and it's quite discouraging
> in the way memory usage continues to mount as you work to enrich and
> deepen your application.

I've been programming in Java for quite a long time, and tinkering with Swing
for quite a bit less, but here are some observations.

Java *is* a memory hog. Provided you've got all your class structure sorted out
(and your task fits OO well enough) it isn't hard to use. Scaling well probably
only stems from the fact that you've got strictly-enforced memory protection.
Both the AWT and Swing suck; too often, if there's a way to do something that
would be useful (such as supporting multi-line labels by default, or having
LayoutManagers that come close to Doing the Right Thing by default) they don't
do it, but opt instead for the course of least effort. The overall API is *far*
too big; finding the best way to do something can be quite difficult. IMHO
"enterprise-class" must be referring to classes taught to people in
enterprises. But there is a significant number of uses where it beats C and C++
into a cocked hat (the memory protection again; it enables all sorts of
security-sensitive uses.)

Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
-- We shall, nevertheless, continue to dispense [insults] on the premise of
giving credit where credit is due, you ill-bred nanowit sack of bovine
fecal matter. -- Xelloss <jfos...@home.com>

Chang Li

unread,
May 23, 2002, 8:34:09 AM5/23/02
to
"Dan Fabrizio" <dfabr...@comcast.net> wrote in message news:<dyUG8.92121$e66.8...@bin6.nnrp.aus1.giganews.com>...

> I have found the Java Collections library to save a lot of time for
> commonly
> used data structures. ( hashtables, link lists, vectors, ... ) and nice
> things like
> built in sorting
>
> Is there any equivalent or close substitute for Tcl/Tk/C??

hashtable (array), list, string are buildin functions in Tcl.
They are native data structures in Tcl.

Chang

Eric Brunel

unread,
May 23, 2002, 10:47:39 AM5/23/02
to
lvi...@yahoo.com wrote:
> P.S. The BLT extension (again, see
> <URL: http://www.purl.org/NET/Tcl-FAQ/part5.html> for a pointer) has
> the ability to display encapsulated postscript on a canvas...


??? According to Tk manual pages (e.g.
http://dev.scriptics.com/man/tcl8.3/TkCmd/canvas.htm#M60 ), "The Postscript
is created in Encapsulated Postscript form using version 3.0 of the
Document Structuring Conventions". So the output of the postscript command
on canvases seems to be natively EPS. Or am I mistaken?
--
- Eric Brunel <eric....@pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Richard.Suchenwirth

unread,
May 23, 2002, 8:43:37 AM5/23/02
to
.. and lists alone can be used to model fancy "containers" like stacks,
queues, priority queues in less than a handful of Tcl code...

See http://mini.net/tcl/3333.tcl
--
Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703
Siemens Dematic AG, PA RC D2, Buecklestr.1-5, 78467 Konstanz,Germany
Personal opinions expressed only unless explicitly stated otherwise.

Donal K. Fellows

unread,
May 23, 2002, 9:02:18 AM5/23/02
to
Dan Fabrizio wrote:
>>> I have found the Java Collections library to save a lot of time for
>>> commonly used data structures. ( hashtables, link lists, vectors, ...)
>>> and nice things like built in sorting
>> Hmm.
>> hashtables -> tcl arrays
>> vectors -> bltextension vectors
>> some other structures -> tcllib

More accurately, much of what you might want from C/Java arrays and Java vectors
can be had through the use of Tcl lists. If you're using 8.4 (still in alpha,
but pretty good all the same) then you even have a tool to update (a variable
holding) a list in-place. And they come with useful operations like
sophisticated searching and sorting.

> I was looking for similar data structure functions in C also.

If you want hashes in C, just half-inch the hashing code out of Tcl. :^)

> My intentions are to put everything in C, except the GUI user interface.
>
> I have been able to compile Tcl/Tk8.3.4 on Windows and Linux and have
> started the conversion of java app. I don't have a lot of C background so
> it take me a longer to get things working like link lists.
>
> Currently, I'm working on this problem in C.

C is hard work. You will find yourself debugging memory usage, since it is
amazingly easy to write C that either releases memory too early (making the code
unstable), or doesn't release it at all (memory leak.) Trust me.

> Given a variable number of names in a text file that are shown vertically
> with one character of each name in each line, how can I build up the names
> in a structure like:
> Inbetween each character is a space, and a period is used instead when
> the names are completed as shown below. The number of names and number
> of lines it takes to build the names varies. The number of lines is equal
> to the number of characters in the largest name.

[...]

Firstly, in Tcl:

# Assume we're reading from a ready-opened file whose channel-name is $f

while {[gets $f line] >= 0} {
set i 0
foreach char [split $line] {
if {![string equal $char .]} {
append name($i) $char
}
incr i
}
}

Now, in C:

/* Assume a few limits for simplicity, as that lets us ignore memory
* management which would make this code much longer... */
char buffer[128], *line, name[64][128];
int len[64];

/* Zero-out some arrays; C doesn't do this by default */
memset(len, 0, sizeof(char)*64*128);
memset(len, 0, sizeof(int)*64);

/* Outer loop reads lines */
while ((line=fgets(buffer,127,f))!=null) {
int i = 0;

/* Inner loop scans the line into names */
do {
while (isspace(*line)) line++; /* Skip spaces */
if (!*line) break; /* Trailing whitespace? */
if (*line != '.') /* Periods are skipped */
name[i][len[i]++] = *line++; /* Add char to end of name */
i++; /* Ready for next name! */
} while (*line);
}

/* Real Programmers would mmap() the file and scan it once. */

In Java, you'd do something recognisably similar to the C version, but Java
zeroes out arrays for you and the StringBuffer class makes things easier too.
And it could handle unbounded numbers of names if you did that, like the Tcl
version and unlike the C version, but that's C for you...

Cameron Laird

unread,
May 23, 2002, 10:08:08 AM5/23/02
to
In article <3CECDE9B...@cs.man.ac.uk>,
.
.
.

>too big; finding the best way to do something can be quite difficult. IMHO
>"enterprise-class" must be referring to classes taught to people in
>enterprises. But there is a significant number of uses where it beats C and C++
>into a cocked hat (the memory protection again; it enables all sorts of
>security-sensitive uses.)
.
.
.
Acquaintances just related to me some of what passes for
"training" in Big, Serious Corporations. While I'd risk
exploding my own head if I repeated the details, I'll
summarize by saying that, yes, I have trouble being pro-
perly respectful when people try to tell me about
Mission-Critical and otherwise Important Applications On
A Scale Beyond Our Comprehension. A lot of it is in-
distinguishable from slapstick.

And what an embarrassment that memory protection problems
still characteristically plague C, or that our profession
is so retarded as to think that memory allocation is the
only significant security resource. We've known better
for at least a decade ...

Cameron Laird

unread,
May 23, 2002, 10:09:34 AM5/23/02
to
In article <3CEC1CC5...@uni-oldenburg.de>,
Michael Schlenker <sch...@uni-oldenburg.de> wrote:
.
.
.

>> I have found the Java Collections library to save a lot of time for
>> commonly
>> used data structures. ( hashtables, link lists, vectors, ... ) and nice
>> things like
>> built in sorting
>Hmm.
>hashtables -> tcl arrays
>vectors -> bltextension vectors
>some other structures -> tcllib
>
>Michael Schlenker
>

There are differences. The Tcl versions are easier
to use than their Java correspondents.

Cameron Laird

unread,
May 23, 2002, 10:13:34 AM5/23/02
to
In article <RQWG8.109283$fU2.10...@bin8.nnrp.aus1.giganews.com>,
Dan Fabrizio <dfabr...@comcast.net> wrote:
.
.
.

>I was looking for similar data structure functions in C also.
>My intentions are to put everything in C, except the GUI user interface.
>
>I have been able to compile Tcl/Tk8.3.4 on Windows and Linux and have
>started the conversion of java app. I don't have a lot of C background so
>it take me a longer to get things working like link lists.
>
>Currently, I'm working on this problem in C.
>
>Given a variable number of names in a text file that are shown vertically
>with
>one character of each name in each line, how can I build up the names in a
>structure like:
.
.
.

> Thanks for your feedback. Any help with the C problems would be great.
>
>Dan
>
>

Several of us have the experience that, in situations
like this, the best help is to say, "avoid use of C".
Tcl (for example) already encapsulates all this work.

I've lost track, I believe; why not do as much as pos-
sible in higher-level languages such as Java or Tcl?

Cameron Laird

unread,
May 23, 2002, 10:16:57 AM5/23/02
to
In article <acilj1$2fo$3...@srv38.cas.org>, <lvi...@yahoo.com> wrote:
.
.
.

>P.S. The BLT extension (again, see
><URL: http://www.purl.org/NET/Tcl-FAQ/part5.html> for a pointer) has
>the ability to display encapsulated postscript on a canvas...
.
.
.
There are other ways, too, if there should be some reason
not to use BLT. I don't know this area well. I do know
that a little research has, in the past, turned up several
plausible alternatives.

Bob Techentin

unread,
May 23, 2002, 10:16:20 AM5/23/02
to
Cameron Laird" <cla...@starbase.neosoft.com> wrote:
>
> Several of us have the experience that, in situations
> like this, the best help is to say, "avoid use of C".
> Tcl (for example) already encapsulates all this work.
>
> I've lost track, I believe; why not do as much as pos-
> sible in higher-level languages such as Java or Tcl?

Perhaps, Cameron, you are remembering this study from a couple of
years ago.

http://www.ipd.uka.de/~prechelt/Biblio/jccpprtTR.pdf

This also appeared in IEEE Computer as an article in Volume: 33 Issue:
10 , Oct. 2000. One of the primary conclusions of the study is that
scripting languages are more productive than C/C++/Java.

Bob
--
Bob Techentin techenti...@mayo.edu
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/


"> Personal: http://starbase.neosoft.com/~claird/home.html


David Kaasen

unread,
May 23, 2002, 2:47:51 PM5/23/02
to
Cameron Laird <cla...@starbase.neosoft.com> wrote:

...

: Several of us have the experience that, in situations


: like this, the best help is to say, "avoid use of C".
: Tcl (for example) already encapsulates all this work.
:
: I've lost track, I believe; why not do as much as pos-
: sible in higher-level languages such as Java or Tcl?

Would it be possible (and recommended) to use Tk as a
GUI for Java programs, probably by using the Jini
Java-to-C interface?

Regards, David Kaasen.

Cameron Laird

unread,
May 23, 2002, 3:40:52 PM5/23/02
to
In article <acjdgn$o27$2...@tyfon.itea.ntnu.no>,

Whoa! 'Think we've confused our keywords here. Jini
is about distributed computing (or Web services, or
computing spaces, or ...). I suspect you mean JNI.

And that's already been done for you! Yes, you can
write Tk GUIs, and load in Tcl Blend ('least, on a
good day, you can load Tk and Tcl Blend together),
and achieve exactly what I believe you have in mind
<URL: http://wiki.tcl.tk/tclblend >.

Dan Fabrizio

unread,
May 23, 2002, 4:30:28 PM5/23/02
to

"Donal K. Fellows" <fell...@cs.man.ac.uk> wrote in message

> More accurately, much of what you might want from C/Java arrays and Java
vectors
> can be had through the use of Tcl lists. If you're using 8.4 (still in
alpha,
> but pretty good all the same) then you even have a tool to update (a
variable
> holding) a list in-place. And they come with useful operations like
> sophisticated searching and sorting.
>

In feel there should be a data structure library for C. I agree it much
easier in
Tcl ( I haven't used 8.4), and maybe I'm wrong, but
searching/sorting/editing long lists
will be much faster in native code.

> If you want hashes in C, just half-inch the hashing code out of Tcl. :^)
>
> > My intentions are to put everything in C, except the GUI user interface.
> >
> > I have been able to compile Tcl/Tk8.3.4 on Windows and Linux and have
> > started the conversion of java app. I don't have a lot of C background
so
> > it take me a longer to get things working like link lists.
> >
> > Currently, I'm working on this problem in C.
>
> C is hard work. You will find yourself debugging memory usage, since it
is
> amazingly easy to write C that either releases memory too early (making
the code
> unstable), or doesn't release it at all (memory leak.) Trust me.
>

Yes. I agree and this might be a limiting factor in making the decision to
convert the
application.

Thanks for your code examples. They helped.

In C, what I did is a strcpy of the first character
into the name, then strcat the remaining characters ( one at a time ) into
name.
Before using strcpy, I used Tcl_Alloc(2). Before the strcat, i used
Tcl_Realloc( char_counter+1).
I stored char_counter in the structure.

This works but I'm not sure what the differences in performance would be in
your
version and mine.

Dan Fabrizio

unread,
May 23, 2002, 4:33:51 PM5/23/02
to

"Cameron Laird" <cla...@starbase.neosoft.com> wrote in message > Several of

us have the experience that, in situations
> like this, the best help is to say, "avoid use of C".
> Tcl (for example) already encapsulates all this work.
>
> I've lost track, I believe; why not do as much as pos-
> sible in higher-level languages such as Java or Tcl?

I'm having trouble deciding how much to use Tcl as compared to C. I do want
to use
C as much as possible for performance mainly and to hide the code. I know
you can
use TclPro to compile Tcl/Tk into bytecodes now but this wasn't an option
when I
first started the app.

Dan Fabrizio

unread,
May 23, 2002, 4:44:23 PM5/23/02
to

> >> I have found the Java Collections library to save a lot of time
for
> >> commonly
> >> used data structures. ( hashtables, link lists, vectors, ... ) and
nice
> >> things like
> >> built in sorting
> >Hmm.
> >hashtables -> tcl arrays
> >vectors -> bltextension vectors
> >some other structures -> tcllib
> >
> >Michael Schlenker
> >
>
> There are differences. The Tcl versions are easier
> to use than their Java correspondents.
> --

Has there ever been a thoughts about adding a Collections library to
the Tcl C library?


Bob Techentin

unread,
May 23, 2002, 5:25:43 PM5/23/02
to
"Dan Fabrizio" <dfabr...@comcast.net> wrote:
>
> I'm having trouble deciding how much to use Tcl as compared to C.
> I do want to use C as much as possible for performance mainly
> and to hide the code.

Common wisdom in this neck of the woods is to write as much of the
application as possible in Tcl, and then optimize only the slow bits
with C. You might be surprised how much performance you can get from
a script language.

As an example, I wrote a unit conversion package
(http://sf.net/projects/units/), prototyping the initial code in Tcl,
writing the test cases, then recoding the whole thing in C. I wasn't
after performance, specifically, but I wanted subroutines that could
be integrated into a SWIG'd interface. (http://www.swig.org/) It
turns out that the Tcl code was much easier to write, is half the
size, and just as fast as the C code.

Obfuscating your code is another matter.

Cameron Laird

unread,
May 23, 2002, 7:10:44 PM5/23/02
to
In article <acjmol$49a$1...@tribune.mayo.edu>,

Bob Techentin <techenti...@mayo.edu> wrote:
>"Dan Fabrizio" <dfabr...@comcast.net> wrote:
>>
>> I'm having trouble deciding how much to use Tcl as compared to C.
>> I do want to use C as much as possible for performance mainly
>> and to hide the code.
>
>Common wisdom in this neck of the woods is to write as much of the
>application as possible in Tcl, and then optimize only the slow bits
>with C. You might be surprised how much performance you can get from
Yes. Performance is not at all necessarily a reason to choose C.
.
.
.

>be integrated into a SWIG'd interface. (http://www.swig.org/) It
>turns out that the Tcl code was much easier to write, is half the
>size, and just as fast as the C code.
>
>Obfuscating your code is another matter.
.
.
.
I've been thinking it's time to write up a definitive
treatise on obfuscation of Tcl scripts. <URL: http://
wiki.tcl.tk/obfuscate > hints at the possibilities.

Cameron Laird

unread,
May 23, 2002, 7:15:20 PM5/23/02
to
In article <EjcH8.80730$th.79...@bin2.nnrp.aus1.giganews.com>,

Dan Fabrizio <dfabr...@comcast.net> wrote:
.
.
.
>In feel there should be a data structure library for C. I agree it much
>easier in
>Tcl ( I haven't used 8.4), and maybe I'm wrong, but
>searching/sorting/editing long lists
>will be much faster in native code.
Not necessarily. I know you think such a claim
is perfectly self-evident--but it's not. That's
part of why languages like Tcl have such devoted
followings.
.
.

.
>This works but I'm not sure what the differences in performance would be in
>your
>version and mine.
>
>
>

One of Tcl's wonderful characteristics is that
we so infrequently speculate about its perfor-
mance. That is, in comparison to C or Java,
it's soooooo much easier just to measure what
Tcl actually does (and even trace through its
source code, after the fact), rather than ex-
amine poultry entrails.

lvi...@yahoo.com

unread,
May 23, 2002, 11:59:00 PM5/23/02
to

According to Eric Brunel <eric....@pragmadev.com>:

:lvi...@yahoo.com wrote:
:> P.S. The BLT extension (again, see
:> <URL: http://www.purl.org/NET/Tcl-FAQ/part5.html> for a pointer) has
:> the ability to display encapsulated postscript on a canvas...
^^^^^^

:??? According to Tk manual pages (e.g.

:http://dev.scriptics.com/man/tcl8.3/TkCmd/canvas.htm#M60 ), "The Postscript
:is created in Encapsulated Postscript form using version 3.0 of the
:Document Structuring Conventions". So the output of the postscript command
:on canvases seems to be natively EPS. Or am I mistaken?

However, the output of the postscript command on canvases is not displayable
on the canvases without help. Why? Shrug.

Maurice DIAMANTINI

unread,
May 24, 2002, 3:00:42 AM5/24/02
to
On Wed, 22 May 2002 21:47:48 GMT, Dan Fabrizio <dfabr...@comcast.net> wrote:

>> Also there is Java SWT lib (Standard Windowing Toolkit) from the IBM
>> eclips project, which seems to
>> merge the avantages from swing (the design) and from AWT
>> (native implementation)
>> I've read that it could be compiled natively with gcj
>> I'd like to test it too:

>> URL:
>> http://www-106.ibm.com/developerworks/java/library/j-nativegui/?loc=dwman
>> http://www.eclipse.org
>
>Yes, I read an article on IBMs developerworks website explaining how to
>completely native applications using GCJ and SWT, but I don't think GCJ
>supports Windows yet. This might be a way to go once this happens. I have to
>look into SWT and see how much work it is to convert from a Swing app.
>

About gcj on windows, here is the status

Subject: Re: win32
From: Adam Megacz <g...@lists.megacz.com>
To: <ja...@gcc.gnu.org>
Date: 23 May 2002 14:33:50 -0700

gcj on cygwin is work in progress. It isn't supported in 3.1.
It passes most of the testsuite in 3.2, but it isn't ready yet.

There are promising reports for linux -> win32 cross-compliation
but it doesn't work OOTB yet.

About gcj on MacOSX, here is the status

Subject: Re: will be gcj (= gcc for java) available with gcc3.1?
From: Stan Shebs <sh...@apple.com>
Date: Fri, 17 May 2002 00:11:51 -0700
To: unix-p...@lists.apple.com, di...@mac.com

> So my questions are :
> - will be gcj available with the next gcc3.1 release from
> Apple?
> - if not, are there any orientation/decision related to
> the feature?

We're not currently planning to make it available. Mac OS X
already includes Sun's Java, so the expected clientele for gcj
is limited, and yours is only about the third request I've heard
in a year.

Even so, I've generally kept an eye on gcj, and try to make sure
that it builds at least. And who knows, if more people express
an interest, it could become a standard compiler on OS X.


So (as Terry Allen from Apple is in Copy) I feel great for
the mac that Apple support the open langages
tcl/tk/java/jacl/gcj (swt ?) This allow poeple to developp
powerfull multiplatform application into native executable.

I am going to work on an Optimisation progamm (graphs..) in
java/jacl instead of C++. This is only possible if I can
compile it to native application which gcj.
I have no need for graphic, only for a tcl console

The tcl console could be from Swank (tk onto jacl), or better
tkcon there is a solution to communicate between native
tcl interpreter and java/jacl virtual machine without using
tclblend.

This is currently possible only onto linux-intel platform
(if I can get jacl to be compile with gcj without to harmness).


>> Imagine:
>> Langage Java + jacl + swt based Swank (= Tk onto Java)
>> + GCJ for native compilation!
>> No more need for C++!

--
Maurice.D...@ensta.fr - ENSTA/LMA
École Nationale Supérieure de Techniques Avancées
Laboratoire de Mathématiques Appliquées
http://www.ensta.fr/~diam

Richard.Suchenwirth

unread,
May 24, 2002, 3:37:35 AM5/24/02
to
Cameron Laird wrote:
>
> In article <EjcH8.80730$th.79...@bin2.nnrp.aus1.giganews.com>,
> Dan Fabrizio <dfabr...@comcast.net> wrote:
> >I feel there should be a data structure library for C. I agree it much

> >easier in
> >Tcl ( I haven't used 8.4), and maybe I'm wrong, but
> >searching/sorting/editing long lists
> >will be much faster in native code.

> Not necessarily. I know you think such a claim
> is perfectly self-evident--but it's not. That's
> part of why languages like Tcl have such devoted
> followings.

..and by the way, searching (with [lsearch]), sorting (with [lsort])
and, since 8.4, editing in place (with [lset]) _are_ in native (C)
code...

Tcl is a rich multi-purpose C library with a mighty powerful
configuration language ;-)

Richard.Suchenwirth

unread,
May 24, 2002, 3:41:19 AM5/24/02
to
lvi...@yahoo.com wrote:
> However, the output of the postscript command on canvases is not displayable
> on the canvases without help. Why? Shrug.

That would require to include a Postscript (which is in fact another
programming language) rendering engine like ghostscript/ghostview, which
is a non-trivial undertaking and needs not be duplicated in Tcl.

Dan Fabrizio

unread,
May 24, 2002, 3:55:07 PM5/24/02
to
Conclusions:

I lost my newsgroup connection. I hope to get it back soon. I will
post this via google but it takes a long time to get posted.

What is you opinion about using itcl? I have converted a small
portion of the java code to itcl and it seems like a good solution
since its OO.

How about performace with itcl? Do you know of performance bottle
necks with itcl? I have many Java classes which would result in many
itcl clasess. Do you know if this will be a problem?

I'm coming to the conclusion that if I want to convert the application
to tcl, then use itcl, and C only for areas that need better
performance.

From the feedback received from everyone, it seems like tcl code runs
as fast as some C versions and of course is much easier to write and
debug.

Also, the Tk canvas does everything needed with line draws, styles,
widths, filled polygons and ps images.


Another test case: All C except the gui.

This version works on Linux but bombs out in Windows. I have
compiled
the Windows version using the make file ( makefile.vc ) but I
want to
set a VC++6.0 project so I can use the debugger.

I think I have all the included libraries set ok, but I need to
get the
link librarys set up.

Can anyone point me to help for this.

winMain.obj : error LNK2001: unresolved external symbol
__imp__Tcl_Eval
winMain.obj : error LNK2001: unresolved external symbol
__imp__Tcl_Alloc
winMain.obj : error LNK2001: unresolved external

symbol__imp__Tcl_GetStringFromObj


Thanks for all the feedback.
Dan

"Dan Fabrizio" <dfabr...@comcast.net> wrote in message news:<_qHG8.86076$e66.7...@bin6.nnrp.aus1.giganews.com>...
> Hello All,
>
> I would like to get opinions from all tcl gurus about this.
>
> I have been working on a Java application (part time) for years. It is a
> graphical
> CAD type program for engineers. There are multiple type of drawings that are
> made and displayed in a tabbed window. In Java I use an abstract class that
> is
> the parent for each type of drawing class so I don't have to duplicate the
> common
> functions between each drawing class. Can this be done in Tk?
>
> One problem is that I would like to use the Graphics2D libraries to get some
> more
> advanced drawing functions but it is very slow on Linux and Unix machines.
> I haven't looked at optimizing for performance which is something
> I know I need to consider. I need line draw styles ( dashed, thickness )
> and
> filling of polygons with images, and publishing quality images and fonts.
>
> Another problem is that Java is a memory hog. My application can eat up 20M
> bytes
> at times.
>
> One other problem is that I need to convert the drawings into publishing
> quality images
> that can be cut/pasted into Windows apps and Unix apps. I have a 3rd party
> EPS
> image encoder but it only works with the Graphics library not the
> Graphics2D.
>
> The main reasons why I started with Java
>
> 1) With Tcl/Tk/C, I would need each platform (Solaris, Mac, HP, ...)
> to compile the C parts.
> 2) Java class libraries looked more complete including printing
> classes.
>
> I would appreciate any feedback from Tcl/Tk gurus which would help me decide
> whether
> to convert this app from java to Tcl/Tk/C or any derivative of Tcl/Tk that
> might be better.
>
> Thanks in advance,
> Dan

Dan Smart

unread,
May 26, 2002, 1:42:03 AM5/26/02
to
cla...@starbase.neosoft.com (Cameron Laird) wrote in
news:4AC1DAA9E5958DAF.8B1EE511...@lp.airnews.net:

>>Common wisdom in this neck of the woods is to write as much of the
>>application as possible in Tcl, and then optimize only the slow bits
>>with C. You might be surprised how much performance you can get from
> Yes. Performance is not at all necessarily a reason to choose C.
Premature optimization is indeed the root of all evil. Well, that and
MFC...

> I've been thinking it's time to write up a definitive
> treatise on obfuscation of Tcl scripts. <URL: http://
> wiki.tcl.tk/obfuscate > hints at the possibilities.
I recommend 72 hours with no sleep, and a large vat of coffee. Naturally
obfuscated code.

Dan "7 days with woof no woof internet, but still woof sane" Smart

--
Dan Smart. C++ Programming and Mentoring.
cpp...@dansmart.com
ADDvantaged

Donal K. Fellows

unread,
May 27, 2002, 4:31:25 AM5/27/02
to
Cameron Laird wrote:
> And what an embarrassment that memory protection problems
> still characteristically plague C, or that our profession
> is so retarded as to think that memory allocation is the
> only significant security resource. We've known better
> for at least a decade ...

While I agree with what you say, I'd just like to point out that without memory
protection (mem-alloc is not the only facet of that) other forms of (in-process)
security are of relatively low value because Bad Code can always circumvent
them. Mem-protection makes it worthwhile tackling the other issues.

-- Thanks, but I only sleep with sentient lifeforms. Anything else is merely
a less sanitary form of masturbation.
-- Alistair J. R. Young <avatar...@arkane.demon.co.uk>

Donal K. Fellows

unread,
May 27, 2002, 5:06:22 AM5/27/02
to
Dan Fabrizio wrote:
> Thanks for your code examples. They helped.

You're welcome.

> In C, what I did is a strcpy of the first character into the name, then
> strcat the remaining characters ( one at a time ) into name. Before using
> strcpy, I used Tcl_Alloc(2). Before the strcat, i used

> Tcl_Realloc(char_counter+1). I stored char_counter in the structure.

If you know the length of the string, don't use strcpy or strcat as they scan
the string. In fact, strcat is linear in the length of the string being
appended to, giving you quadratic performance :^( as you repeatedly concatenate
characters onto the end. Writing the characters directly is far more efficient.

> This works but I'm not sure what the differences in performance would be in
> your version and mine.

In mine, each character is referenced exactly twice in user-level code; once in
fgets, and once in my scan loop (well, assuming a half-way decent optimising
compiler) and the resulting code is linear in the size of the data file being
read (i.e. if you double the size of the file, you double the time to read it
in.) If you're using strcat and reallocing before every alloc to increase the
size of the buffer by one, you're going to be quadratic (double the file size ->
four times the time) and with a much larger multiplier too. Compare with the
following which uses more tricks from the C coders' arsenal...

#define ALLOC_STEP 8
#define MAX_NAMES 64

char buffer[2*MAX_NAMES], *line, *name[MAX_NAMES];
int len[MAX_NAMES], alloc[MAX_NAMES], i, j;

/* Initialise our arrays */
for (i=0 ; i<MAX_NAMES ; i++) {
len[i] = 0;
alloc[i] = ALLOC_STEP;
name[i] = ckalloc(ALLOC_STEP);
}

/* Outer loop reads lines */

while ((line=fgets(buffer,2*MAX_NAMES-1,f))!=null) {
i = 0;

/* Inner loop scans the line into names */

while (1) {
register char c = *line++;
switch (c) {
case 0:
goto endinnerloop:
case ' ': case '\t':
continue;
default:
if (len[i]==alloc[i]) {
name[i] = ckrealloc(name[i], alloc[i] += ALLOC_STEP);
}
name[i][len[i]++] = c;
case '.':
i++;
}
}
endinnerloop:
}

/*
* Add NUL terminators; you need a loop here if all names are same length.
* Note that we also trim the memory allocated and remove unused names.
*/
for (j=0 ; j<i ; j++) {
/* Trim to length */
name[j] = ckrealloc(name[j], len[j]+1);
name[j][len[j]] = 0;
}
for (; j<MAX_NAMES ; j++) {
ckfree(name[j]);
}

(Handling arbitrary numbers of names is trickier; you need to pre-scan the first
line to work out the size of buffers you'll need, and either store the
characters you read in the process or fseek back to the start. Or use a more
elaborate I/O system, e.g. that provided by the Tcl library, which can read a
whole line of arbitrary length into a dynamically-growing buffer.)

Donal K. Fellows

unread,
May 27, 2002, 5:17:33 AM5/27/02
to
Dan Fabrizio wrote:
> Has there ever been a thoughts about adding a Collections library to
> the Tcl C library?

We have entities indexable by string and entities indexable by number. What
else do we need? Linked lists are overhyped for many uses (if you don't need a
lot of "insert-or-remove-not-at-end" operations, you don't need linked lists)
and trees tend to not be done with general collection systems in languages like
Java or C because the complexity of tree management is not often anything like
as significant as other factors (like the use-case-specific data or operations.)

There's no theoretical reason why we couldn't add more collections systems to
the Tcl C library, but a lot of people don't seem to feel the pressing need.

lvi...@yahoo.com

unread,
May 28, 2002, 2:51:57 PM5/28/02
to

According to Dan Fabrizio <dfabr...@comcast.net>:
:Has there ever been a thoughts about adding a Collections library to
:the Tcl C library?

There are thoughts of all sorts in this community <grin>. Some are
treated as sane ones, some as insane ones. But the bottom line tends to be
that until a worker bee finds the topic of enough interest to volunteer to
do the work, the ideas sit in sf.net feature request queues, wiki pages,
comp.lang.tcl wishful thinking postings, etc.

--
Support Internet Radio <URL: http://saveinternetradio.org/ >
Join Tcl'2002 in Vancouver http://www.tcl.tk/community/tcl2002/

Even if explicitly stated to the contrary, nothing in this posting

should be construed as representing my employer's opinions.

Don Porter

unread,
Jun 3, 2002, 10:07:05 AM6/3/02
to
Dan Fabrizio wrote:
>> Has there ever been a thoughts about adding a Collections library to
>> the Tcl C library?

Donal K. Fellows wrote:
> We have entities indexable by string and entities indexable by number. What
> else do we need?

At the 1998 Tcl Conference, George "BLT" Howlett gave a presentation
on "Data Objects for Tcl" that made a good case that a good set of
data objects could improve Tcl development quite a bit. Most notably,
Tk would be improved if some of its more complex widgets did not hold
large organizations of data themselves, but held references to that
data held by a more widely usable data object.

At last year's Tcl conference, Michael "[incr *]" McLennan referred
to the same idea, and cited is as evidence that "George Howlett is a
Programming God". McLennan extended the idea by noting that the
data objects ought to have events and callbacks, like variable traces
or events in Tk widgets, for effective combination in an event-driven
environment like Tcl.

> There's no theoretical reason why we couldn't add more collections systems to
> the Tcl C library, but a lot of people don't seem to feel the pressing need.

I don't think such data objects need to be in Tcl itself; an extension
could provide them easily enough. The "struct" package of tcllib gets
at the same idea. Perhaps it could be supplemented with CriTcl
extensions for performance?

--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

0 new messages