f



Are Tcl and Tk "inseparable"?

Hi,

I am a Ruby user and probably I will have to use Tk in order to get
nice GUIs. Now, the problem is that: Learning a new language (Ruby) is
already time consuming enough. Do I have to learn also Tcl in order to
use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with
Ruby, I mean)

Thanks in advance.

0
1/9/2006 12:39:11 PM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

30 Replies
807 Views

Similar Articles

[PageSpeed] 22

Surgeon schrieb:
> Hi,
> 
> I am a Ruby user and probably I will have to use Tk in order to get
> nice GUIs. Now, the problem is that: Learning a new language (Ruby) is
> already time consuming enough. Do I have to learn also Tcl in order to
> use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with
> Ruby, I mean)

The Perl community ripped Tcl from their PerlTk package, but it was just
slower, less up to date and more memory hungry. So in principle one
could separate Tk from Tcl, but its not worth it.

But your question goes in a different direction:
The Ruby/Tk binding wraps Tk into a set of Ruby Objects, so you are
using Ruby when you create Ruby/Tk programs. So you do not need to learn
Tcl to be able to use RubyTk, but it could help in translating advanced
Tk examples found on the Tcl'ers wiki (http://wiki.tcl.tk).
But you have to learn the options and functions of your libraries, as
you have to do for any other package.

Michael
0
schlenk (1615)
1/9/2006 2:40:43 PM
 Surgeon <biyokuantum@gmail.com> wrote:
> Hi, 
 > I am a Ruby user and probably I will have to use Tk in order
> to get nice GUIs. Now, the problem is that: Learning a new
> language (Ruby) is already time consuming enough. Do I have
> to learn also Tcl in order to use Tk? Can't I use Tk alone?
> (Umm, well, not so alone, together with Ruby, I mean) 
> Thanks in advance. 

It is definitely possible to separate Tk from Tcl.
There is Perl-Tk which don't use tcl interpreter to do callbacks and
such things - everything is rewritten on Perl. As far as I know, once
there was Scheme-Tk which was done same way. 

Python people are more lazy - they just compile Tcl interpeter into
Python interpreter and call result Tkinter. It has obvois benefit that
it allows one to use Tcl/Tk extensions in Python/Tkinter. But typically
one don't need to know Tcl in order to use Python/Tkinter. Everything
can be done on Python, unless you want to do some very clever things,
such as incorporate some Tcl-based extension.

I don't know how Ruby bindings for Tk looks like, but in any case if
such bindings exists, you can use Tk from Ruby without using any other
language than Ruby. At least for simple things.

-- 
It's documented in The Book, somewhere...
             -- Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>
0
vitus
1/9/2006 3:58:25 PM
"Surgeon" <biyokuantum@gmail.com> wrote in message
news:1136810351.264377.204260@o13g2000cwo.googlegroups.com...
> Hi,
>
> I am a Ruby user and probably I will have to use Tk in order to get
> nice GUIs. Now, the problem is that: Learning a new language (Ruby) is
> already time consuming enough. Do I have to learn also Tcl in order to
> use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with
> Ruby, I mean)

Why waste time learning Ruby, Python, Perl, etc. when you can do everything
easier, faster, and more reliably in Tcl?


0
1/9/2006 5:44:15 PM
Earl Grieda wrote:
> "Surgeon" <biyokuantum@gmail.com> wrote in message
> news:1136810351.264377.204260@o13g2000cwo.googlegroups.com...
> > Hi,
> >
> > I am a Ruby user and probably I will have to use Tk in order to get
> > nice GUIs. Now, the problem is that: Learning a new language (Ruby) is
> > already time consuming enough. Do I have to learn also Tcl in order to
> > use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with
> > Ruby, I mean)
>
> Why waste time learning Ruby, Python, Perl, etc. when you can do everything
> easier, faster, and more reliably in Tcl?

My god man! Do you want to start a war!  lol

Robert

0
sigzero (1319)
1/9/2006 5:47:41 PM
Earl Grieda wrote:
> "Surgeon" <biyokuantum@gmail.com> wrote in message
> news:1136810351.264377.204260@o13g2000cwo.googlegroups.com...
> 
>>Hi,
>>
>>I am a Ruby user and probably I will have to use Tk in order to get
>>nice GUIs. Now, the problem is that: Learning a new language (Ruby) is
>>already time consuming enough. Do I have to learn also Tcl in order to
>>use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with
>>Ruby, I mean)
> 
> 
> Why waste time learning Ruby, Python, Perl, etc. when you can do everything
> easier, faster, and more reliably in Tcl?

The original poster already knows Ruby. If they already know a language 
that works for them there's no real reason to learn Tcl (*)

Except in this case, since the original poster has to use Tk. As others 
have pointed out, other languages have bindings for Tk but it probably 
helps to know a little Tcl, too. At least enough to be able to read the 
Tk man pages.

As for doing things in Tcl "faster, easier and more reliable", that's 
rather debatable but we'll let those other newsgroups sort it out. 
Language wars are so '90s.

(*) except to become a better programmer :-)
0
oakley (2074)
1/9/2006 5:59:55 PM
Earl Grieda wrote:
> "Surgeon" <biyokuantum@gmail.com> wrote in message
> news:1136810351.264377.204260@o13g2000cwo.googlegroups.com...
> 
>>Hi,
>>
>>I am a Ruby user and probably I will have to use Tk in order to get
>>nice GUIs. Now, the problem is that: Learning a new language (Ruby) is
>>already time consuming enough. Do I have to learn also Tcl in order to
>>use Tk? Can't I use Tk alone? (Umm, well, not so alone, together with
>>Ruby, I mean)
> 
> 
> Why waste time learning Ruby, Python, Perl, etc. when you can do everything
> easier, faster, and more reliably in Tcl?

