Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

Software Geeks: Tk/Tcl or Python?

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
 
valis Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-21-05 01:56 PM
Original message
Software Geeks: Tk/Tcl or Python?
Edited on Sat May-21-05 01:57 PM by valis
Do you use any of these scripting languages? Which one do you think is best? I'm a Tk/Tcl fan myself. But Python has certain strenghts.
Printer Friendly | Permalink |  | Top
salvorhardin Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-21-05 02:01 PM
Response to Original message
1. Neither
Edited on Sat May-21-05 02:06 PM by salvorhardin
PERL is the one true scripting god. How dare you blaspheme? And when Version 6 is finished it shall assimilate all lesser scripting languages and cleanse the world of all non-believers with its auto-smoting capabilities. Provided you can figure out the new and improved RegEx syntax.

On edit: Besides, how can you not love a language that is indistinguisable from line noise?
Printer Friendly | Permalink |  | Top
 
valis Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-21-05 02:05 PM
Response to Reply #1
2. PERL is OK. But inferior to Tcl!
As the two leading scripting languages, Tcl and Perl are often compared. New users frequently ask on the Tcl and Perl newsgroups for advice in choosing between them. Although both languages offer powerful capabilities, here are ten reasons why many people prefer Tcl over Perl:

1. Simplicity. Tcl is much simpler and easier to learn than Perl. Perl has a complex syntax where most of the characters on the keyboard have special meanings you have to memorize. The Perl language is riddled with special cases and idioms. There are many different ways to do the same task in Perl, and you'll have to learn them all if you're going to read other people's code. As a result, you'll need to be an expert programmer to learn Perl, and you should expect to go through a long learning curve. Tcl is just the opposite. To get started with Tcl, all you need to learn is about a half dozen basic syntax rules plus a few of the most popular commands. There are dozens of additional commands that provide everything from graphical user interfaces to database access to object-oriented programming, but you can pick these up one at a time when you need them. Even casual programmers find that they can learn enough Tcl to perform useful tasks in just a few hours.
2. Maintainability. People often refer to Perl code as "write-only": if you come back to a Perl script after a couple of months, you probably won't be able to understand it anymore. This problem stems from the complex idiomatic nature of the Perl language. The simplicity of the Tcl language makes it easier to read and maintain Tcl code. Even the most popular reference book for Perl (the Camel Book) makes this admission:

There's no correct way to write Perl. A Perl script is correct if it's halfway readble and gets the job done before your boss fires you.
-- Programming Perl

3. Graphical User Interfaces. The Tk toolkit provides Tcl with GUI facilities that are amazingly simple and powerful. There's nothing quite like it in any other language. Perl has no built-in GUI facilities of its own. There is a package called TkPerl that allows you to use Tk from Perl scripts, but it's pretty clumsy. Tk was really designed to work best with Tcl; furthermore, TkPerl doesn't provide access to the additional widget extensions people have built for Tk.
4. Development tools. TclPro product provides a sophisticated set of development tools for Tcl, including a powerful graphical debugger, code checker, and other tools. TclPro runs on Windows as well as several versions of Unix. The commercial tools available for Perl are less complete and run mainly under Windows.
5. Internationalization. Tcl is based on Unicode, which makes it superior for applications that must be internationalized. Perl is still based on 8-bit characters. It can't support Asian character sets, and it can't properly support new technologies that require Unicode, such as XML. The Tcl regular expression engine works on 16-bit characters. Perl's does not. With Perl 5.8 (Summer 2002), unicode support for Perl has improved, but the level of transparency to the programmer varies.
6. Extensibility. Tcl was designed from the start to be easily extensible. This means that you can add new features to the language by writing C, C++, or Java code. Tcl provides a rich set of APIs for building extensions: they allow you to add new functions, new data structures, and even new control structures such as loops or conditionals. Tcl's extension mechanism makes it easy to connect Tcl with things you would like to automate or integrate, such as enterprise applications or new network protocols. Dozens of Tcl extensions are available freely on the Internet, providing features such as database access (Sybtcl, Oratcl, and Tclodbc), object-oriented programming (), and network management (Scotty). Perl does not have a well-developed set of extension APIs; though it is possible in principle to extend Perl, it is rarely done in practice.
7. Embeddability. The Tcl interpreter exists as a C library package that can be linked directly into a variety of applications. When embedded, the features of the application are incorporated into Tcl using Tcl's extension APIs. This allows Tcl to serve as a powerful command language for applications; Tcl scripts can then be used for configuration, management, customization, and integration. Tcl can also be embedded into devices for a variety of uses. Perl was not designed to be embeddable and it is difficult to use in this way. Thus, if you would like a scripting language for use inside an application or device, Tcl is your best bet.
8. Thread-safe. The Tcl interpreter is thread-safe, which means you can embed Tcl in multi-threaded applications such as large servers and enterprise applications. Some of the largest Web sites (e.g., NetScape NetCenter) use Tcl in multi-threaded server applications for dynamic page generation. Perl is not thread-safe. Perl 5.8 is working towards correcting many of the threading problems in Perl, but the jury is still out. Perl6, the long-in-development and oft-lambasted rewrite of the Perl core is being done in part to get threading right.
9. Range. Tcl can be used in many more situations, for many more purposes, than Perl. Perl is really a text manipulation language, whereas Tcl is a more general application development language. Graphical user interfaces, Unicode, extensibility, embeddability, and threading are just a few examples of Tcl's greater range.
10. Event handling. Tcl has a much more sophisticated event handling system than Perl; this is important for server applications. With just a few lines of Tcl code you can define a network server that handles connections from multiple clients simultaneously.
Misconceptions

