Idle Frequently Asked Questions

Some FAQs about Idle, with answers. If you have a question that's not answered here see the main documentation file for contact information.

1. Why would anyone do yet another scripting language?
top of page

Well, there are indeed a few reasons... at least for me:-)

One reason is that Perl is powerful but unreadable (I've now written Perl programs -- or rather the gibberish that passes for Perl programs -- for more than ten years... believe it or not, I sometimes still have to grab the CamelBook if I want to understand some of my older scripts). Another reason is that Python, though powerful, has a strange feel to it (free form? what the heck is free form?). I never really tried Ruby: perhaps this would have been the revelation I've been waiting for.

However, all these worthy considerations aside, the main reason, the absolutely overriding reason for 'inventing' Idle, is this: all scripting languages I know are either puny little lightweights or powerful big beasts. And when I say 'big' I mean that in two senses: these are huge, complex packages that could easily overwhelm a casual user (especially under Windows which is my home patch). Second, they produce monstrously big executable files (if they support easy conversion to .exe files at all). All of which makes distributing small (or not-so-small) utility scripts to friends, neighbours, colleagues, newsgroups... rather difficult.

So here's what I want: I want a simple, but powerful scripting language that can be installed by copying a couple files between machines and then be done with. I want a language that will build executables in the 20 to 50 KB range, not the megabyte monsters py2exe throws at me. And I want a fast, efficient, extensible language. (And if script code I've written ages ago remains readable and understandable even a decade later, I won't complain either.)

Enter Lua. Lua is small, but powerful. It can be installed by copying a few files which take altogether less than 200 KB. Lua has an elegant, almost orthogonal language definition which successfully combines the feel of a Niklaus-Wirth-designed language with the strange things one can do in Scheme. In a word, Lua is great.

2. Hang on a minute. If Lua is such a great thing, how come not more people are using it as their scripting language of choice?
top of page

That's a rather good question and an exhaustive answer is probably beyond me. However, here are a few hints (all of which are thoroughly IMHO):

So, in the end, Idle is simply my attempt to take all that is good in Lua and to extend it with those things I'd like to see in a script language... all the while keeping the bloat factor down, so that I can write scripts and distribute them as small executable files (plus another 230 KB or so for the Idle runtime DLL which is of course needed only once).

Idle can't solve all scripting problems in the world (it sure wasn't designed to do that). And I could spend ages with defending this or that design decision, could get into heated philosophical discussions about the relative merits of, say, lexical scoping vs dynamic scoping. No: Idle is nothing more and nothing less than my solution to a specific problem that was plaguing me for some time (a problem which many people probably don't have). It does exactly what I want it do do... and it does so in a clean, pragmatic manner. Idle is a tool and if this tool can help other people as well... so much the better.

There you have it.

3. Exactly how compatible to Lua is Idle?
top of page

Syntactically correct Lua programs should work in Idle. If they don't, there's a bug either in Lua or in Idle (almost certainly the latter). However, there are a few important caveats:

Most of these things have quick and relatively painless fixes.

4. Hm... we'll see. What about the extensions?
top of page

There are many extensions in Idle which if used in a script will render it incompatible to Lua. The most important of these, as far as the language is concerned, include:

And there's of course the huge set of additional functions in the Idle runtime: almost all standard Lua modules include additional functions plus there are Perl-compatible regular expressions and PEGs, integrated support for archives, many operating system functions, real pre-emptive multitasking, many Win32 specific calls, the ability to dynamically call any functions in any Windows DLL, the ability to embed Perl and Tiny C code, networking, SQLite 3 database support...

5. Is there an easy way to learn how to write scripts in Idle (or, for that matter, in Lua)?
top of page

Learning how to program is never easy;-). That said, Idle as a programming language is relatively easy to learn because it has a small and clean syntax. It is slightly more verbose than Perl but for quite a few people, me included, that is actually an advantage (for instance if you try to understand a script you've written years ago...).

Given that Idle is based on Lua, any manual or book about Lua will help you to learn the ropes. See for example the online version of "Programming in Lua" by Roberto Ierusalimschy. Although this book describes a slightly earlier version of Lua, it is a very good introduction not only to the language but also to some general concepts in script programming. "Programming in Lua" is also available in an extended 2nd edition. There is also "Beginning Lua Programming" by Kurt Jung and Aaron Brown (Wrox, ISBN 0470069171).

6. Why do you use 'break 0' instead of the more conventional 'continue'?
top of page

'break' is already a reserved keyword whereas 'continue' is not. Adding reserved keywords may well break compatibility with existing code so I will only do that if there's absolutely no other way. And 'break 0' to continue a loop, if you think about it, does have a certain twisted logic. In the end this is just a minor syntactical detail: if you want 'continue', you could define a macro or use a token filter.

7. What is the difference between the Idle interpreter, the Idle compiler and the JIT compiler?
top of page

The Idle interpreter (idle.exe or idlew.exe) accepts either an Idle source file and compiles it to byte code or it reads an already compiled byte code file. In either case it then executes the byte code stream in a virtual machine.

The Idle compiler (idlec.exe) compiles an Idle source code file (a module or a program). This produces either a byte code file that can be run later by the Idle interpreter or an executable file which needs neither the interpreter nor the compiler, just the Idle runtime DLL (which contains the virtual machine that executes the byte code stream).

Last but not least, the JIT compiler kicks in once the byte code stream is actually executed by the virtual machine. The JIT compiler takes the byte codes and translates them on the fly to x86 machine instructions. This process goes on transparently in the background.

8. My GUI script doesn't work; instead Idle says "mygui.idle:1: gui not declared in main program". What gives?
top of page

You are probably using idle.exe (ie the console version of Idle) to start the script. In this case, you have to explicitly call require('gui') to load the gui module. The GUI version of the interpreter (ie idlew.exe) does that automatically.

9. What is the standard extension used for compiled byte code?
top of page

By default, idlec.exe (the Idle compiler) and the runtime libraries use .idol (IDle Object Library), but for all intents and purposes you're free to use whatever you want. See the tools page for details.

10. I think you should have included $feature. Why didn't you?
top of page

Perhaps I never needed it (I am a big believer in feature-driven development). Or perhaps it's trivial to do in a couple lines of Idle. Maybe I simply forgot. Remember: this is still a beta release and one reason why I am releasing it is to get bug reports and feature feedback.

In a word, it's never too late: just send me an email with your suggestion(s) and we'll see (including some working code would greatly enhance the chances that I include $feature in the next release).

11. Will you prepare a new version of Idle if a new version of Lua appears?
top of page

Yes, although I won't promise a definite time frame. If we're talking about minor bug-fix releases like the recent 5.1.x versions, I should be able to update Idle within weeks rather than months (all the more so as I am slipstreaming official fixes as they become available).

A major new version of Lua (version 5.2 is currently in the works) may not be as straightforward, though. The general idea would be to continue the current 1.x stream of Idle (but concentrating on bug fixes from the 5.1.x series of Lua) and to start a completely new stream, perhaps called Idle v2.x, based on the 5.2 version of Lua. Given that this version of Lua will implement quite a few things which are already available in Idle v1.0, a 5.2-based version of Idle should not be too much work. Then again, devil, details and all that;-)