Knowing multiple languages tends to make for a better 
programmer/analysts/whatever.

No as to which one to use in any give situation ...
0
Gerald.Lester (2014)
1/9/2006 6:14:44 PM
> Why waste time learning Ruby, Python, Perl, etc. when you can do everything easier, faster, and more reliably in Tcl?

As a matter of fact, I heard Tcl so many times but I never tried it.

My area of interest is artificial intelligence. I tried C++, Java,
Prolog and Lisp. You know C++ and Java so no need to mention them
again. Prolog was a total culture shock. Lisp was good but I got tired
with thos parantheses and prefix notion.

Finally I decided to try Python and very liked it. As you can guess, I
thought "that's enough, I don't want to try another language, now I
must concentrate on my main domain".

One day, a Ruby user told me that "try Ruby a weekend and make your
decision". I did this half-heartedly. But when I saw Ruby I said
"That's it!".

Python is clean, Ruby is cleaner.
Studying Python is enjoyable, studying Ruby is more enjoyable.
Python is good, Ruby is better, IMHO.

But I am not a Tcl enemy ;-D because I don't know anything about it. I
love Ruby, that's all.

0
1/9/2006 7:05:55 PM
TCL is ideal for Artificial Intelligence:

set iq 200
set brain [createneurons $iq]
set answer [askanyquestion "who's your daddy?"]

:)


"Surgeon" <biyokuantum@gmail.com> wrote in message 
news:1136833555.698297.29690@g44g2000cwa.googlegroups.com...
>> Why waste time learning Ruby, Python, Perl, etc. when you can do 
>> everything easier, faster, and more reliably in Tcl?
>
> As a matter of fact, I heard Tcl so many times but I never tried it.
>
> My area of interest is artificial intelligence. I tried C++, Java,
> Prolog and Lisp. You know C++ and Java so no need to mention them
> again. Prolog was a total culture shock. Lisp was good but I got tired
> with thos parantheses and prefix notion.
>
> Finally I decided to try Python and very liked it. As you can guess, I
> thought "that's enough, I don't want to try another language, now I
> must concentrate on my main domain".
>
> One day, a Ruby user told me that "try Ruby a weekend and make your
> decision". I did this half-heartedly. But when I saw Ruby I said
> "That's it!".
>
> Python is clean, Ruby is cleaner.
> Studying Python is enjoyable, studying Ruby is more enjoyable.
> Python is good, Ruby is better, IMHO.
>
> But I am not a Tcl enemy ;-D because I don't know anything about it. I
> love Ruby, that's all.
> 


0
no672 (255)
1/9/2006 11:09:28 PM
Surgeon wrote:
> One day, a Ruby user told me that "try Ruby a weekend and make your
> decision". I did this half-heartedly. But when I saw Ruby I said
> "That's it!".
> 
> Python is clean, Ruby is cleaner.
> Studying Python is enjoyable, studying Ruby is more enjoyable.
> Python is good, Ruby is better, IMHO.
> 
> But I am not a Tcl enemy ;-D because I don't know anything about it. I
> love Ruby, that's all.

The truth is that if you find something you *really* like, you should
stick with it. Programming's hard enough without doing it in a language
that doesn't suit.

Though you should probably try the different major paradigms out at some
point. If you know what C, Scheme, Lisp, Haskell and Prolog (plus your
favourite scripting language of course) are like and why they aren't
universal solutions, you'll be a much better programmer than if you
haven't tried them. This is because having seen all those different ways
of doing things changes how you think about writing code, making you
better able to see different ways of doing stuff.

And it's fun too. ;-)

Donal.
0
1/9/2006 11:17:00 PM
Surgeon wrote:
> 
> My area of interest is artificial intelligence. I tried C++, Java,
> Prolog and Lisp. You know C++ and Java so no need to mention them
> again. Prolog was a total culture shock. Lisp was good but I got tired
> with thos parantheses and prefix notion.

AIs my area too. Prolog and Lisp are both widely used, and good 
languages. Prolog is a culture shock, but one which is well worth going 
through.

If you don't like prefix notation, then Tcl probably isn't for you as it 
too is prefix. Less parentheses, though, and a few bits of sugar over Lisp.