If you explore the Perl Web sites, you'll find various claims about why Perl is superior to Tcl. Many of these claims are either incorrect or out-of-date, including all of the following:
* Perl is faster than Tcl? This was true many years ago, but Tcl caught up with the 8.0 release in 1997. Since then Perl and Tcl have had roughly equivalent performance (not surprising, given that both languages are now implemented with bytecode interpreters). Arguments that Tcl is purely a string-substitution language, that it can't store numbers as numbers, and that its lists are expensive are incorrect: all of these problems, and many other performance issues, were corrected in the 8.0 release.
* Perl has better regular expressions? Again, this was true in the past, but Tcl's regular expression package was completely rewritten for the 8.1 release. The new Tcl regular expression package has all of the advanced features that Perl has, plus Unicode support which Perl is lacking.
* Tcl isn't 8-bit clean? This claim hasn't been true for at least four or five years. In fact, today Tcl is based on Unicode, which allows it to support all of the languages of the world. Perl's Unicode implementation still isn't complete.
* Tcl doesn't support namespaces or object-oriented programming? Also not true. Namespaces were added in Tcl 8.0, and object-oriented programming has been available in Tcl for many years through the extension.
* Tcl can't handle binary data? Tcl has supported binary data since the 8.0 release.
Printer Friendly | Permalink |  | Top
 
salvorhardin Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-21-05 02:20 PM
Response to Reply #2
3. Refutation, point by point
Edited on Sat May-21-05 02:21 PM by salvorhardin
1. Simplicity is the hobgoblin of little minds. If you think that word should be 'complexity', you only prove the point.
2. Maintainability == lack of job security.
3. GUI Schmooey!
4. Real developers use vi
5. 7 bits should be enough for anyone
6. PERL is as extensible as anything. Just ask Larry Wall, he's been adding to it for almost 20 years now!
7. Embeddability -- phooey. It's much better to assimilate. All your scripts are belong to us.
8. One interpreter, one thread. What could be safer?
9. 7 bits. How often does this need repeating.
10. Hey, if ERRNO is good enough for C, it's good enough for PERL. Besides, real programmers know ABEND is the only error handling you need. See point above concerning job security.

Obviously I'm being facetious. The best language is the one that is right for the job.
Printer Friendly | Permalink |  | Top
 
valis Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-21-05 02:23 PM
Response to Reply #3
4. Ahahah! That's right. If it works for your needs that's good enough!
Well said...
Printer Friendly | Permalink |  | Top
 
salvorhardin Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-21-05 02:24 PM
Response to Reply #4
5. Right...
...and as everyone knows, Ruby is the right language for every job. :evilgrin:
Printer Friendly | Permalink |  | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Thu May 02nd 2024, 03:23 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC