Programming in Lua, Second Edition Reviews



Amazon.com Customer Reviews

Good PIL book - Review written on November 17, 2007
* * * * *
Rating: 5 out of 5
2 customers found this review helpful, 1 did not.

Good examples, suggestions, and notes. Is a must have for any one looking to program in Lua.
I was not impressed - Review written on October 26, 2007
* * *
Rating: 3 out of 5
9 customers found this review helpful, 28 did not.

Naming this language after the moon is ironically apropos, as many of its lunatic creator's cognitive processes seem to randomly scramble themselves according to the phase of said moon. I'm no language designer myself, but if I were trying to come up with a high-level scripting language that would appeal directly to C programmers, the last thing I'd want to do is start array indices at 1 rather than 0. Sure, you have the option of altering this behavior in the constructor, but in the author's own words:

"I do not recommend the use of arrays starting at 0 in Lua. Most built-in functions assume that arrays start at index 1, and therefore they will not handle such arrays correctly."

Talk about giving you just enough rope to hang yourself. But it gets even better. Array elements in Lua are to be removed by assigning their indices the value of nil. This is all well and good, but, again in the author's own words:

"Lua uses [the nil] value as a sentinel to find the end of the array. When the array has holes--nil elements inside it--the length operator may assume any of these nil elements as the end marker. Of course, this unpredictability is hardly what you want."

No shoot, Sherlock. So why not get rid of that unpredictability? As I read further I came to the conclusion that this decision was made because doing otherwise would spoil the running theme of the language. Another favorite passage comes from page 32 when discussing the numeric for loop:

"you should never change the value of the control variable: the effect of such changes is unpredictable."

Great! I love unpredictable results. They make so much more sense than raising a predictable exception or pointing out a predictable old syntax error. Let's see now... How else can we anger C programmers? How about if we make it so "a break or return statement can appear only as the last statement of a block"? Wonderful! Now let's get rid of one of the primary attractions of high-level scripting languages--regular expressions--and say we can't include them due to size concerns (we really need to be able to brag about our entire distribution fitting on a single floppy disk, and the PCRE library is just HUGE).

These things are marginally less obnoxious than Python's significant whitespace, but still obnoxious, and apart from the multiple return values thing, I really didn't find any compelling reason to join the Lua fanboy camp in this volume. Maybe if I were a Warcraft player I'd feel differently.