Such a second stream of Idle would not necessarily be 100% backward-compatible to the Idle 1.x stream and it would implement some significant additions, foremost some sort of Unicode support. I am also seriously contemplating to port at least a basic version (ie Idle minus the win32/GUI stuff) of any future Idle v2.x to Linux.

12. What are the versions of the main external libraries that are used in Idle? How much did you change?
top of page

As for Lua itself, if new versions of these libraries appear I will endeavour to incorporate significant bug fixes ASAP. However, since all the libraries (with the possible exception of ldb) are mature products, I do not anticipate huge changes.

There are two additional language bindings, for Perl and Tiny C:

Probably needless to say: wherever I changed or adapted existing source from third parties, any and all bugs and 'issues' are my full responsibility.

13. Why doesn't Idle support Unicode?
top of page

Idle is based on Lua and the Lua language core is currently not Unicode-enabled. No amount of library support can change this fact as Unicode support has to be included at the very lowest level to work at all. This being the case I removed Unicode support from some of Idle's supporting libraries (eg the regular expression library); this was purely a space-saving measure.

I am looking into this matter for a future version (probably not before Idle v2.0, so don't hold your breath) and although full-blown Unicode support (utf16 or even utf32) will not be coming anytime soon, at some point I may include reading, writing and converting utf8 strings.

Having said all that, Unicode is not an all-or-nothing proposition. Idle supports 8-bit-clean strings and \0 has no special significance, so depending on what you actually want (or need) to do it may well be possible right out of the box.

14. What if there's a discrepancy between the downloaded documentation and the online version?
top of page

The online version is generally slightly more recent and more trustworthy. This should only ever be a problem for things currently under active development or while I am fixing a bug.

15. The Idle runtime DLL is UPX compressed. What can I do if I need it uncompressed?
top of page

Simply uncompress the compressed image by calling UPX with the -d switch:

upx -d idle03.dll
16. What about a Linux, Solaris, BSD ... version?
top of page

I am primarily a Windows developer (read: if you place all I know about Linux system programming on the pin of a needle there'd still be enough room for a troupe of angels). OTOH, I think getting this baby to work under Linux would not be devilishly difficult. Many of the libraries I've used have their origins in the *nix world anyway. As to my code -- with the exception of the gui and win32 modules --, this is not unnecessarily tightly bound to Windows (I hope). So in principle, doing a port should be feasible.

However, I won't attempt such a port myself. A few people who currently use the Windows version have expressed their interest in a Linux version of Idle and they might want to try their hand in porting the stuff, once the sources are publicly available (see next question). Until then, Wine may or may not be a temporary solution for some.

17. Can I get the Idle sources?
top of page

Yes, simply download and unpack this zip file. As it stands, compiling the sources requires a mildly convoluted toolchain based on stock MS C compilers but linking strictly against MSVCRT.DLL only. This is not a requirement per se, I've just done it that way to minimise runtime library dependencies. The sources should be seen a starting point; they are far less polished than they could be, if I had been able and willing to invest more time.

Some details about the required tools and libraries are found in a README included with the sources.

18. Where is the documentation for the GUI functions?
top of page

Hopefully somewhere in my head;-)

Seriously, I have included preliminary HTML documentation: this, together with the GUI sample scripts (see test\GUI\), should give you a pretty good idea how things hang together. If you're really stumped, please send me an email; possibly I can help you and also update the documentation. A future version of Idle will include full documentation for the GUI module as well.

19. Does Idle support Windows 9x or ME?
top of page

No. Idle uses system calls that are not defined for non-NT systems. Look at a few recent statistics about the number of people who (try to) use Windows 9x systems and, more importantly, the long-term trend and you will understand why there are no plans at all to change this.

Idle does run under all NT-based system (Windows 2000, XP, ...). Using certain features under Windows Vista may well require to switch off UAC. This being the case, Idle is not (and will probably never be) certified Vista compatible.

98. What's the meaning of Idle?
top of page

It's what I'd like to be more often;-) No, I just found 'Idle' to be a nice name for a scripting language (to be fair, a number of people think it's the daftest name under the sun... take your pick).

Idle is of course a real word with a real dictionary entry but it might just as well be an acronym. Here are some possible meanings for those who love to play the ADG:

I personally prefer the last one. If you find a good one, send it in and I might put it into the FAQ.

99. What about the cheesy image (top right of this page)? Don't you have something more flashy?
top of page

Hey, at least it's colourful! As to the flashiness... sorry, I am a programmer, not a graphics artist. ('Sorry, I'm a butler, not a catcher.')

However, anyone who feels a sudden irrepressible urge to produce a really nice-looking image for Idle... don't be idle, go ahead. If I like it, I may adopt it.

$$ built from IdleFAQ.txt d106963c4f77 Mon Sep 27 13:27:10 2010 +0000 thomasl $$