Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Limits of Perl/tk?

by Sprad (Hermit)
on Apr 28, 2001 at 02:14 UTC ( [id://76284]=perlquestion: print w/replies, xml ) Need Help??

Sprad has asked for the wisdom of the Perl Monks concerning the following question:

I'm just beginning to explore Perl/tk, and I was wondering what it's capable of. What are some of the more complex things that have been done with it? Is there anything that's out of scope for it? I heard there was a web browser; are there spreadsheets? Graphics programs? First-person shooters?

And what about speed? How does a Perl/tk program compare to a similar app written in Java? VB? Where are the bottlenecks?

Assuming there is a limit, is there anything available that's more powerful, but still lets me use Perl?

---
A fair fight is a sign of poor planning.

Replies are listed 'Best First'.
Re: Limits of Perl/tk?
by tinman (Curate) on Apr 28, 2001 at 02:33 UTC

    I've used Perl/Tk for some applications... and I think its a very good GUI toolkit.. but, there are limitations that I've observed..

    Firstly, the syntax is a bit awkward to pick up.. at least, I found it to be so.. some of the learning curve in Perl/Tk for me could have been because when I learnt it, I didn't understand OOP in Perl at all.. the concept of objects was unknown to me... but it looks different from the usual Perl code...

    Although I hate to say this, I must concede that Swing, in recent years, has overtaken Tk in extensibility and functionality.. Having programmed quite a bit in Swing, it seems to have a lot of more breadth in widget types now than before...

    Ok, now, onto the good stuff, and believe me, there is a lot that Tk has going for it.. Spreadsheets, yes, definitely possible...see here for a module on this.. never used it myself, but I know it exists :o) Graphics programs, very definitely.. if you haven't already, fire up the widget examples that came with your Tk distribution and look at the Canvas examples.. I've seen wonderful examples of graphics related programming in Tk.. First person shooters, nope, not really.. can't say I've seen those... Some more experienced monks, please do correct me if I err, but Perl/Tk isn't the fastest for that sort of thing... I'd tell you to look at C or C++ for that sort of thing..

    Speed wise, and memory consumption wise, Tk rules.. don't even bother running Swing unless you have 128+ mb of RAM.. but I completed a complex Tk application that ran perfectly on my ancient P200 with just 32mb of RAM on Win95... no swapping out to disk, at all... Part of this is due to what I consider to be a design drawback of Swing, in that it renders each and every component.. Tk takes the much more pragmatic approach of using native components (dialogs etc) where possible, so it runs faster and smaller than its Swing equivalent...

    As far as Visual Basic goes, well, I have to say that its much easier to write quick'n'dirty GUI apps using it... although Perl has made advances with the use of tools like SpecTcl and SpecPerl... but there is one major advantage of using Tk over VB, and that is platform independence.. I have not had to change much code (mostly, I haven't had to change any code at all) to get an application to run on both Win32 and Linux..

    I'd probably tell you to stick with Tk, its a rewarding GUI toolkit to use, but if you insist, WxWindows has a Perl binding.. I think its in beta, but I have used the Python binding, and I find it to be useful for some GUI building tasks.. YMMV..
    HTH

Re: Limits of Perl/tk?
by Starky (Chaplain) on Apr 28, 2001 at 06:35 UTC
    Perl/Tk is a thoroughly underrated GUI toolkit.

    I have used Perl/Tk, Java AWT, Java Swing, Gtk+, and VB. I can say that Perl/Tk is by far my favorite.

    Preferences aside, there are advantages and disadvantages to each and each may be used for different reasons.

    These are the advantages of Perl/Tk as I see it:

    1) Platform independence. I have written rather complicated applications (e.g., about 20 different kinds of toplevel windows in the application) in Perl/Tk, and they worked identically for both my Linux and Windows users. I even used ActiveState's perlapp without a hitch to create executables, which enabled me to distribute the application to Windows users who didn't have Perl installed or didn't know how to type "ppm install Tk" at a DOS prompt.

    2) Robustness. I was quite pleased with the widget set Perl/Tk had to offer. I found making compound (i.e., complex customized) widgets easy once I got the hang of it and never felt like there was any crucial element that I was missing, as I felt when I was working with AWT.

    3) Simplicity. The GUI code of Perl/Tk is as easy as VB, and because it's in Perl, the non-GUI parts of the code are alot easier and more intuitive to me. (I've heard others say they don't find Perl/Tk syntax intuitive, but I've always found it easy to understand. Maybe that's just me.) Plus you have the whole of the CPAN to work with :-)

    4) Reliability. The base widget set is fairly mature, and it shows.

    5) Perl. You can code in Perl, which, of Perl, Java, C, and C++ (the other languages I've coded in) is by far my favorite language for reasons that would fill several volumes.

    Here are some of the disadvantages:

    1) Documentation. Back when I started, there were a couple of web sites with documentation (O'Reilly books were years in the coming) and comp.lang.perl.tk. To this day, widespread and easily digested documentation (with the possible exception of the Learning Perl/Tk book by O'Reilly) is sorely lacking. In documentation, Java and VB easily have the edge.

    I must say, though, I enjoy coding in Perl so much that the lack of documentation did not deter me, and I'm happy that it didn't.

    2) Compiling on Unix. There is no easy, commonly accepted means to compile Perl scripts for Unix. Over time, the widget toolkit can change, which rarely changes the functionality of the widgets, but can sometimes impact the appearance of your widgets. (The most annoying thing I've found is changes in font support). On Windows, I've never seen perlapp unable to compile even the most complex Perl/Tk application.

    3) GUI builders. I've always been one to learn something with a basic text editor at my fingers, then move on to IDEs and GUI builders once I'm confident with the foundations. So this was not an issue for me, and in fact now that I know the syntax so well, I can code the text much faster and cleaner in Perl/Tk that I've seen VB coders build similar things with a GUI builder. (I even had a race once with a VB coder who was using a GUI builder. I won 2 of 3 contests.) However, GUI builders for the other languages are clearly superior.

    4) Community. Less people code in Perl/Tk than Java/Swing or VB. I see this as an advantage and disadvantage. I get consistently good advice when I post a question to comp.lang.perl.tk and the community is very friendly and helpful. However, there are not as many resources available.

    Finally, I should point out that Perl/Tk is good for small to medium applications, and for a word processor or some other extremely complex application, you will want to go with something else. (For example, when you build an application that has a huge scroll area, such as a spreadsheet with 65536 rows and 1024 columns, you will run into significant problems as Perl/Tk doesn't have the kind of widgets that support such mongo, if I may say mongo, needs.) But for applications that you need to make with a minimum of fuss, particularly for applications that should be cross-platform, Perl/Tk won't steer you wrong.

    As an aside, I think Perl/Tk should be included with the standard Perl bundle. It would make such a great environment for making GUI-based utilities (such as sysadmin utilities) and other applications that would make Unix more friendly to less knowledgable users if Perl coders could simply assume that Perl/Tk came installed on the platform they were writing for.

    When I've been asked by customers for GUI applications and the choice of language has not been specified, I usually reach for Perl/Tk first. They have even been unaware after receiving the product that it was written in Perl, but they are pleased with the turnaround time.

    Hope this helps!

    P.S.
    by Starky (Chaplain) on Apr 28, 2001 at 23:38 UTC
      In more direct reply to some of your specific questions, check out GAMS-Tk. It is part of a package called GAMS-X I wrote years ago for mathematical modeling using a proprietary optimization software product called GAMS. That's the largest Perl/Tk application I've ever created.

      Although the code has gone stale since I left graduate school, you can see several screen shots. It was quite cutting-edge at the time, if I do say so myself ;-)

      It uses GIFgraph (now PNGgraph I believe) and Gnuplot for graphics.

      As to graphics and first-person shooters, I think Perl/Tk would be inappropriate for that kind of application because (i) the widget set really wasn't designed for that sort of thing and (ii) you would want to write a 1st person shooter game in C or some other language that gives you fast fast fast code. Perl is not that language.

      You may also enjoy taking a peak at the Moaning Goat Meter. I use it on my desktop, and it's a very nicely done and unique Perl/Tk application.

      And as far as weight (e.g., process size and resource intensity) and speed go, of course it all depends, but in my experience, Perl/Tk is (i) lighter weight and faster (in some cases much faster) than Java but (ii) a heavier weight than VB for small apps (but not really all that heavy after all, so this shouldn't be a deciding factor), with the size appearing to approach that of VB as the size of the app grows, and a touch slower than VB in most areas (though not noticably so). I've never made scientific observations to back up these statements; they should be taken as subjective and based on a limited sample size.

Re: Limits of Perl/tk?
by traveler (Parson) on Apr 28, 2001 at 02:49 UTC
    I have not used perl/tk: the syntax turned me off. I have used Gtk-Perl. I like it a lot and have done some significant projects with it (sorry I cannot provide pointers, they're for the clients' internal use only...). I had done some Gtk programming in C before using Perl-Gtk so I knew a few things about Gtk, but the perl interface is much easier to use. Rather than list the capabilities, here is a list of the modules (from the website):
    • libgtk The base module (Gtk and Gtk::Gdk namespaces).
    • libgdkimlib The Imlib module (Gtk::Gdk::ImlibImage namespace).
    • libgdkpixbuf The Pixbuf module (Gtk::Gdk::Pixbuf namespace).
    • libgtkglarea The OpenGL widget module (Gtk::GLArea namespace).
    • libgnomeui The main Gnome module (Gnome namespace).
    • libgnomeprint The GnomePrint module (Gnome::Print namespace).
    • libgtkhtml The HTML widget module (Gtk::HTML namespace).
    • libxmhtml The alternate HTML widget module (Gtk::XmHTML namespace).
    • libglade The Glade interface files (Gtk::GladeXML namespace).
    There is lots of stuff and it seems to be a fairly complete Gtk implementation. Lots of tools are built with gtk, but I do not know of a statistic for apps built with Perl-Gtk. Based on the queries on the mailing list, though, there are some pretty interesting ones.

    --traveler

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://76284]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-25 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found