As for the book itself, the writing is terse and very obviously coming from a non-native speaker. The typesetting is atrocious (good typography is one of those things you never really appreciate until it's gone) and the entire thing looks like it was printed on an old laser printer that was low on toner at Kinko's. If it were cheaper, I wouldn't care, but it's not, so I do.

Stick to the free PDF if you really have to learn Lua for something. The changes in 5.1 are not significant enough to warrant a second edition, and the flimsy, smudged paper is really not worth paying for.
All C programmers should have this book - Review written on August 06, 2007
* * * * *
Rating: 5 out of 5
7 customers found this review helpful.

Buying this book does more than support the Lua project. Having the book available will change your opinion of integrating script with C code! "Progamming in Lua" is a well-written text that makes using Lua practical. All of the best features of Lua are covered; the sample code is concise, clear and complete.

Lua is very different from C, and so allows a programmer to easily do things that are difficult in C. That makes it a perfect companion language. The only obstacle is training a C programmer to use it! That's where the book becomes useful. It's a quick read and covers all the essentials.

Even better, Lua is so well-connected to C that it is easy to switch back and forth in the course of a typical programming day, writing performance code in C and high-level logic in Lua. It is even possible to easily interact with Lua data structures in C without writing Lua code for situations where the data structures are desirable but Lua code isn't required. If you're looking for a scripting language for your next project, you need to know about Lua, and this book is the quickest way to make an informed decision.
Brilliant language, brilliant author, brilliant book - Review written on June 07, 2007
* * * * *
Rating: 5 out of 5
8 customers found this review helpful, 4 did not.

The Lua programming language is among those gems appearing once per decade. It has a simplicity and rigor which may make other well-thought languages (such as Prolog or Scheme) pale a little.

Simple without being simplistic, Lua takes you to a new level of productivity. This is *true* productivity flowing from the essence of a well-designed language, miles away from the well-known plethora of wizards and libraries that take you months to master in order to become "productive".

With Lua you do not learn a language, you simply learn a direct, simple and natural way of doing things. Lua "clears your mind", just like Prolog does - but in a different way (see "The Art of Prolog" by Sterling & Shapiro). Few programming languages boast such quintessential brilliance.

The author of this language is truly a genius of language design and most likely the years to come will prove it. I would not be surprised that after a decade or two Mr. Ierusalimschy will be cited among folks like Sussman or Colmerauer.

How "Programming in Lua" is written shows off that it was produced by the same mind which conceived Lua itself.

Good, well organized, concise without being too dry, showing good explanations without being too verbose, this book makes you not only learn while reading, but also to envision solutions to your programming tasks while learning.

One last thing: I did *not* read exactly this book. I've read only the first half of edition 1 online, but it is enough to understand what Lua is all about.

Needless to say that I ordered a copy of the second edition - surely equal in quality.
If you only buy one LUA book.... - Review written on June 06, 2007
* * * * *
Rating: 5 out of 5
8 customers found this review helpful.

This book is an excellent introduction to LUA programming.

I also have the "Beginning Lua Programming Book" by Kurt Jung and Aaron Brown (which admittedly covers a broader scope), but I find myself constantly referring to "Programming in Lua".

My own bias is that I am a C++ programming looking to embed LUA in a C++ application. Whilst I am a huge fan of this book, I would prefer slightly more coverage of the C Api for C/C++ programmers. One glaring example is the absence of any reference (that I could find) to the lua_next function. The stack concept is central to understanding interaction between LUA and C/C++ programs. I feel that my learning would have been accelerated by highlighting this fact, ideally with some pictorial representation of the stack contents when c/c++ methods are called from LUA, when lua_getfield, and lua_next methods are called. Maybe this could be covered in a third edition.

This book is still an excellent introduction to LUA!
Lua has real potential! - Review written on January 11, 2007
* * * *
Rating: 4 out of 5
5 customers found this review helpful, 1 did not.

Lua is an very interesting embeddable language. Its design is clever, even elegant in places. And this book is one of the more enjoyable programming language books I've read in awhile. Succinct, clear, without belaboring of theory, yet important concepts are carefully presented; a programmer's book. About a language that should be more widely used.
wow - Review written on November 09, 2006
* * * * *
Rating: 5 out of 5
3 customers found this review helpful, 5 did not.

this book does a great job of getting you going and filling your head with lots of neat ideas pretty quickly.

wish i had discovered lua a few years back when i was working on a project that needed an embedded scripting language.
It is an excellent book - Review written on October 25, 2006
* * * * *
Rating: 5 out of 5
14 customers found this review helpful, 1 did not.

I developed my previous project (Ribosome Builder [sourceforge.net]) with Lua and found it to be very stable, easy-to-use, small, fast and powerful. That said, I was eagerly looking forward to the release of this next edition of the book, because I'm using Lua again for my current projects, and hope to make even better use of Lua 5.1. I'm especially excited about the new support for modules, and also the fact that Lua is now supported by SWIG. Previously, I had to do a lot of manual hacking to define the interface functions between my core code (in C++) and the lua scripts.

I've read about 3/4 of the book so far and I am very pleased with it. The book is very cleanly and clearly written, with many things explained in a concise and elegant style. For example, Ierusalimschy's explanation of closures allowed me to immediately grasp them and appreciate why they are useful. I remember reading about them way back years ago in Larry Wall's book 'Programming Perl', and was remained rather confused about the concept. I don't know if the additional years of experience helped, but the clear style of the Lua book certainly did.

Using a scripting language for enhancing and extending a complex project just seems to be a given for most serious projects these days, and after surveying the field, I considered only two main choices: Python and Lua. Python is also really well designed and powerful, but I decided to go with Lua because it does pretty much everything I need it to do, does it very well, but best of all, it is so very small. These days when even the most basic projects can quickly grow into complex, interconnected monstrosities with a zillion dependencies, I believe that the values of small and simple are more important than ever. So for that reason especially, I'm really excited about Lua and the prospect for using it more effectively after I finish swallowing this tasty Blue PIL.
The ultimate book on Lua programming language - Review written on September 23, 2006
* * * * *
Rating: 5 out of 5
8 customers found this review helpful, 2 did not.

Recently I bought "Programming in Lua, Second Edition". Written by Lua creator himself this book offers great walkthrough the Lua language, includes many useful examples and shows variety of important Lua coding ideoms that comprise so called "Lua programming style". As an expert C/C++/Ruby coder but a novice Lua programmer I found PiL2 a great jump start in the languge.
Now on what PiL2 is not. PiL2 is not a reference manual (and was not designed that way). Lua reference manual is available online on Lua home page. Its printed version exists as well.
Great book for all Lua users - Review written on June 10, 2006
* * * * *
Rating: 5 out of 5
5 customers found this review helpful, 1 did not.

If you're a Lua 5.1 user, this book will help a lot. Many things that are left unclear in the Lua reference is picked up in this book, such as how module/require works but not only that.

This edition of the PiL also has more information about the C API, so if you want to implement Lua in your own application this will help too. I used it for implementing Lua in some of my own applications.
An Elegant Book for an Elegant Language - Review written on May 23, 2006
* * * * *
Rating: 5 out of 5
17 customers found this review helpful, 2 did not.

I am new to Lua. While a C++ developer, having used Perl, Python and Ruby, I was suprised by how much you can do with this compact scripting language.

The second edition is as eloquently written as the first (which is available online), but with new material and even more examples. In little time it introduced me to all aspects of the latest version of Lua -- 5.1 -- which includes a number of new features such as the new package system. Being a newcomer, it was nice to have a recent book covering all aspects of this latest version.

The book is well organized. It works as both a primer and complete course on the langauge. It covers the basic tenets and first principles, as well as the subtleties. It is written in the spirit of Lua: accomplishing much in minimal space. It does so through crisp, engaging writing and thorough, well-crafted examples. It is one of those books that feels timeless -- so well done that you mark your name on it with a Sharpie.

Lua is both a language and developer's tool. Part IV of the book, devoted to the C API, is as thorough for developers as the preceding parts are for language users. As I am using Lua in a multi-threaded environment, the second edition had the perfect example covering everything I needed to know -- from managing multiple states (interpreters) to wrapping C/C++ data structures.

I was so pleased with the book, I emailed the author. If you use Lua, and especially if you are new to Lua, you won't be disappointed with this edition.
The Blue PiL - Review written on April 24, 2006
* * * * *
Rating: 5 out of 5
18 customers found this review helpful, 2 did not.

Reading the first PiL left us with that hard-to-believe-it-could-get-any-better impression.
But Roberto did it again and surprised us with another 5-stars gem!

The Lua language has evolved (a lot!) and version 5.1 brings new mechanisms such as a full modules/packaging support system, tighter control over garbage collection, new (minor but significant) syntax notations, all of which justify this second edition. For the 5.0 user the book also offers plenty of new examples, such as graph management, extensive string content manipulation and a complete multithreaded C system using different Lua states in each thread.

Lua itself would be a good enough reason to buy another book written by its creator, but PiL 2 is much more than one could expect. The book is full of brilliant solutions and tackles a wide variety of computing challenges, in the best Knuth style as hardly seen ever since.

The text not only shows spotless academic rigour and consistency, but it is also astonishingly clear, pleasant to read and carefully crafted and lapidated by a writer who learned English as a second language.

A bedside book!
Excellent book on Lua - required addition to the Reference Manual - Review written on March 18, 2006
* * * * *
Rating: 5 out of 5
2 customers found this review helpful, 1 did not.

The book Programming in Lua is an excellent book on the Lua language. It helps clear up many of the questions I had about entries and usage cases in the Reference Manual. The book also includes many examples that can be readily used by the reader.
Excellent book - Review written on March 04, 2004
* * * * *
Rating: 5 out of 5
19 customers found this review helpful.

Lua is a gem among programming languages. Its designers have commendably placed a high value on keeping the language small, readable and portable. The diminutive size and simple syntax of Lua, however, belie a very rich, highly factored and stable architecture. It is a fun language in which to program. Lua dovetails beautifully with lower level languages by means of a C interface, and its drum tight language processor and libraries are right at home in event-driven graphical applications as well as console programs.

The excellent book "Programming in Lua" by Roberto Ierusalimschy provides developers with a broad summary of the language. The author includes a myriad of small examples, each of which is well focused and easily grasped. Different solutions to a given problem are often accompanied by benchmark figures. Prof. Ierusalimschy has an educator's gift for finding the appropriate level at which to write, and readers will appreciate the conversational nature of his writing. Unlike many programming language books, "Programming in Lua" has a strong content-to-fluff ratio throughout.

The book provides valuable explanations of language and library features which even the careful reader of the Lua reference manual might miss. In addition, over twenty C library entry points are discussed (and, thankfully, indexed) which are not mentioned in the reference manual.

It is hard to conceive of a software project which would not benefit from using Lua, both as an embedded component and as a standalone interpreter of scripts. The book "Programming in Lua" is valuable for anyone with an interest in this lovely language.

A valuable multi-level book - Review written on February 19, 2004
* * * * *
Rating: 5 out of 5
27 customers found this review helpful, 1 did not.

Lua is a free scripting language with an interesting development history. It is a language that is gaining wider acceptance thanks to small size, readable syntax, expressive power, efficiency, ANSI C portability and easy two-way integration with C and C++. It is also useful as a data-description language that can be tailored to one's needs.

Written by the chief architect of the language, this book is aimed at programmers whishing to approach or to better understand Lua and the (often unsuspected) capabilities offered by a fully dynamic language.

Despite its deceptively small size (260 pages) and a plain, readable style with an eye-resting typesetting, "Programming in Lua" packs an impressive amount of information peppered with small, clear code examples to help digesting it; it reminds me of my favorite programming book: the K&R (Kernighan and Ritchie's "The C programming language"). It is a multi-level book that always gives something new at every reading.

Rather than offer a catalogue of functions (left to the downloadable reference manual), the book's four sections introduce capabilities, concepts and interesting techniques that may surprise programmers used to static languages.

The first section is devoted to the language itself, including not-so-common subjects like dynamic typing, multiple results, first-class functions, closures, iterators and coroutines. The following section shows how to build all sorts of data structures, from simple arrays and lists to packages and objects, using Lua's "tables" and the powerful idea of "metatables" that makes the language easily customizable.
The third section introduces the standard libraries (they are actually optional, e.g. in microcontroller applications) with special emphasis on the simple but versatile pattern matching capabilities.

The fourth and last section is different: aimed at system programmers, it explains in detail how to interface Lua and C, both to add new functions to Lua and to use Lua inside a C program (possibly called from programs written in other languages).

"Programming in Lua" covers version 5.0 of the language, which is now mature and stable. I am using Lua both as a general-purpose 'light' language for system tasks or small programs, and as an embedded language inside C++ applications: the combined power of the two languages is impressive. I liked this book a lot, I learned much from it and I've done it the honor of a place besides my well-thumbed K&R.

Your One Stop Lua Source - Review written on January 09, 2004
* * * * *
Rating: 5 out of 5
10 customers found this review helpful.

I found Programming in Lua a good complement to the resources already available online.

Roberto shows flair in his writing and his various points about the language are sustained by concise but clear (and many times entertaining) programming examples.

In my limited Lua experience I have come across information similar to the one presented in Roberto's book in other places too. However, the book organizes the concepts well, systematically and, perhaps more importantly, in a consistent style (not to mention that is also well indexed).

For the beginner Lua programmers it offers handholding, for the programmers with extensive C background it shows how to replace conventional C idioms with more efficient Lua ones and, finally, for the hardcore Lua people it offers those glimpses of Lua code honed to perfection.

At fewer than 300 pages the book manages to cover the entire language while emphasizing on doing things the Lua way. I only wished there were more goodies in the book but, then, it only matches Lua's footprint!

For those people caring for their collection of programming books, I found the book's graphics sleek and, well, Lua-ish. I personally ordered two copies, one to sit in my personal library besides Stroustrup and other sacred, and one to use as a reference at work.

As a professional with many years of programming experience I recognize value in this book and recommend it to anyone that programs or wishes to program in Lua.

Marius Gheorghe

Software Team Leader
CableTest Systems Inc.
www.cabletest.com

Let the revolution begin - Review written on December 16, 2003
* * * * *
Rating: 5 out of 5
72 customers found this review helpful, 3 did not.

The Lua programming Language has been around for a while but this book by Roberto Ierusalimschy will be a mark in its history. The book managed to surpass every expectation I had for it, and I was eager! From someone with no Lua knowledge to those with Lua klocs in their backs, this book will be a great companion in a nice to read trip down the Lua 5.0 lane.

The book begins with the basic Lua elements and structures and then advances through control structures, functions, iterators and coroutines. Iterators and coroutines are one of those language features that may confuse the first timers, but the author manages to show the concepts and inter relations between them in a way that clarified the issues even for a seasoned Lua programmer. Alas, make no mistake, the whole first part is totally worthwhile for non beginners.

The second part of the book shows one of Lua biggest assets: tables and metatables. I've seen people sneer at Lua at first glance and then convert themselves to Lua evangelists simply for the features of tables and metatables. The author does his magic and makes a whole set of apparently complex concepts flow by the reader as fluid and logical as they can be.

By the way, fluency is arguably one of the major benefits of this book. The reader is taken from substrate to substrate of the Lua way of life without even taking notice. Every end of chapter left me with the satisfaction of having been presented with one more facet of Lua and with the tranquility that everything was falling in place at the right timing.

After tables and metatables, the book presents the concepts of Packages and Object Orientation in Lua. If you had any doubt ever that Lua was able to sustain "real" Modular/OO programming, be prepared to replace your dogmas. The book not only clarifies how to do it in Lua but also shows how easy and clear the coding gets.

The author ends the second part of the book with a great chapter on Weak Tables. I have to admit that I was somewhat refractory to Weak Tables before I read this book, but after this single chapter I was converted. May the name "weak" not influence your judgment on those Weak Tables. They are great, and the book showed more about them than I was expecting.

The third part of the book focuses on the standard libraries. Those would be the Table, String, I/O, Operating System and Debug libraries. Instead of repeating the contents of the Lua reference manual, the author manages to show lots of new information about the libraries by the use of examples and clear explanations. There are some points in Lua that can indeed be quite idiosyncratic at a glance, but this book is more than enough to clarify every one of them.

The fourth and last part of the book brings us the Lua C API. For the beginner Lua programmer this part will probably be skipped, but for the average programmer and most of all for the hardcore Lua explorer, this part will be pure delight. C programming is not for the faint of heart, but having a Lua interface for your C library is akin to the jackpot of embedded languages in my opinion.

This part of the book shows that the task of wrapping C code for Lua is not only feasible, but easily done once you grasp the fundamentals. Have one thing in mind, this was no small task for the author. Describing such an plethora of resources and how to use them in six chapters demands a clear yet straight to the point approach, and once again the book shines through.

Step by step the author shows how to deal with the Stack, to get arguments from and return values back to Lua, to handle tables (even those big ones), to call Lua functions from C code, to call C functions from Lua code, to handle strings, to handle state (using the registry, references and upvalues), and last but not least to use userdata types and metatables in C.

The last chapter of the book brings two examples of the use of the C API, one offers a directory iterator and the other a really nice example of binding an existent library (expat) for Lua use. Lots of my questions on the C API were dismissed with those two examples.

I should also reserve a praise for the book index. Not only I've found it complete but it is easy to understand some details of the Lua structure only by glancing at the index pages.

Conclusion

Being one of the first readers of this book was not only a great honor but also a great surprise. As a Lua old timer, I wasn't expecting to be presented to so many novelties, subtleties and jewels of programming in almost every chapter. Was I wrong...

If you have not seen Lua until now, this book is THE starting point.

If you are acquainted with other versions of Lua but have not studied version 5.0, this book is a great shortcut for your new endeavors.

Finally, if you think Lua is your native language and no book could teach you something worthwhile, think again. I was grateful I didn't skip not even one paragraph.

We've got the language. We've got the book. Let the revolution begin... :o)