Differences include:
Under DOS,
tclsh myscript.tcl > output.txt
does what one wants, but it's harder to achieve with wish.
Luciano ES Harder? Harder how? (please read on...)
This topic was raised at comp.lang.tcl by Luciano ES who asked, boldly: "What do we need tclsh for?" My point was that wish can do everything that tclsh can, plus the extra optional features, so why not ditch tclsh and keep wish only?
Among the several mentioned reasons, were:
It was also noted that the opposite is a lot easier to achieve, i.e. ditch wish and keep tclsh.
package require Tk 8.4
The simple line above in a Tcl script, even if run by tclsh, will immediately make all Tk functionality available throughout the rest of the program. A little (just a little) more about that is discussed in Using Tk as a loadable package.
Someone also added that: "At a DOS prompt I can say...
tclsh myscript.tcl >output.txt
... to capture the output (of practically unlimited size). Using wish for this kind of stuff might be possible but would be more involved IMO."
The information was confirmed by a notorious Tcl expert, who also said that "Tkcon would require an exec at the beginning of that command"
But it still puzzles me:
wm withdraw . puts "hi, Mom" exit
The script above can be run by wish and produce the same result as tclsh.
wish myscript.tcl >output.txt
in a DOS prompt produces just the same result as...
tclsh myscript.tcl >output.txt
I also ran wish myscript.tcl >output.txt from Tkcon, without the exec command, and had exactly the same result (shrug).
So, my conclusions so far are:
Note that I don't really want to get rid of tclsh. It is all just for the sake of getting a better grasp of the differences between the two programs.
SLB From a DOS prompt try running
wish myscript.tcl
i.e. with no redirection. The output will be lost. Conversely, if you setup file extensions so you can run Tcl scripts from Windows Explorer via tclsh, you will get a DOS Window.
RLH You will not get the DOS Window if you require the Tk package in your Tcl script. Even after reading all of this I come away with "we only really need tclsh now.". Am I missing something?
package require Tk 8.4
SLB Hmm, not what I see. Let's be specific. I'm running ActiveTcl 8.4.5 on Windows 2000. If I use the Run option from the start menu to launch tclsh84 I get a DOS window. I can use
package require Tk 8.4
and the DOS window is still there. I try the command
console show
I see:
invalid command name "console"
So the wish console is not available from tclsh. That's one difference between wish and tclsh
If I now take a simple Tcl script such as:
package require Tk button .b pack .b
save it in a file and double click on the file from Windows Explorer, then the wish top level window appears with no DOS window. Perhaps this is what you meant?
But now, I go to Windows Explorer's Tools menu, select Folder Options and then choose the File Types tab. I locate the file type Tcl and press Advanced to see its actions. I choose action 'open' and press Edit... This reveals that 'open' uses wish84. Change it to tclsh84, OK all the dialogs and try running the script again. I now see DOS prompt.