Things I tend to look for in languages for AI work are that they be 
multi-paradigm (i.e. allowing you to code in functional, OO, rule-based 
etc ways) and that they provide some means to extend the language with 
new syntactic constructs, e.g. via macros or higher-order functions or 
some other means (Tcl's basic procs are very flexible). Generally these 
are features I look for in a language for *any* work.

> One day, a Ruby user told me that "try Ruby a weekend and make your
> decision". I did this half-heartedly. But when I saw Ruby I said
> "That's it!".

Glad you've found a language you like. Ruby is quite a nice language. I 
like the notation for blocks/lambdas (as in Smalltalk).

Other languages you might like to look at:

Mercury (http://www.cs.mu.oz.au/research/mercury/): Basically a much 
updated Prolog.

Oz (http://www.mozart-oz.org/): A new language with lots of interesting 
features. It is a distant descendant of Prolog in that it uses 
assign-once logic variables, and can do back-tracking search etc. Based 
on constraint programming, and with cool ideas on concurrency etc. (The 
book "Concepts, Techniques, and Models of Computer Programming" by the 
Oz people is a great book.

Haskell (http://www.haskell.org/): Probably has the most language 
research buzz around it. A pure (no side-effects) non-strict functional 
language. This is another culture shock worth going through. Encourages 
equational reasoning.

If you like Haskell and Oz, then you might also be interested in Alice 
ML (http://www.ps.uni-sb.de/alice/) which is a strict functional 
language (based on Standard ML, another major language family) but with 
several of the features from Oz added.

-- Neil
0
nem3909 (1000)
1/10/2006 7:28:09 AM
Neil Madden wrote:
> Haskell (http://www.haskell.org/): Probably has the most language 
> research buzz around it. A pure (no side-effects) non-strict functional 
> language. This is another culture shock worth going through. Encourages 
> equational reasoning.

Oh, Haskell has side effects, but you've got to encapsulate them within
the right monad. The reason I recommend looking at it is that it is a
(largely) lazy programming language, in that it only computes a value
when it actually needs it. Makes it very natural to think in terms of
infinite data structures, which is quite different to just about any
other programming language most people have tried, where infinite stuff
is to be avoided like the plague.

Donal.
0
1/10/2006 9:54:23 AM
Donal K. Fellows wrote:
> Neil Madden wrote:
> 
>> Haskell (http://www.haskell.org/): Probably has the most language 
>> research buzz around it. A pure (no side-effects) non-strict 
>> functional language. This is another culture shock worth going 
>> through. Encourages equational reasoning.
> 
> 
> Oh, Haskell has side effects, but you've got to encapsulate them within
> the right monad.

Well, that depends on your point of view. With monads you actually build 
a sequence of actions (i.e. an imperative program) in a side-effect free 
way. This sequence of actions is the returned as the result of the 
program and executed. e.g. in the code:

main = do
         line <- getLine
         putStrLn line

the monadic "do" block creates an abstract operation (of type "IO ()") 
that will perform an action (getting a line from stdin and then echoing 
back to stdout) and returns this as the result of "main". So in Haskell 
itself there are no side-effects, but instead you write a program that 
builds a program that does use side-effects. This is related to 
laziness, as the actions returned are unevaluated and (for the IO monad 
at least) there is no way to "force" the actions to get their value.

> The reason I recommend looking at it is that it is a
> (largely) lazy programming language, in that it only computes a value
> when it actually needs it. Makes it very natural to think in terms of
> infinite data structures, which is quite different to just about any
> other programming language most people have tried, where infinite stuff
> is to be avoided like the plague.

Yeah, laziness is well worth experiencing. SICP explains [1] quite well 
the difference between lazy and strict evaluation by showing the 
possible design choices when writing an interpreter. Haskell is actually 
non-strict (or call-by-need) rather than lazy (call-by-name) as it only 
ever evaluates expressions once -- the result is "memoized" to avoid 
recomputing it in future. Tcl supports a form of call-by-name laziness 
via {} which allows the caller to package up an unevaluated expression 
and pass it to a procedure unevaluated (useful for conditionals and 
other custom control structures).

Simon Peyton Jones (one of Haskell's creators) has called laziness a 
"hair-shirt" [2] that can be a pain, but keeps Haskell pure (laziness 
and side-effects really don't mix well). Oz and Alice ML are strict by 
default, but have support for optional laziness, e.g. (in Alice ML):

- fun lazy enumFrom n = n :: enumFrom (n+1);
val enumFrom : int -> int list = _fn
- val nats = enumFrom 1;
val nats : int list = _lazy
- List.take (nats, 10);
val it : int list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- nats;
val it : int list = 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: 10 :: _lazy

Alice is a really nice language. Laziness there is done via "futures" 
which are also used for concurrency [3] and are one of the coolest new 
language design features I've heard about for a while.

[1] http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-27.html#%_sec_4.2
(see also 
http://www.swiss.ai.mit.edu/classes/6.001/abelson-sussman-lectures/ for 
video lectures, but that site is forever bogged down serving GB-size 
video files...)
[2] 
http://research.microsoft.com/Users/simonpj/papers/haskell-retrospective/
[3] http://www.ps.uni-sb.de/alice/manual/futures.html

-- Neil (rambling again!)
0
nem3909 (1000)
1/10/2006 5:57:53 PM
Neil Madden wrote:

> Simon Peyton Jones (one of Haskell's creators) has called laziness a
> "hair-shirt" [2] that can be a pain, but keeps Haskell pure (laziness
> and side-effects really don't mix well). Oz and Alice ML are strict by
> default, but have support for optional laziness, e.g. (in Alice ML):

I had the opportunity to meet that guy at a conference, and while
Haskell isn't my cup of tea, he was a great speaker, interesting to talk
to, and a nice, approachable person as well.  Highly recommended, in
other words.

-- 
David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/
0
davidw (997)
1/10/2006 10:19:40 PM
On Mon, 09 Jan 2006 17:44:15 GMT, "Earl Grieda"
<eASQWERTgrieda@VADFWEFyahoo.comical> wrote:

>Why waste time learning Ruby, Python, Perl, etc. when you can do everything
>easier, faster, and more reliably in Tcl?

ordinarily i'd agree with you. except for the 'easier, faster, and
more reilably' part when it comes to threading.

i find doing everything with threading in ruby easier, faster  and
more reliable then hte rest of the languages.

the main reason i use tcl/tk is that there's no quicker way to write a
gui app.

if tk syntax could be used in ruby, i would have no wishlist :)
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
0
snowzone5 (252)
2/15/2006 6:43:17 PM
In message <n7t6v19k6tf4hbjpgmeof7pqjee2odk22l@4ax.com>, tony summerfelt 
<snowzone5@hotmail.com> writes
>On Mon, 09 Jan 2006 17:44:15 GMT, "Earl Grieda"
><eASQWERTgrieda@VADFWEFyahoo.comical> wrote:
>
>>Why waste time learning Ruby, Python, Perl, etc. when you can do everything
>>easier, faster, and more reliably in Tcl?
>
>ordinarily i'd agree with you. except for the 'easier, faster, and
>more reilably' part when it comes to threading.
>
>i find doing everything with threading in ruby easier, faster  and
>more reliable then hte rest of the languages.
>
>the main reason i use tcl/tk is that there's no quicker way to write a
>gui app.
>
>if tk syntax could be used in ruby, i would have no wishlist :)
>http://home.cogeco.ca/~tsummerfelt1
>telnet://ventedspleen.dyndns.org

But why do you _need_ threading?

-- 
Eric Junkermann
0
eric154 (81)
2/15/2006 7:20:18 PM
tony summerfelt wrote:
> On Mon, 09 Jan 2006 17:44:15 GMT, "Earl Grieda"
> <eASQWERTgrieda@VADFWEFyahoo.comical> wrote:
> 
>> Why waste time learning Ruby, Python, Perl, etc. when you can do everything
>> easier, faster, and more reliably in Tcl?
> 
> ordinarily i'd agree with you. except for the 'easier, faster, and
> more reilably' part when it comes to threading.
> 
> i find doing everything with threading in ruby easier, faster  and
> more reliable then hte rest of the languages.
> 
> the main reason i use tcl/tk is that there's no quicker way to write a
> gui app.
> 
> if tk syntax could be used in ruby, i would have no wishlist :)

Well, you have Ruby/Tk, but as to threading ... what's wrong
with what Tcl/Tk provides?  Having used several other languages
threading, I find Tcl's to be very nice.  In fact, I converted
a Ruby/Tk user over to Tcl/Tk based on threading simplicity the
last time I went on a query to learn more about Ruby/Tk's
internals (which was not my intention, but an interesting side
effect).  Furthermore, Tcl gives you true native OS threads
(very scalable), not user level threads.

-- 
   Jeff Hobbs, The Tcl Guy
   http://www.ActiveState.com/, a division of Sophos
0
jeffh (1291)
2/17/2006 6:20:19 AM
Eric Junkermann wrote:

> But why do you _need_ threading?

E.g. for non-blocking GUI-apps...
But - Tcl's threading model is quite ok for that (well, I don't know of
Ruby's).


Eckhard

0
ecky-l (428)
2/17/2006 10:35:03 PM
Eric Junkermann wrote:
> But why do you _need_ threading?

When you're interfacing to something that blocks and you don't want to 
block. E.g., accessing a database via a library that blocks, and you 
want to serve multiple connections at once.

-- 
   Darren New / San Diego, CA, USA (PST)
     Is it OK to be obsessive-compulsive
     as long as you're not disordered?
0
dnew (1159)
2/17/2006 11:13:13 PM
On 17 Feb 2006 14:35:03 -0800, "Eckhard Lehmann" <ecky-l@web.de>
wrote:


>Eric Junkermann wrote:

>> But why do you _need_ threading?

two loops which have nothing to do with each other, use different
resources, but must execute before the rest of the code does. makes
sense to put both in a seperate thread.

i often have to iterate over large log files with more than one
operation performd  on different lines. while they COULD be in one
loop, it doesn't make sense or  readability later on. 
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
0
snowzone5 (252)
2/18/2006 7:32:46 PM
tony summerfelt wrote:
> On 17 Feb 2006 14:35:03 -0800, "Eckhard Lehmann" <ecky-l@web.de>
> wrote:
> 
> 
> 
>>Eric Junkermann wrote:
> 
> 
>>>But why do you _need_ threading?
> 
> 
> two loops which have nothing to do with each other, use different
> resources, but must execute before the rest of the code does. makes
> sense to put both in a seperate thread.
> 
> i often have to iterate over large log files with more than one
> operation performd  on different lines. while they COULD be in one
> loop, it doesn't make sense or  readability later on. 
> http://home.cogeco.ca/~tsummerfelt1
> telnet://ventedspleen.dyndns.org

What about fileevent, trace .. all that event stuff?
http://wiki.tcl.tk/1904

uwe
0
2/18/2006 8:14:55 PM
tony summerfelt wrote:
> On 17 Feb 2006 14:35:03 -0800, "Eckhard Lehmann" <ecky-l@web.de>
> wrote:
> 
> 
> 
>>Eric Junkermann wrote:
> 
> 
>>>But why do you _need_ threading?
> 
> 
> two loops which have nothing to do with each other, use different
> resources, but must execute before the rest of the code does. makes
> sense to put both in a seperate thread.
> 
> i often have to iterate over large log files with more than one
> operation performd  on different lines. while they COULD be in one
> loop, it doesn't make sense or  readability later on. 
> http://home.cogeco.ca/~tsummerfelt1
> telnet://ventedspleen.dyndns.org

If that's all you're doing, it's relatively easy to do without threads.

Do what you're comfortable with, of course, but realize that threads are 
rarely needed with Tcl/Tk, even for apps which have to process data from 
several sources "simultaneously".


-- 
Bryan Oakley
http://www.tclscripting.com
0
oakley (2074)
2/18/2006 9:56:27 PM
I just noticed your "tclscripting" sig. I visited it. Very cool and
informative.

Robert

0
sigzero (1319)
2/18/2006 11:36:33 PM
Robert Hicks wrote:
> I just noticed your "tclscripting" sig. I visited it. Very cool and
> informative.

Thank you.

-- 
Bryan Oakley
http://www.tclscripting.com
0
oakley (2074)
2/19/2006 12:08:34 AM
tony summerfelt wrote:
> On 17 Feb 2006 14:35:03 -0800, "Eckhard Lehmann" <ecky-l@web.de>
> wrote:
> 
> 
> 
>>Eric Junkermann wrote:
> 
> 
>>>But why do you _need_ threading?
> 
> 
> two loops which have nothing to do with each other, use different
> resources, but must execute before the rest of the code does. makes
> sense to put both in a seperate thread.
> 
> i often have to iterate over large log files with more than one
> operation performd  on different lines. while they COULD be in one
> loop, it doesn't make sense or  readability later on. 

You do realize, unless you are on a multiprocessor system and the log files 
are on different spindles (maybe even on different I/O channels), you may as 
well process one file then the other -- threads here only give a false sense 
of parallelism.

Before going to threading, one really needs to analyze, at the hardware 
level, what can and can not be done in parallel.
0
Gerald.Lester (2014)
2/19/2006 3:23:54 AM
On Sat, 18 Feb 2006 21:14:55 +0100, Uwe Klein
<uwe_klein_habertwedt@t-online.de> wrote:


>What about fileevent, trace .. all that event stuff?
>http://wiki.tcl.tk/1904

not nearly as much fun :)

that link seemed to lean towards operstions  that would affect each
other...i was referring to looping operations that needed to be
performed but had nothing to do with each other...

http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
0
snowzone5 (252)
2/19/2006 9:07:53 PM
On Sat, 18 Feb 2006 21:56:27 GMT, Bryan Oakley
<oakley@bardo.clearlight.com> wrote:


>If that's all you're doing, it's relatively easy to do without threads.

that was just an example. sometimes i'm not working with files at all,
just a large hash that i need to extract information from for
different purposes.

>Do what you're comfortable with, of course, but realize that threads are 
>rarely needed with Tcl/Tk, even for apps which have to process data from 
>several sources "simultaneously".

after reading: http://wiki.tcl.tk/880

fileevent doesn't sound safe enough compared to using threads with
mutex's
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
0
snowzone5 (252)
2/19/2006 9:18:10 PM
On Sat, 18 Feb 2006 21:23:54 -0600, "Gerald W. Lester"
<Gerald.Lester@cox.net> wrote:

>You do realize, unless you are on a multiprocessor system and the log files 
>are on different spindles (maybe even on different I/O channels), you may as 
>well process one file then the other -- threads here only give a false sense 
>of parallelism.

>Before going to threading, one really needs to analyze, at the hardware 
>level, what can and can not be done in parallel.

is that with tcl/tk?

i have a project in ruby that uses threading. separate methods each
taking various amounts of time. running them one at a time gives me a
total time of about 15 seconds.

running each in it's own thread they finish around the 5 second mark
(ie. time of the longest thread). this is on an xp box with a single
cpu.

i realize that it's only a savings of 10 seconds :) but that starts to
add up if you run it several dozen times...
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
0
snowzone5 (252)
2/19/2006 9:26:45 PM
tony summerfelt wrote:
> On Sat, 18 Feb 2006 21:23:54 -0600, "Gerald W. Lester"
> <Gerald.Lester@cox.net> wrote:
> 
>> You do realize, unless you are on a multiprocessor system and the log files 
>> are on different spindles (maybe even on different I/O channels), you may as 
>> well process one file then the other -- threads here only give a false sense 
>> of parallelism.
> 
>> Before going to threading, one really needs to analyze, at the hardware 
>> level, what can and can not be done in parallel.
> 
> is that with tcl/tk?

No it is with anything, please read the detailed remarks below.

> i have a project in ruby that uses threading. separate methods each
> taking various amounts of time. running them one at a time gives me a
> total time of about 15 seconds.
> 
> running each in it's own thread they finish around the 5 second mark
> (ie. time of the longest thread). this is on an xp box with a single
> cpu.
> 
> i realize that it's only a savings of 10 seconds :) but that starts to
> add up if you run it several dozen times...

If you are not running on a multiprocessor system and your log files are on 
the same disk and you are not accessing resources remote to your machine, 
then I really don't see where the time reduction can be coming from.  Of 
course if part of your processing involves doing things like a lookup of an 
IP address from a name (or the reverse) then you are waiting on remote 
resources (the DNS servers) and using either threads or event driven 
programming can reduce the clock time to process everything.

A single processor only processes one instruction at a time, the disk can 
only be transferring one block at a time -- and most systems implement read 
ahead caching so that the next data block is ready for you before you need it.
0
Gerald.Lester (2014)
2/19/2006 10:10:40 PM
tony summerfelt wrote:
> fileevent doesn't sound safe enough compared to using threads with
> mutex's

What do you think is unsafe? No fileevent is going to run while another 
fileevent is running, unless you ask explicitly for that behavior (by 
invoking "update"). Fileevents are *far* safer than threads and mutexes 
in a more traditional language. (Threads are pretty darn safe in Tcl, 
too. Not sure why you'd even need a mutex in Tcl's implementation of 
threads. I certainly never did.)

-- 
   Darren New / San Diego, CA, USA (PST)
     Is it OK to be obsessive-compulsive
     as long as you're not disordered?
0
dnew (1159)
2/19/2006 11:08:50 PM
On Sun, 19 Feb 2006 16:10:40 -0600, "Gerald W. Lester"
<Gerald.Lester@cox.net> wrote:

>If you are not running on a multiprocessor system and your log files are on 
>the same disk and you are not accessing resources remote to your machine, 

sometimes they're  on the same drive, sometimes not.

>A single processor only processes one instruction at a time, 

when i was taking a cs course in college back in the '80's that was
one of the first things we learned. which is/was  important when
you're designing microprocessor based circuits...

>only be transferring one block at a time -- and most systems implement read 
>ahead caching so that the next data block is ready for you before you need it.

entire log files are  read in to hashes, various operations performed
on the hashes, results written out to several places. in the middle of
any of those operations the log files  get's written to, needs to re-
read again. ad nauseum...

having the various operations (which have nothing to do with reading
the log files once they are in a hash) as performed  procedurally just
slows down the whole program. on top of that it doesn't do the job the
client asked for, but that's beside the point.

it shouldn't make any difference on a single cpu, but it does.

if nothing else threading lets me write code that makes more sense for
operations that should be happening at the "'same time".

other than that i don't know what to tell you :)
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
0
snowzone5 (252)
2/21/2006 1:50:46 PM
Reply:

Similar Artilces:

Looking for binary "expect" and "TCL/Tk" (if required) for OpenServer6
Does anybody know where to find "expect" (and related requirements) for OpenServer6? I can download the source files from nist.gov, but they do not compile. The MAN pages are already loaded on the system, so I suspect the programs would be on the distribution media somewhere. Any help would be appreciated. Thanks, Rick On 9 Feb, 17:57, Rick_Hoyle <motosl...@hotmail.com> wrote: > Does anybody know where to find "expect" (and related requirements) > for OpenServer6? I can download the source files from nist.gov, but > they do not compile. The MAN pages are al...

"Sayonara Tcl/Tk"
It seems that someone is really upset about Tcl/Tk. http://forum.sqlitestudio.pl/viewtopic.php?f=16&t=333 Στις 29/4/2013 11:49, ο/η saxo3800@gmail.com έγραψε: > It seems that someone is really upset about Tcl/Tk. > > http://forum.sqlitestudio.pl/viewtopic.php?f=16&t=333 > I think that he has a point regarding threads. George On Apr 29, 11:02=C2=A0am, Georgios Petasis <peta...@iit.demokritos.gr> wrote: > =CE=A3=CF=84=CE=B9=CF=82 29/4/2013 11:49, =CE=BF/=CE=B7 saxo3...@gmail.co= m =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > > > It seems that someone is really upset about Tcl/Tk. > > >http://forum.sqlitestudio.pl/viewtopic.php?f=3D16&t=3D333 > > I think that he has a point regarding threads. Sure. Though I'm curious to know what specific problem of his is so much better served by explicit locks and shared vars than by message passing, given the context. It's not as if he was worried by lost nanoseconds in mutex contention. -Alex Στις 29/4/2013 20:07, ο/η Alexandre Ferrieux έγραψε: > On Apr 29, 11:02 am, Georgios Petasis <peta...@iit.demokritos.gr> > wrote: >> Στις 29/4/2013 11:49, ο/η saxo3...@gmail.com έγραψε: >> >>> It seems that someone is really upset about Tcl/Tk. >> >>> http://forum.sqlitestudio.pl/viewtopic.php?f=16&t=333 >> >> I think that he has a point regarding threads. > > Sure. Though I'...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

"Multithreaded" tcl/tk problem?
Hello In short: I ran into serious problems when developing multithreded Tcl/ Tk application in C. After spending (literally!) weeks on debugging and tests, I believe that it narrows down to Tcl/Tk bugs in multithread mode. I tried to find something over net on such problems, but to no success :-( I'll be very grateful if someone could confirm that, or perhaps point out what I'm doing wrong...here's detailed description: I have Win32 C++ application (SCADA/HMI program) which may contain several (from zero to literally hundreths) independent Tcl/Tk "modules". Module is my own term here, and it boils down to separate thread, with it's own tcl interpreter. I also create a "container window" in module's thread, and initialize Tk in this interpreter (via Tk_Init) so that "container window" becomes parent window for this Tk's instance "main window" (this is done via setting global "argv" variable to "-use container_id"). After initialization, thread load script from file into interpreter and enters fairly standard event loop, processing both windows messages and Tcl events. Some of messages (defined by RegisterWindowsMessage) are used to carry commands from other threads - when I receive such message I call some Tcl function in interpreter, by usual Tcl_Eval( "functionName" ) call. This code in turn does some Tcl work, like setting GUI up, displaying information for the user, sometimes i...

"prompt" dialog for Tcl/Tk
Hey folks, I noticed Tk has some handy default modal dialogs: tk_messageBox, tk_chooseDirectory, tk_openFile, and so on. One particular form of dialog I would like to find - but don't know if it exists - is a "prompt" dialog similar to a browser's native "prompt" dialog for JavaScript, which pops up a modal dialog with a label, a single text entry field, and "OK" and "Cancel" buttons, and returns the string value of its entry field when the user clicks "OK" (or null if the user clicks "Cancel"). Since browser makers have seen fit to include this as a core native widget for the browser, I'd be surprised if Tk didn't have something similar (before I go off & try building one on my own). Thanks, David On May 10, 12:41=A0pm, David Golightly <davig...@gmail.com> wrote: > Hey folks, > > I noticed Tk has some handy default modal dialogs: tk_messageBox, > tk_chooseDirectory, tk_openFile, and so on. =A0One particular form of > dialog I would like to find - but don't know if it exists - is a > "prompt" dialog similar to a browser's native "prompt" dialog for > JavaScript, which pops up a modal dialog with a label, a single text > entry field, and "OK" and "Cancel" buttons, and returns the string > value of its entry field when the user clicks "OK" (or null if the > user clicks "Cancel"). =A0Since br...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

How to do PHP "require()" or TCL "source" in bash script
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Does it need a ";" at the very after of "if" and "for"
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if statement? marsarden said: > write code like: > > int main(void) > { > int a=10; > if(a<20) > {} > } > > Compiler ok on dev-cpp . don't we have to add a ";" after if > statement? The syntax for 'if' is: if(expression) statement There is no semicolon after the ) but before the statement. The statement is either a normal statement (which can be empty), ending in a semicolon:- if(expr) ...

"No installer way" to distribute tcl/tk?
Hi, I am writing a small app for the team as a utility. I uses Lisp and tcl/tk bindings. I have ActiveState tcl/tk 8.4 installed on my machine. Is there any way to distribute my app without having to install ActiveState package on every user machine? I am wondering if there is "minimum" way to distribute the necessary tcl/tk components (wish.exe, etc.). I mean just what dlls and exe should I put in my lisp app folder? Thanks! Andrew In article <1119284301.062794.27820@z14g2000cwz.googlegroups.com>, <astebakov@yahoo.com> wrote: >Hi, > >I am writing a small app for the team as a utility. I uses Lisp and >tcl/tk bindings. I have ActiveState tcl/tk 8.4 installed on my machine. >Is there any way to distribute my app without having to install >ActiveState package on every user machine? >I am wondering if there is "minimum" way to distribute the >necessary tcl/tk components (wish.exe, etc.). I mean just what dlls and >exe should I put in my lisp app folder? . . . Does <URL: http://wiki.tcl.tk/deployment > leave any questions? You'll particularly want to read <URL: http://wiki.tcl.tk/starkit > and <URL: http://wiki.tcl.tk/11861 >. Others have passed this way before you. astebakov@yahoo.com schrieb: > Hi, > > I am writing a small app for the team as a utility. I uses Lisp and > tcl/tk bindings. I have ActiveState tcl/tk 8.4 installed on my machine. > Is there any way to dis...

"Tk editor application template" [http://wiki.tcl.tk/8288]
I'm using Tk/Tcl 8.6.4 under WinXP Pro SP3 My learning style is to tweak something that is almost what I want until it is. I have three identified problems: 1. What is proper syntax to invoke when sourced from another script? [Works as expected when clicking on filename.] The code reads: #-------------------------------------------------- # Execute the main procedure #-------------------------------------------------- myAppMain $argc $argv However no reference to "argc" exists. 2. How do I add a functional "Find" com...

How to open a pty from Tcl (or "please translate C example to Tcl")
Hello out there, still struggling with getting TCP/IP to work in my somewhat bizarre setup (TCP/IP over 10.000 Volt power-line modems) I got a hint to try to use a pseudo tty. I got the advice --- What you would do is write a small C program (or perl, or any of a number of other languages). This program would call the "openpty" function, which: - Locates the next available (unused) pseudo-TTY device in the system, - Opens both ends of it, into two different descriptors, - Returns the file-descriptor numbers for the two ends (the "slave" end which mimics a tty, and the master end that your program will be using as the intercept point), and the filename of the slave (e.g. "/dev/ptya0"). --- Q1: Any way I could accomplish this from Tcl? Well, knowing nothing about openpty and pseude ttys I hunted around and found the following code snippet: --- /* * Allocate pseudo tty, returns master side fd. * Stores slave name in the first arg(must be large enough). */ int pty_open(char *sl_name) { int mr_fd; char ptyname[] = "/dev/ptyXY"; char ch[] = "pqrstuvwxyz"; char digit[] = "0123456789abcdefghijklmnopqrstuv"; int l, m; /* This algorithm should work for almost all standard Unices */ for(l=0; ch[l]; l++ ) { for(m=0; digit[m]; m++ ) { ptyname[8] = ch[l]; ptyname[9] = digit[m]; /* Open the master */ if( (mr_fd=open(ptyname, O_RDWR)) < 0 ) continue...

Using "source" vs "package require" for Tcl application files
I would like to divide my Tcl application into separate files. Should I generally use "source" to combine the files, or should I use the package mechanism (package provide, package require, etc.)? What is the generally accepted practice? Thanks, Gregg On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: > I would like to divide my Tcl application into separate files. Should I > generally use "source" to combine the files, or should I use the package > mechanism (package provide, package require, etc.)? > > What is the generally accepted practice? > > Thanks, > > Gregg IMHO use [source]. My reasoning: - The package mechanism is meant for getting access to general-purpose libraries, installed directly under the Tcl installation. - You talk of source files for your own application. So I would expect these files to reside in a directory containing that application. Then [source] is easier to use - and you guarantee that you get the source files from your application (otherwise a random package with the same name from the installation could interfer, if you are not careful with the library path) - Using [source] also makes it clear that these files are meant for your application only, not for more general purposes. Regards, Arjen Arjen Markus wrote: > On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: >> I would like to divide my Tcl application into separate files. Should I >> gen...

[tcl/tk] Question
Hi, I'd like to set the size of the "entry" field as long as the text entered. Any ideas? the line looks like this: set ent_top [entry .aaa.bbb.ent_top -textvariable TOP] On 09/08/2011 14:07, Guy wrote: > I'd like to set the size of the "entry" field as long as the text entered. > > set ent_top [entry .aaa.bbb.ent_top -textvariable TOP] Put a write trace on TOP that sets the -width of the entry. You might want to have a minimum and maximum though; zero-width entries are hard to use, and you don't want a width more than that of the screen (just in case someone cut-n-paste's War and Peace in there…) Donal. Am 09.08.2011 16:40, schrieb Donal K. Fellows: > On 09/08/2011 14:07, Guy wrote: >> I'd like to set the size of the "entry" field as long as the text >> entered. >> >> set ent_top [entry .aaa.bbb.ent_top -textvariable TOP] > > Put a write trace on TOP that sets the -width of the entry. You might > want to have a minimum and maximum though; zero-width entries are hard > to use, and you don't want a width more than that of the screen (just in > case someone cut-n-paste's War and Peace in there…) > > Donal. Why not use the built-in easy way: Just set the widget's -width option to 0. From the "entry" man page: "... If the value is less than or equal to zero, the widget picks a size just large enough to hold its current text.&...

"Tcl/Tk is a fringe language only used by cults"
While estimating a new project a few weeks ago I stated that my estimates were based on using Tcl/Tk, because the proposed project was very similar to others that we have done using Tcl/Tk. But the system architect informed me that "Tcl/Tk is a fringe language only used by cults" and that the new project would be done in C/C++. So now I'm exploring the wonders of MS Visual C/C++ for the first time; the only such IDE I've used previously is Sun Workshop. I have successfully compiled a DLL, but of course I need to *test* it, and... hmm... somehow it just happens to contain hooks so it's loadable and callable from Tcl. Gosh, how'd those get in there? Come to think of it, "c.l.t" does *look* an awful lot like "cult"! And one of the finest and friendliest cults on usenet it is, too. Sl�inte! Well at least he showed you his intelligence level up front... :-) Robert John Seal wrote: > architect informed me that "Tcl/Tk is a fringe language only used by > cults" and that the new project would be done in C/C++. So now I'm Bah, the world is full of silly ideas. Come and visit me sometime and I'll share them with you over a glass of koolaid. :D -- Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos John Seal wrote: > "Tcl/Tk is a fringe language only used by > cults" I agree. Tcl/Tk is a cult that has less members than cults like C/C++ YekSo...

Perhaps more eyecandy ("How to promote TCL/Tk" series...)?
I've installed recently xorg server V7.1, and examining the "eyecandy effects", which are available using "xcompmgr" utility, I noticed, that even the very basic settings, which I've found on Gentoo forum (for example: xcompmgr -cCfF -r7 -o.65 -l-10 -t-8 -D7) gave quite pleasant effect, when using Tk-driven programs. Although personally I'm not so big eyecandy-fan - I do realize, that most applications-users are very fond of such effects. So, my suggestion would be: perhaps could be possible to add some new options, which could allow such effects like "shadow" (below the window, or just pulled down menu), blur, shadow, opacity (I mean: some of the things to be found on the xcompmgr man page) - or perhaps even to open new toplevel with translucent background - just "by default", when xorg has been detected in environment? It's likely, that such direct support would mean less CPU usage. I don't know, how difficult to implement it can be (or whether is it possible at all) - it's just an idea. -- ZB ZB wrote: > I've installed recently xorg server V7.1, and examining the "eyecandy > effects", which are available using "xcompmgr" utility, I noticed, that even > the very basic settings, which I've found on Gentoo forum (for example: > xcompmgr -cCfF -r7 -o.65 -l-10 -t-8 -D7) gave quite pleasant effect, when > using Tk-driven programs. > > Although personally I'm n...

TCL "subshell"
Hi, I'm working on a kind of simulator /debugger application for some special multiprocessor hardware. The application has a number of TCL commands which the user can use to drive it. I'd like to implement breakpoints where the user can register TCL scripts to be executed when the breakpoint event is encountered. I really wanted to run these scripts in a "sub-shell" of the TCL environment which runs the main application. The reason for this is I want to provide a number of environment variables which can be accessed by the "subshell" but do not make sense int he main shell - for instance, the break point script could ask which process the breakpoint occured on, or the line number/file, ( there are a number of different things here which would only make sense to those involved in the development of the hardware). My first attempt was to use Tcl_CreateSlave(), but this doesnt "inherit" the commands from the main shell so doesn't work for me - in particular, the scripts registered for the breakpoints are not available in the slave. Does this "subshell" idea which makes sense in TCL or am I flogging a dead horse? dave In article <T66dnUaDisWokVXVnZ2dnUVZ_ofinZ2d@comcast.com>, CockneyWinker <datownsend@comcast.net> wrote: >Hi, > >I'm working on a kind of simulator /debugger application for some special >multiprocessor hardware. >The application has a number of TCL commands which ...

"?" in Tcl regexp
Any one can explain why I can not match the character "?" in Expect: expect -re "bala bala\?" Thanks, Dao "Dao" <youdao_du@hotmial.com> wrote in message news:bgt790$aca$1@zcars0v6.ca.nortel.com... > Any one can explain why I can not match the character "?" in Expect: > expect -re "bala bala\?" Backslash substitution in the quoted string is taking away the backslash for you; so the regexp you are using is "bala bala?" Put the string in braces instead of quotes. -- Jonathan Bromley, Consultant DOULOS - Developing De...

"Vectors" in tcl?
Hi all, What is my "best" alternative in handling vectors in Tcl? ("best" as in using a package available in ActiveTcl. I know about VecTcl, but...) I want to use a vector (potentially large, as in half a million boolean values). If this vector is created with all zeros, and I want to turn some of them (I have their indices as a tcl list) to 1. Right now I am using a tcl list, but I need to loop over this list, and set each one to 1. And I was wondering if there is a faster way (as in doing it with a single tcl command). I was looking at the the math:...

Web resources about - Are Tcl and Tk "inseparable"? - comp.lang.tcl

Resources last updated: 3/13/2016 4:39:41 PM