Slashdot Mirror


Programming in Lua 2nd Edition

Andre Carregal writes "In the second edition of Programming in Lua Roberto Ierusalimschy presents the Lua programming Language in a simple yet precise format for both novice and advanced programmers." Read the rest of Andre's review. Programming in Lua, 2nd Edition author Roberto Ierusalimschy pages 328 publisher Lua.Org; 2nd edition (March 5, 2006) rating 10 reviewer Andre Carregal ISBN 8590379825 summary Shows how Lua is the language of choice for anyone who needs a scripting language that is simple, efficient, extensible, portable, and free.

The Lua programming language has been around for more than 10 years, but only recently has it started to appear on the mainstream radar screens. It has evolved from a simple scripting language to a full-fledged solution for scripting and embedding. Lua is portable, fast and small, and the language of choice for applications as diverse as games, Web sites and robot controllers as the Lua Users Wiki and LuaForge will confirm.

Lua portability can be shown by the long list of operating systems it runs on, which includes not only Windows and Linux, but also small systems and mobile devices. The memory and CPU requirements for the runtime are really low, and Lua has been used in environments that most other scripting options would not dare go into.

One of the milestones of the history of Lua has been the release of the book Programming in Lua (a.k.a "PiL"), by Roberto Ierusalimschy, in 2003. This review is about the second edition of Programming in Lua, a.k.a. the "Blue PiL" due to the color of its cover.

Lua is free software and can be obtained from its site (www.lua.org). There you will also find the reference manual of the language and the full contents of the first edition of Programming in Lua.

As a disclaimer, let me say that I'm one of the technical reviewers of the book and I have been working with Lua since 1993, most of the time interacting with Roberto Ierusalimschy, even when not working in the same projects as him.

The second edition manages to surpass an already good book in various aspects. The "Blue PiL" presents not only the language itself, but also gives an excellent view of how one could see Lua as the foundation of solid scripting techniques. The original Programming in Lua was focused on Lua 5.0, while the second edition focuses on Lua 5.1. While the differences between Lua 5.0 and 5.1 are not radical, the newer version has a lot more to offer, both in terms of the modularity aspect and of language features. The second edition of Programming in Lua indicates clearly when some concept or detail relates only to a specific version of Lua, but most of the contents can be applied to both Lua versions.

Programming in Lua is oriented to both the novice programmer who wants to get a first feeling for Lua, and to the advanced Lua or C programmer who wants to use the full potential of the language. The book clearly separates the two aspects and indicates the sections that can be skipped for each reader profile. The author manages to keep a light and easily readable style during the whole book and the examples are simple and direct, making the flow of the reading quite pleasant. I can say that, even having some reasonable experience with Lua, I was surprised by a lot of details in the book. The "Blue PiL" is one of those books that you can read many times over, and each time you learn something new.

The "Blue PiL" starts with an overview of the Lua language and slowly evolves through the more advanced concepts and the features that make Lua such a unique language. Even though it's a relatively thin book, it goes from the starting concepts to the more sophisticated ones with a grace that is really rare to find. The one other book that comes to mind with an effect like this is the classical Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Jay Sussman, which says a lot.

The first part of the book presents the language and the basic features. In particular, concepts such as iterators, coroutines and closures are presented in a clear way, which is no small feat considering that many readers will be having contact with such concepts for the first time.

One of the strong points of Lua is its simplicity, but don't assume that this implies lack of power. An example of this balance is the table data structure, in fact the only data structure for Lua. Tables allow the construction of every other data structure (arrays, sets, bags etc) but also allows the use of sophisticated techniques such as metamethods, function environments, modules and object orientation.

In fact, instead of providing every feature one might want to use, Lua provides the meta mechanisms so you can create your own features, or use them as modules created by third parties. In order to explain the full power of these meta mechanisms the second part of the book takes the reader from the basic steps of creating a table and shows how each of the mechanisms can add features or help the usage of some advanced concepts.

As an example, the chapter on object-oriented programming not only shows how to use objects in Lua, but also how to think of objects as prototypes for other objects, and how to implement inheritance on such a model without using anything too fancy.

There are also chapters on the use of metatables (basically tables that define the behavior of other tables), the use of tables as function environments (a really powerful mechanism once understood), modules and finally weak tables. Weak tables allow the advanced use of memory resources in an automatic way, providing mechanisms for data structures that tend to be hard to implement in other languages, if even possible at all.

This slow but efficient presentation of concepts that, though complex, can be easily assimilated by the reader is a predominant aspect of Roberto's work. He is not only a skilled author but also knows how to present things in a way that a novice can grasp and an expert can master.

The third part of Programming in Lua covers all the language libraries (math, table, string, system, debug and I/O) in clear prose and shows that even with a small set of libraries Lua can pack a lot of power on a very small footprint.

Finally, the last part of the book is directed to programmers that want to use Lua to its full potential. Lua can be used as an extension language or as an embedded language, and knowing how to interact with the host language (C, C++, Java, Delphi etc.) is mandatory for that. The book presents the C API for Lua in the same progressive pace, but also manages to cover every ground needed so one can add Lua to a project without much pain, if any.

One important thing to note about the book is that it follows the same philosophy that guides the language, showing that simplicity and lightness has nothing to do with lack of power or coverage.

I really recommend this book to anyone interested in learning Lua, and also for those who already know how to use Lua but would like to fully master its way of thinking, the so called "Lua way" of doing things. The book has been considered by many as an excellent guide on programming, even if one is not interested in Lua in particular."

You can purchase Programming in Lua, 2nd Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

131 comments

  1. As opposed to... by Anonymous Coward · · Score: 2, Funny
    > "Roberto Ierusalimschy presents the Lua programming Language in a simple yet precise format for both novice and advanced programmers."

    Of course, if you grew up with a last name like "Ierusalimschy", reading Perl aloud is probably pretty old hat for you. For that matter, so are APL and Brainf*ck.

    1. Re:As opposed to... by k4_pacific · · Score: 5, Funny

      Yeah, no kidding, Ierusalimschy isn't a name, it's a bad Scrabble hand.

      --
      Unknown host pong.
    2. Re:As opposed to... by hesiod · · Score: 0

      > Ierusalimschy isn't a name, it's a bad Scrabble hand.

      Actually, to get that you would have to be cheating... badly.

    3. Re:As opposed to... by Anonymous Coward · · Score: 0

      Forgive my ignorance, but is it pronounced "Yerusalimschy" or is the I pronouced as a "J"?

    4. Re:As opposed to... by illegalcortex · · Score: 1

      One of the best MST3K lines (and one of the most useful in real life) ever!

    5. Re:As opposed to... by TeknoHog · · Score: 1

      We are not amused. The name looks like it's related to Jerusalem, it just looks a little odd in English due to the particular transliteration (cf. Iesus, Iehova). There are countless other examples of family names based on cities, this is pretty much like "von Jerusalem".

      --
      Escher was the first MC and Giger invented the HR department.
    6. Re:As opposed to... by farker+haiku · · Score: 1

      You cheat, Dr. Jones!

      --
      Your sig(k) has been stolen. There is a puff of smoke!
    7. Re:As opposed to... by Raenex · · Score: 2, Insightful

      Who's "we", and when did they elect you to speak for them?

    8. Re:As opposed to... by TeknoHog · · Score: 1

      "We are not amused" is just a Monty Python way of saying "this is not funny". It was used in a sketch of Queen Victoria, who presumably referred to herself in plural. If you didn't recognize the line, please hand in your geek card on the way out ;)

      However, I also have a (Finnish) name that's pretty incomprehensible to English speakers, so I feel qualified to note when people make fun of something on the basis that they don't understand it.

      --
      Escher was the first MC and Giger invented the HR department.
    9. Re:As opposed to... by Raenex · · Score: 1

      Ah. I'm one of those anti-geek-establishment geeks who isn't into Monty Python. But besides that, I think you're being overly sensitive. The guy's last name looks funny to the average Slashdot reader. So what? I didn't detect any viciousness in the jokes.

  2. Perfect... by T.Louis · · Score: 2, Informative

    ... for the Burning Crusade expansion of World of Warcraft (Lua 5.1) and customized UIs!

    1. Re:Perfect... by jdray · · Score: 4, Interesting

      I really recommend this book to anyone interested in learning Lua, and also for those who already know how to use Lua but would like to fully master its way of thinking, the so called "Lua way" of doing things.

      Every time I see one of these "Learn Language X in Your Spare Time" book reviews, I wonder, "Why another language?" Advancement of languages is good, and "new" languages like Ruby are great, but how many programming languages are we as a community going to produce? Like text editors, it would be better to focus on fewer targets and add features than keep coming up with new "my toolbox grew so big I created a compiler for it" languages.

      Of course, I may just be trollish today. Hard to tell.

      --
      The Spoon
      Updated 6/28/2011
    2. Re:Perfect... by AncientWarrior · · Score: 2, Interesting

      Every time I see one of these "Learn Language X in Your Spare Time" book reviews, I wonder, "Why another language?" Advancement of languages is good, and "new" languages like Ruby are great, but how many programming languages are we as a community going to produce? Like text editors, it would be better to focus on fewer targets and add features than keep coming up with new "my toolbox grew so big I created a compiler for it" languages.

      I think that what you say really does apply to a number of languages -- python, ruby, php etc -- but lua really is something else -- small, elegant, and powerful, like scheme and C in their respective domains, but with some strikingly original constructs. Well worth the study.

    3. Re:Perfect... by Majik+Sheff · · Score: 1

      Lua has the same relationship with WoW Lua that Java has to Javascript. One is a powerful, flexible, modular language and the other is a braindead scripting language that happens to share keywords and syntax. I understand that Blizzard wants to keep security within the game solid, but it was a real exercise in frustration to learn what little can be done within the game's engine. You want to customize the UI? Fine. You want to do some interesting things with chat text? Go ahead. You want to step outside those two tasks? Good luck.

      --
      Women are like electronics: you don't know how damaged they are until you try to turn them on.
    4. Re:Perfect... by misleb · · Score: 1
      Every time I see one of these "Learn Language X in Your Spare Time" book reviews, I wonder, "Why another language?" Advancement of languages is good, and "new" languages like Ruby are great, but how many programming languages are we as a community going to produce? Like text editors, it would be better to focus on fewer targets and add features than keep coming up with new "my toolbox grew so big I created a compiler for it" languages.


      "Because different people prefer different text editors" would be the obvious answer to your question(s). Another possibility would be that some people want more control over how a text editor evolves, so they start their own. I imagine the same goes for languages. Some languages are better for different applications. I thought all this was pretty obvious.

      -matthew
      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    5. Re:Perfect... by flynt · · Score: 1

      If we use your technique, I don't think we'd have Ruby for instance. There are far too many different kinds of people and programming tasks and techniques to limit to a few. If no one uses a new language, it dies. I don't see the problem here, it seems we're better off having too many options than too few!

    6. Re:Perfect... by alienmole · · Score: 5, Insightful
      Like text editors, it would be better to focus on fewer targets and add features

      The history of programming languages shows that this is a good way to kill a language. Languages are a delicate balance between enabling you to express things, and preventing you from expressing things. You can't just throw the kitchen sink in there and expect the result to be usable. People design new programming languages because they perceive limitations in the ones they already know, limitations that often can't just be overcome by adding features.

      From a programmer's point of view, a good reason to learn a new language is to expand your mental horizons. It can be a passable substitute for actually studying computer science (which you clearly haven't done, if you're asking "why another language?") Don't just learn an array of similar languages, like Python and Ruby. If you already know a popular OO language, then learn a language like Scheme, ML, or Erlang, or if you really want some nerdy metaphorical hair on your chest, learn Haskell (although you might want to start with one of the others first). Then you'll understand "why another language".

    7. Re:Perfect... by Cthefuture · · Score: 4, Insightful

      For starters Lua is older than Ruby so be sure to point your finger in the right direction. Lua was already at 1.0 when Matz starting thinking about Ruby.

      But Lua is different than those other languages anyway. It's extremely small, both as a language and as a binary. It's also easy to embed anywhere you need it. And finally it's pretty fast as far as dynamic languages go.

      Lua doesn't get enough credit these days. It's used in tons of products (especially games) but most of the time people don't realize they are using it.

      --
      The ratio of people to cake is too big
    8. Re:Perfect... by Bill+Dog · · Score: 1

      You've made the argument for learning another category of languages, not another language. Unless Lua is such a paradigm shift that it warrants its own, new category, then the GP's question remains a good one: Why another language?

      I was thinking "why another scripting language", but I don't know bupkis about Lua. But the problem is one can only be truly fluent in a couple or four languages, at a time. Outside the few that I have the chance to maintain high levels of expertise in, code that I write in any others is going to be, on average, pretty mediocre. This can manifest as inefficiencies, due to the way it was coded, or just awkwardness in the code, or sometimes crossing paths with a language "gotcha" (what people call it when they're personally unfamiliar with a particular language feature) resulting in a bug. We have finite mental abilities and can really only write high-quality code in the few languages we've chosen to specialize in (and some of us don't even do that), so do we really need yet another language vying for our attention and use?

      --
      Attention zealots and haters: 00100 00100
    9. Re:Perfect... by jdray · · Score: 1, Interesting

      I have to admit that I don't know from shineola a thing about Lua. The book review didn't do anything to compel me to find out more, though, and that's unfortunate if Lua is such a wonderful thing to behold. It's not necessarily the job of a writer of a book review to educate his readership about the subject of the book in question, but a short paragraph telling me in a few sentences why I should care about Lua might make me more susceptible to his argument that it's something I should rush right out and buy. If I don't care enough about the language by the time I get to the end of the review, I'm not going to put enough effort into finding out more to even Google it.

      In my too-many years of being an IT professional, I've never been much of a programmer. I've dabbled with several languages, but left the serious work up to those with enough time on their hands to do it right. What I, as someone who spends more time gluing disparate applications together than developing new ones wants is a language that does the things I need it to today and will grow with the changing requirements of my job and information technology in general. Perl is great for a huge number of things, and a lot of what I do I choose Perl for. But give me a requirement to cobble together a GUI-based app, and I'm going to use VB.NET (I have to say that I feel like with .NET, VB has arrived at being a clean and useful language). I'm interested in Ruby because it's more cleanly object oriented than Perl, but I'm not going to put a bunch of effort into learning it because I don't see that it really adds anything to my capablities.

      I guess I keep reading these book reviews in hopes that one day one will say, "Here's the language you need: It scripts well, compiles into binaries that are portable across platforms, produces GUI-based apps that bolt easily to databases, and is fast to code in. Oh, and this book tells you all about it in an easy-to-read format that will have you coding basic apps quickly and carry you through advanced concepts. Oh, yeah, and it's written assuming that the reader doesn't need to know what a variable is and how you can use one."

      I suppose it's a lot to ask. I'll keep reading, though. And I'm going to look into Perl 6. Yeah, that too.

      --
      The Spoon
      Updated 6/28/2011
    10. Re:Perfect... by T.Louis · · Score: 1

      Yes, you are right it is restricted. But it is a game, it is not about who can write a macro/bot with a nice UI controller to play the game for you right? And besides, if you think it is that limited, go and download some of the more popular UIs and look at the creativity that flows from being constrained by such crap. My initial comment was sarcasm, maybe it was misunderstood, maybe not. T

    11. Re:Perfect... by alienmole · · Score: 1

      I answered the original question in a general way, because it was stated generally, i.e. "Why another language". In Lua's case specifically, it has borrowed important features from Scheme and Icon, so for those who insist on only learning popular languages with familiar syntaxes, it might be a way to gain familiarity with some interesting capabilities that you won't find in standard Python, Ruby, or Java.

      But I don't think anyone is arguing that you should learn Lua specifically just because it's there. You might learn Lua if you're looking for a lightweight embeddable scripting language, in which case it's one of the better choices available; or if you're working with one of the systems in which it's already embedded, in which case Lua is a foregone conclusion. So the answer to the question you seem to be asking, which is why does Lua even exist, is that it fills certain needs better than most of its competition. That doesn't mean everyone should learn it.

      The even more general answer to the question of "why another language" is that languages are incredibly multi-dimensional constructs, and each of their many features interact in subtle ways, impacting everything from the way code can be expressed in a language, to the characteristics of an implementation. For example, the features of Lua impact the size of its implementation, which affects how easy it is to embed in another application; and those features are well-chosen to match the needs of the embedded scripting environment. At the same time, the list of things that Lua doesn't have built-in support for is long, so there are many contexts in which you wouldn't choose it.

      If you've ever written a language, even a toy one for a class or for your own interest, you know that almost every feature you choose precludes other features, other ways of doing something. Some languages try to make this into a virtue ("there's only one way to do it", or whatever), but every language has its limits designed into it as clearly as its features. Saying "why another language" makes about as much sense as saying "why another type of food", "why another type of car", or "why aren't all humans just clones of Albert Einstein, or maybe David Hasselhoff".

    12. Re:Perfect... by jericho4.0 · · Score: 1
      I agree that most people are not capable of maintaing fluency in more than a couple languages, but nobody's making you learn this new fangled language and neglect another. Lua, Python, Haskell, and all the rest exist because they encapsulate something new, that goes beyond syntax. The ideas might turn out to be really dumb, or it might turn out to be very smart, and then we all run of and try these things in our favorite language.

      I hated the whitespace thing in Python, now I'm convinced that every language should do it. I used to think the TMTOWTDI philosophy was 1337 and allowed me to express myself better, now I think it's messy and confusing.

      --
      "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
    13. Re:Perfect... by Res3000 · · Score: 1

      But that's exactly the thing LUA in WoW should do. Change your UI, and change things in your chat. You aren't even allowed to do other things than that. And I honestly don't know what else I would do with it. I don't want it to play the game for me.

    14. Re:Perfect... by jdray · · Score: 1

      You might learn Lua if you're looking for a lightweight embeddable scripting language, in which case it's one of the better choices available; or if you're working with one of the systems in which it's already embedded, in which case Lua is a foregone conclusion.

      Okay, so you have me interested. Can you elaborate on just what an "embeddable scripting language" is? I mean, I have an idea, but go about it as if I have no clue. That will satisfy those that believe such.

      And, just to let you know, I feel like your argument is well written and compelling. That, combined with the fact that I'm feeling less trollish today, at least has me interested in finding out more, and I'll do a little research on Lua. I will say, though, that my argument against new languages that don't bring anything significantly new in architecture to the table (the way C++ did over C) applies equally to (insert new programming language here) as it does to the (thankfully short-lived in popularity) spoken "language" of Ebonics.

      Using your metaphor, the differentiation between Thai food and French food is far greater than between any two menu items at Taco Bell, particularly if your first compared item is the 7-layer burrito, which contains all but about two of their ingredients. It's one thing to start up a new cheap, fast food Tex-Mex restaurant because you want to provide a higher quality food or a different menu entirely, but putting up what's essentially a Taco Bell clone on one corner in downtown and offering an 8-layer burrito instead and Coke instead of Pepsi doesn't, to me, make a lot of sense.

      --
      The Spoon
      Updated 6/28/2011
    15. Re:Perfect... by Bill+Dog · · Score: 1

      ...but nobody's making you learn this new fangled language...

      Not yet. If it gets popular, I may have to, to maintain employability. I love programming and will stay current on things regardless, but it is a heavy load some times keeping up with the technology du jour. I'm a little older now, and am a little more picky about where I spend my time, and have acquired the perspective of not being too jazzed about learning something new that would not mean a quantum leap in capabilities for me. Even in my 20's I recall being a little ticked about having to move from Pascal to C, not because I didn't like C (I liked it better than Pascal), but because it was really a lateral move. Then from C/procedural programming to C++/OOP was definitely a worthwhile journey. Java and C# seem essentially redundant to C++, so I'm waiting for "the next big thing" in programming languages, hopefully something designed especially for writing concurrent systems.

      --
      Attention zealots and haters: 00100 00100
    16. Re:Perfect... by alienmole · · Score: 1
      Okay, so you have me interested. Can you elaborate on just what an "embeddable scripting language" is? I mean, I have an idea, but go about it as if I have no clue.

      It's a language that can be integrated into an application at the source code level, so that the language becomes part of the application and has access to all that application's internal structures. This allows you to easily write programs which control (or "script") the application. This is one of the most successful software development strategies ever invented: many well-known programs use the approach, which is not a coincidence, since having a scripting language makes a program much more customizable and controllable, which makes it more useful and more likely to succeed.

      Today, the most common example of an embedded scripting language is Javascript, which is embedded in web browsers. Games in particular have benefitted from this approach, because the scripting languages allow both the game developers and users to easily create new levels, implement new behaviors, etc. Unreal Tournament

      A few more classic examples are AutoCAD (Lisp), Emacs (Lisp), and The Gimp (Scheme). Those are all variations on Lisp for a reason: Lisp and its cousin, Scheme, are easy to implement, because they have a simple syntax and their features are built out from a small core. This means that the part of the language that's implemented in a lower-level language like C tends to be fairly small and focused, which makes it easier to integrate with an application. It also means that much of the rest of the scripting language is implemented in the scripting language itself, so the fact that the core language is small is not too much of a limiting factor, and it's often possible for users or third-parties to extend the language in significant ways, even without access to the main application's source code.

      Lua fits the bill quite nicely as a language which follows similar small-core design principles to Scheme, but with a more familiar syntax. That's part of why it's used in more than a dozen games (see its wikipedia entry).

      And, just to let you know, I feel like your argument is well written and compelling.

      Thanks! You're undermining your trolling credentials, though. ;)

      I will say, though, that my argument against new languages that don't bring anything significantly new in architecture to the table (the way C++ did over C) applies equally to (insert new programming language here) as it does to the (thankfully short-lived in popularity) spoken "language" of Ebonics.

      Me done agrees wif dat. However, usually by the time a new language is creating some buzz beyond its inventor's own hype, there's some reason that people are using it over the competition. You just have to figure out whether those reasons hold any interest for you. The question "Why another language for me?" can have a different answer than "Why another language?" in general.

    17. Re:Perfect... by jbolden · · Score: 1

      so I'm waiting for "the next big thing" in programming languages, hopefully something designed especially for writing concurrent systems.

      Don't know if you get emails for responses but... Erlang sounds like what you are asking for

  3. ref book online by Anonymous Coward · · Score: 5, Informative

    Every page has a donation or Amazon link...
    Anyways the ref book is online:
    http://www.lua.org/manual/5.1/

  4. Just what the world needs by Anonymous Coward · · Score: 0, Flamebait

    Just what the world needs, another 'toy' programming language, a solution in search of a problem. Toss this aside next to the java books. A cute theoretical analysis, but more or less useless in the real world.

    1. Re:Just what the world needs by vashfish · · Score: 5, Informative

      A toy programming language used (possibly unwittingly) by at LEAST 7,000,000 people, thanks to World of Warcraft...

    2. Re:Just what the world needs by Anonymous Coward · · Score: 0

      Hahahaha Java books excellent troll!

    3. Re:Just what the world needs by Anonymous Coward · · Score: 0

      LOL U R TEH RETARDZ

    4. Re:Just what the world needs by vashfish · · Score: 1

      O.o I was being ironic... or were you just quoting me for truth? If not, I direct you to http://forums.worldofwarcraft.com/search.html?foru mId=10001&characterId=118201689&sid=1

    5. Re:Just what the world needs by illegalcortex · · Score: 1

      Actually, I read that comment as mocking the obliviousness of the original post. But to each his own.

    6. Re:Just what the world needs by Anonymous Coward · · Score: 0

      More than that, since it is used in Far Cry, as well. Unlike some other famous FPS game mod toolsets out there, Lua doesn't choke on whitespace [if you're maintaining a code set for dedicated servers on multiple platforms, it's enough to make you want to kick someone in the face] and doesn't require a compiler [like some other famous modding toolset].

    7. Re:Just what the world needs by Anonymous Coward · · Score: 0

      Lua is used in tons of games, as it's well-suited for embedding.

    8. Re:Just what the world needs by Anonymous Coward · · Score: 0

      yeah, what kind of stupid toy language is that? I bet half of them don't even know they're using it!

    9. Re:Just what the world needs by UncleSocks · · Score: 2, Interesting

      Actually a really elegant embeddable language. On previous products I've created I've embbbeded TCL, Python, LISP and FORTH. Lua is more elegant and almost as small as a FORTH kernel. I assure you Lua is already in at least three very propular products.

  5. Moo by Chacham · · Score: 3, Interesting
    As a disclaimer, let me say that I'm one of the technical reviewers of the book and I have been working with Lua since 1993, most of the time interacting with Roberto Ierusalimschy, even when not working in the same projects as him.

    Disclaimer or not, should he be allowed as a reviewer?

    Hmm, the Review Guidelines state
    Important: If you have a relationship (other than as an ordinary reader) to the author or publisher of a book you're reviewing, disclose that relationship. This means not only cases like "My brother, the author, has given me a million dollars to type this review, and is holding me at gunpoint, while dictating to me from the Amazon review he himself wrote," but also "I used to work at this book's publisher, and was a technical reviewer for this book's three chapters on networking," or "The author is a good friend of mine." Better to disclose more than you think necessary (it can always be edited out if sensible; we'll let you know if we think there's an inappropriate conflict of interest) than less than actually necessary. If in doubt, please speak up.
    So, it OK according to the guidelines. Though, i'd wonder if someone so involved is a good person to actually write such a review.

    1. Re:Moo by Anonymous Coward · · Score: 0
      Why do most (if not all) of your comments start with "Moo"?

      Is this like Troll Tuesday (same concept)?

      I find it intriguing, and shall await your reply.

    2. Re:Moo by Rudisaurus · · Score: 1
      Disclaimer or not, should he be allowed as a reviewer?

      [...]

      So, it OK according to the guidelines. Though, i'd wonder if someone so involved is a good person to actually write such a review.
      I do not understand your comment: "Disclaimer or not". That's precisely why the disclaimer is there -- so that you can make up your own mind about the reviewer! You are a perfect case-in-point! Without the disclaimer, you wouldn't have a clue about the reviewer's past relationship with the author. This way you can decide for yourself whether or not he has any credibility in your own eyes. And the rest of us can too!
      --
      licet differant, aequabitur
  6. Blue PiL by TranscendentalAnarch · · Score: 1

    But, I want to see how deep the rabbit hole goes!

  7. hello world by DohnJoe · · Score: 5, Funny

    as a short introduction to the LUA language I present here the code for a hello world app:

    print "Hello world"

    hope that helps...

    1. Re:hello world by Shados · · Score: 4, Funny

      Thanks, now with this newfound knowledge in mind, I can add on my resume "Intermediate LUA developer"

    2. Re:hello world by jhoger · · Score: 2, Interesting

      No it's
      print ("Hello, world.")

      Reader's Digest guide to Lua:

      -1) I believe it's 'Lua' not LUA
      0) You need the parentheses on function calls.
      a) Only data structure is hash tables
      b) Hash tables with positive integer indexes emulate arrays (order is maintained)
      c) Positive integer indexed hash tables are one-based. Gawd. This makes for some serious unpleasantness if you want to embed Lua in your C application, since many real world things are 0 based and probably all the patterns you know for writing proper loops in C are zero based. They wanted to make things simple, but they got this one dead wrong. Someone should make a zero-based fork.
      d) No continue statement for loops
      e) No semicolon separator
      f) Iterators
      g) Cool cooperative multitasking support
      h) Closures
      i) An extremely quirky stack based interface to C. Some api's pop their arguments some don't. They should do it the Forth way (words consume their arguments) or not automatically pop anything. Pick one, not both. And please, some simple stack operators (swap, drop, dup, roll, etc.)
      j) Perlish do-it-yourself objects
      k) Not-quite-regex string processing support. Come on, at least make it a subset of proper RE's, don't put a new syntax.
      l) Implicit dereferencing

      I'm probably missing something...

      -- John.

    3. Re:hello world by kristoferkarlsson · · Score: 1

      You got a few things wrong:

      0) You need the parentheses on function calls.
      False, f("a string") is equivalent to f"a string" and f({a = b}) is equivalent to f{a = b}

      a) Only data structure is hash tables
      False, lua tables contain both a hash table part and a pure array part. The runtime figures out how to store stuff internally. As a lua programmer, you never need to care, but if you're only using positive integer keys between 1 and N, with few gaps, it will most likely be stored as an array.

      e) No semicolon separator
      False, there is a semicolon seperator, but in most cases, you don't need it. a = 4 b = 6 can only be interpretered in one way so you don't have to write a = 4; b = 6, even though you can, if you want.

      i) An extremely quirky stack based interface to C. Some api's pop their arguments some don't. They should do it the Forth way (words consume their arguments) or not automatically pop anything. Pick one, not both. And please, some simple stack operators (swap, drop, dup, roll, etc.)
      Lua's popping of arguments is not really a problem, just read the manual, it's very clearly described how they behave. Also lua does have lots of stack operators, see the manual. lua_pushvalue(L, -1) would correspond to a dup. lua_insert(L, -2) would correspond to a swap. If by drop you mean pop off elements from the stack, see lua_pop. I couldn't find a roll operator, but that is just a series of inserts anyway. Other interesting stack operations are lua_remove, lua_replace. I am sure you can find enough stack operators to get by.

    4. Re:hello world by Wulfstan · · Score: 1

      Some other little gotchas:

      m) No built-in Unicode support (Waaak! How can a modern language not support a wide string type!)
      n) Variables are global BY DEFAULT and not local. To declare a local variable you have to say local foo = "blah".

      --
      --- Nick, hard at work :->
    5. Re:hello world by YA_Python_dev · · Score: 1
      No it's
      print ("Hello, world.")

      The GP code works fine:

      Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio
      > print "Hello world"
      Hello world
      >
      --
      There's a hidden treasure in Python 3.x: __prepare__()
    6. Re:hello world by jhoger · · Score: 1

      I'll grant that 0) is ok, you taught me something. But really, it's a narrow point. There are only two cases (single string parameter or single table constructor argument) where you can leave out the parens, unlike Perl where the cases where you must use parens are the exception. So you get in the habit of always putting them.
      For a) I maintain my statement; the Lua abstraction is an associative array (commonly called a "hash" by Perl programmers). Efficient use of positive integer indexes is a nice optimization though.
      I believe I've seen cases where the ; causes problems so I leave it out.
      As to the stack interface: I understand (and am using) the API, I just find it amateurish. You don't seriously think that lua_insert (L, -2) is as clear as swap (L) do you? It makes for hard to understand, write-only code for dealing with parameters. Also, sometimes you can use pseudo stack indices sometimes you need real ones. I'm not talking there about "getting by," of course you can get by. The problem is that it doesn't make for readable, maintainable code.

  8. Book's cheaper through there too by Anonymous Coward · · Score: 0

    And considering that Amazon has the book for cheap, and the project favors it, it's ridiculous that Slashdot links to the always overpriced B & N.

    1. Re:Book's cheaper through there too by 70Bang · · Score: 1


      B&N?

      Addall.com
      BookPool.com

      Addall will reference Amazon stores and it's not difficult to find a brand new (or "like new", etc.) book. It's like being able to purchase the previously college textbook, but at a discounted price. If I buy books online, I go to those two as a rule.

      I suppose some people go to other sities such as OverStock there with other things in mind; e.g., Showing the luscious MILF Sabine Ehrenfeld your "O" face.

  9. Re:f1rst! by Anonymous Coward · · Score: 0

    Cracky-Chan Up, Mercatur Down!

  10. Plua: Lua on a Palm Pilot by HoneyBeeSpace · · Score: 3, Informative

    If you want to geek out a bit and program Lua on your Palm, you may do so: http://netpage.em.com.br/mmand/plua.htm

    1. Re:Plua: Lua on a Palm Pilot by Raenex · · Score: 1

      Or even geekier, on your DS.

  11. Re:DOA - the license sucks. by planetoid · · Score: 4, Insightful

    How so? Last I checked, anyone is free to modify Lua to their heart's content and include the modified Lua VM in their program, and they can choose whether or not to release the source. That's even more free than what the GPL states, if you consider Lua's domain. Remember, Lua has been and is still used by many game developers who don't necessarily want modifications done to their games (or at least to their games' code, if not the data), and Lua would probably have failed in that market if it had a restrictive, bossy license like the GPL behind it. Lua is anything but DOA.

    --
    Slashdot requires you to wait longer between hitting 'reply' and submitting a comment.
  12. Programming *in* the Lua by Blrfl · · Score: 5, Funny

    Read the article again, and this time remember that "lua" is a word the Hawaiians use for the bathroom.

    1. Re:Programming *in* the Lua by Anonymous Coward · · Score: 0

      It also means "Moon" in portuguese (the author is brazilian)

    2. Re:Programming *in* the Lua by Anonymous Coward · · Score: 0
      Read the article again, and this time remember that "lua" is a word the Hawaiians use for the bathroom.

      That's because the Ferdinand Magellan, the Portuguese explorer who first circumnavigated the world, felt a sense of urgency after a delicious feast provided by the Hawaiian natives, but didn't know the word for bathroom. Of course they didn't understand Portuguese, so the word "banheiro" meant nothing to them. Recalling the crescent moon usually carved on outhouses, he thought that perhaps "Lua!" might ring a bell. They were still puzzled, of course. In frustration, he cried, "LUA! LUA!", thinking that if he just said it loudly enough, he could make them understand. The natives thought it was so funny that ever since that day, bathrooms have been called "lua lua" in Hawaii.

    3. Re:Programming *in* the Lua by J053 · · Score: 1
      Nice story, except that Magellan is not known to have visited Hawaii. The first European known to have landed in Hawaii was James Cook in 1778 - well after Magellan's voyage in 1519-1522.

      Lua in Hawaiian has, as primary meaning, a hole, pit, or crater - specifically, a hole that has a bottom (vs. a "bottomless" pit), and contrasting with puka - a hole through something. The secondary meaning of lua has been "toilet" since well before the Europeans discovered the Islands.

  13. O rly? by Anonymous Coward · · Score: 0

    Who cares.. we need more submissions about blatantly homosexual WoW characters.

  14. Celestia by Fallingcow · · Score: 4, Informative

    If you need a reason to learn Lua, look no farther than Celestia.

    Lua is the more powerful of the two scripting languages that can be used with Celestia. You can do some awesome stuff with it, and there are lots of examples on various forums (fora?) devoted to Celestia scripting. Good times.

  15. lua uses by Anonymous Coward · · Score: 3, Informative

    http://www.lua.org/uses.html list an impressive amount of project (many of them games) using lua.

  16. Re:DOA - the license sucks. by aardvarkjoe · · Score: 1

    More to the point, given that Lua is widely used, only an idiot would try to claim that Lua is "DOA" because of its license.

    --

    How can we continue to believe in a just universe and freedom to eat crackers if we have no ale?
  17. data description language; Lua vs Guile by bcrowell · · Score: 1

    Although Lua's killer app seems to be as a scripting engine for games, it's also a good general-purpose data description language. I used it for that purpose, for a little database where the alternative would have been a csv file, and it worked out well. I would also be interested in people's thoughts about Lua vs Guile. They're both used as scripting engines for a lot of open-source apps, and they're also both good data description languages. Would the main difference be speed? Performance? Licensing? Portability? Personal taste in syntax?

    1. Re:data description language; Lua vs Guile by Bluesman · · Score: 1

      I don't know anything about Lua, but portability is a concern for me. I don't use guile because it's next to impossible to compile a recent version on Windows with MinGW, when it should be a piece of cake.

      It's a shame, as I'd really like to be able to use it. But an "extension" language that isn't as portable as the GUI toolkit I'm using (QT) isn't worth the effort IMHO.

      From what little I've read, Lua seems as if it would be a bit more portable.

      --
      If moderation could change anything, it would be illegal.
    2. Re:data description language; Lua vs Guile by 91degrees · · Score: 1

      From what little I've read, Lua seems as if it would be a bit more portable.

      Written in very clean C. Tried it with half a dozen compilers and not so much as a warning. If your platform has a C compiler, lua will probably work.

    3. Re:data description language; Lua vs Guile by Bastian · · Score: 1

      Lua is definitely more portable, and it's easier to get it to talk to other languages. I had originally looked at Guile for my current app (which does the heavy lifting with Objective-C), and decided against. Judging from the small number of Guile bridges, it looks like Guile doesn't play so nice with languages that aren't substantially similar to C, and even then there seem to be a lot of conditions and complications floating along the boundary between it and C.

      Lua, on the other hand, is happy to run on anything from mainframes to toasters. It also has a number of existing bridges, many fewer of which seem to have been orphaned by their maintainers.

      The language itself is a solid alternative to Sheme, too: It has enough functional-y features (first class functions, closures, reflection, etc.) to keep me happy, while also being designed well enough to handle other programming styles without getting unwieldy. It's really rather similar to Sheme in that it's a small language with just enough of a feature set to make you do large things. It does other things more nicely, too - implementing an ADT with tables involves a whole lot less boilerplate code than doing it with lists, for example.

    4. Re:data description language; Lua vs Guile by SimHacker · · Score: 2, Informative

      Absolutely: The Lua interpreter source code is very clean and well written, and wonderfully portable and platform agnostic.

      Here's the source code that you can view online -- there isn't much to it! Four global header files, 19 core C files, 19 core header files, 10 library C files, 1 interpreter C file, and 2 compiler C files. Here is the main loop of the virtual machine -- notice that there are only 38 opcodes!

      A great example of some interesting code written in Lua is the Auctioneer add-on for World of Warcraft (screenshots, manual). Here's the index of the Lua sources, and an interesing Lua file that calculates statistics on auction items. This code depends on features provided by the WOW client (implemented in C++ or whatever), as well as other Lua scripts loaded into the client.

      One important reason to learn and consider using Lua, is that it's by far one of the fastest and smallest of all the interpreted scripting languages, on the Programming Language Shootout. It totally smokes most other scripting languages.

      Here are the ratios of interpreted languages compared to compiled C code, in order of SPEED (the number is how many times slower it is than C, smaller is better unless you make your living by wasting time):
      Lua: 6.4; Python: 7.4; Pike: 8.3; Tcl: 8.7; Perl: 9.0; Scheme MzScheme: 11; PHP: 13; Icon: 14; Smalltalk GST: 15; Ruby: 16; JavaScript SpiderMonkey: 32;

      Here are the ratios of interpreted languages compared to compiled C code, in order of SIZE (the number is how many times bigger it is than C, smaller is better unless you make your living by selling memory):
      Lua: 2.5; Haskell GHC: 2.8; SML MLton: 3.4; Python: 4.1; Perl: 4.3; Tcl: 5.1; Icon: 5.4; Ruby: 6.0; C# Mono: 6.3; Pike: 6.8; PHP: 7.1; Oberon-2 OO2C: 7.9; Erlang HiPE: 7.9; Java JDK -server: 9.1; Scheme MzScheme: 9.2; Mozart/Oz: 9.8; Scala: 10; Lisp SBCL: 10; Smalltalk GST: 13; Smalltalk VisualWorks: 15; JavaScript SpiderMonkey: 30;

      Lua is even better than several compiled languages (like Java) when it comes to its size! Like Java, Lua also has a "just in time" compiler, but that was not used in these benchmarks (although I presume Java's was, because Java did very well with speed but not memory usage).

      I think it's laughable that someone would put their time into learning a faddishly popular language like Ruby, but would then not consider learning a technically superior language like Lua, since Ruby scores so badly on these benchmarks compared to Lua, Lua has been around a lot longer than Ruby, and it had already proven itself in many commercial products (like WOW).

      Lua really is far ahead of the pack of other languages in many ways, BECAUSE it's so clean and well designed. Plus its licensing terms are excellent, it's extremely portable, easy to embed and integrate with applications, and SWIG supports it well. So it's definitely well worth learning.

      -Don

      --
      Take a look and feel free: http://www.PieMenu.com
    5. Re:data description language; Lua vs Guile by belmolis · · Score: 1

      Lua is a nice language for some purposes, but it has two major limitations. One is that it has no regexp support. It has some limited pattern matching stuff that looks superficially like regexp matching but isn't. This is intentional, in order to keep the footprint small. For game programming you probably don't need regular expressions, but it makes Lua much less suitable than Tcl, Python, or various other scripting languages for anything involved string processing.

      Secondly, Lua does not support Unicode, which is a defect not only for text processing but for anything requiring serious localization.

    6. Re:data description language; Lua vs Guile by Fred_A · · Score: 1

      While there may be lots of reasons to use Lua and the language may have lots of qualities, this kind of argument is on par with saying Lua is better becase there are fewer "Lua sucks" pages indexed on Google than " sucks" so it *just* has to be better.
      A language shouldn't be used "because it's better than language x" but because it's better for a task.

      I certainly haven't been converted over.

      Anyway since all your benchmarks compare everything unfavorably to C, you should be using C by your own metric. Smaller, faster, portable (mostly). ;)

      I'll stick to Perl and Python for the few dozens of code I have to output every now and then.

      --

      May contain traces of nut.
      Made from the freshest electrons.
    7. Re:data description language; Lua vs Guile by Anonymous Coward · · Score: 0

      > The language itself is a solid alternative to Sheme, too:

      Yeah, quite a numeric tower it has, eh?

      I mean, it's a nice enough language, but come on.

    8. Re:data description language; Lua vs Guile by bcrowell · · Score: 1

      I think it's laughable that someone would put their time into learning a faddishly popular language like Ruby, but would then not consider learning a technically superior language like Lua, since Ruby scores so badly on these benchmarks compared to Lua, Lua has been around a lot longer than Ruby, and it had already proven itself in many commercial products (like WOW).
      That's a total apples-and-oranges comparison. I've used both Lua and Ruby, and liked them both, but there's very little overlap between the tasks I'd consider doing in Lua and the ones I'd consider doing in Ruby.

    9. Re:data description language; Lua vs Guile by SimHacker · · Score: 1

      I gave several reasons why Lua is better than Ruby, for many tasks. Most tasks consider speed and memory usage to be important. Also, Lua is much better than Ruby when it comes to embedding it in an application (like World of Warcraft does). And Lua is also very easy to extend the language with C or C++ code and libraries written in other languages, which is useful for a wide range of tasks. And the fact that it's well written and well designed certainly doesn't hurt.

      I still love Python and use it regularly, and won't stop using it just because I learned Lua. It has a huge library of useful extension modules and libraries written in Python, that I wouldn't want to do without. But it's impossible to strip down Python so it's as small and efficient as Lua, so Lua is useful for a wide range of tasks on small devices that Python simply can't address. I have both Python and Lua on my PocketPC, but Python is much larger and doesn't leave room for much else, while Lua is far more practical for developing scriptable applications on small devices, than Python.

      Don't even get me started about how horrible and badly designed Perl is, but it's practically useless as an embedded extension language, or on small devices. The only task Perl is really good for is maintaining job security for unethical programmers of indecypherable spaghetti code.

      -Don

      --
      Take a look and feel free: http://www.PieMenu.com
    10. Re:data description language; Lua vs Guile by Bastian · · Score: 1

      The grandparen't wasn't saying that Lua's speed on these benchmarks alone is why Lua is the greatest language or anything. However, it does make Lua worth caring about. There are plenty of other reasons to like it - it's a fairly clean language, and in situations where maintainability matters it's probably preferable for a lot of people who don't like, say, perl's terseness and tangled syntax. It's a reflective language, which makes it useful for some more complex tasks than some other scripting languages.

      Of course these aren't reasons why Lua is categorically better than other languages - perl is my first choice whenever I need an extraction and reporting language, C is still my first choice when performance matters, ObjC when performance matters a bit more but not as muc as in C (though in both those cases it's common for me to be working with an embedded scripting language, too), C++ if the gods turn sour on me and I end up having to be able to work with C++ libraries, postscript for dicking around in printers, etc.

    11. Re:data description language; Lua vs Guile by bit01 · · Score: 1

      Secondly, Lua does not support Unicode, which is a defect not only for text processing but for anything requiring serious localization.

      That's a showstopper for me. In this day and age no language that claims to be general purpose should be without UTF-8 support. English+ASCII covers only a fraction of the world's languages.

      ---

      The patent mafia: When all they've got is a hammer, everything looks like a nail.

    12. Re:data description language; Lua vs Guile by Bastian · · Score: 1

      Yeah, quite a numeric tower it has, eh?

      They address this issue in the book's section on numbers.

      It's a scripting language that was designed toward the end of the 20th century. It doesn't need all sorts of integers and whatnot. If you need to care that much about speed, memory consumption, etc, you shouldn't be using an interpreted language in the first place. In the domain for which Lua was designed, tall numeric towers are rice.

    13. Re:data description language; Lua vs Guile by vashfish · · Score: 1

      Secondly, Lua does not support Unicode, which is a defect not only for text processing but for anything requiring serious localization. Misinformation at its finest. *sighs* Lua is natively UTF-8 compatable. It does choke on the BOM in source files, but that can easily be fixed.

    14. Re:data description language; Lua vs Guile by belmolis · · Score: 1

      Unless you've got more up-to-date information than I have, Lua in fact does not support Unicode. It is true that you can kind of, sort of, manipulate Unicode strings in Lua, but to call this ability support is unwarranted. Here is the discussion of the topic from the Lua Users' Wiki. It says that the length functions do not return the number of characters in a string, only the number of bytes. It says that Lua's built-in pattern matching does not work on Unicode. It says that there is no notation that allows you to specify a Unicode character without hand-encoding it in UTF-8 and specifying each byte - you can't write something like "\u0561" in a Lua program to get the character U+0561 Armenian letter ayb. It says that Lua does not perform Unicode normalization for you, so unless you can guarantee that your strings are appropriately normlized, Lua will not determine string equality correctly and you will not be able to use Unicode strings as table keys.

      I submit therefore that Lua does not support Unicode in the sense that languages like Tcl and Python do. It is much easier to work with Unicode in those languages than in Lua.

  18. It is an excellent book by mhackarbie · · Score: 4, Informative
    I don't have any association with the author or the other creators of the language, so perhaps my opinion will add some legitimate support for the book and the language. I developed my previous project (Ribosome Builder) 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 completely agree with the reviewer's assessment. It's 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 Blue PIL.

    mhack

    --
    Building a better ribosome since 1997
    1. Re:It is an excellent book by imbaczek · · Score: 1

      Python is generally easier to extend than embed; Lua is different in that it's designed to be embedded.

    2. Re:It is an excellent book by rucs_hack · · Score: 1

      Lua has one major advantage over Python, that is it's use in a number of very populer mainstream games. Supreme commander uses it, and that may be enough to get it more populer.

      populer != best, but best is a relative term. Fit for purpose is more relevent. I do like python, but I'm starting to apreciate what lua enables in game modding, in so far as it involves the games I like.

    3. Re:It is an excellent book by smaddox · · Score: 1
      populer != best, but best is a relative term.

      Yeah, only a geek would think that being best at something is more important than being popular =P
  19. PiL is a great book by Anonymous Coward · · Score: 0

    Programming in Lua is simply one of the best books on programming I have ever read. It's "The C Programming Language" of Lua.

  20. Close... by Anonymous Coward · · Score: 0

    That would be "lua lua".

    1. Re:Close... by Pollardito · · Score: 1

      maybe he was thinking of "loo"

    2. Re:Close... by Hillgiant · · Score: 1

      Oh baby. We gotta go now.

      --
      -
  21. Re:DOA - the license sucks. by Goaway · · Score: 2, Informative

    Wow, that's the most brain-washed open-source zealot response I've seen in a while. Do you even understand the "free as in beer" line at all? Apparently not.

    If it really, really, really bothers you that Lua doesn't have enough restrictions on distribution, you are quite free to download a copy, stick a GPL license on it, and use that. How about that?

  22. Re:DOA - the license sucks. by clang_jangle · · Score: 1
    So, the license is as compatible as the BSD license is. Free as in beer, not free as in Libre.
    Can't imagine where you got that idea, in fact the BSD license is *more* free (as in libre) than the GPL. And obviously so is lua's. Just read it.
    --
    Caveat Utilitor
  23. with apologies to steve taylor by stoolpigeon · · Score: 4, Funny

    Chacham Cow
    It was a morning just like any other morning
    In the Sinai desert, 1200 B.S. (Before Slashdot)
    It glistened, it glowed, it rose from the gold of the children of Israel ...and most of the adults
    The chacham cow!
    The golden chacham cow had a body like the great cows of ancient Egypt
    And a face like the face of Cowboy Neal ...without the horns
    And through the centuries it has roamed the earth
    Like a ravenous bovine
    Seeking whom it may lick
    chacham cow!
    From the valley of the shadow of fark
    To the on-line gambling boutique
    From the depths of youtube
    To the custom style sheet
    The chacham cow lurks
    The chacham cow lurks
    Who loves you, baby?
    Who'll give you good karma?
    Who says you'll regret it?
    Aaa-ooooooo
    Who loves you, baby?
    Who'll give you mod points?
    Who says you'll regret it?
    Aaa-aaa-aaa-ooooooo
    I was in love and I needed the clicks
    And then I needed more clicks
    I was filthy rich and all I wanted were more page views ...and a few more clicks
    Woe to you, proud mortal
    Secure in your modest digs
    You think you're immune?
    You, who couldn't finger said cow in a police line-up with the three little pigs!
    chacham cow!
    Master of disguises!
    Who's gonna change shape at will?
    Who's the eye on the pyramid on the back of the dollar bill?
    Who loves power lunchin' from boing-boing to digg?
    Who loves you, baby?
    chacham cow comin' to get ya
    Why?
    Cuz you think this is stupid, don't you?
    The chacham cow will not be mocked!
    The chacham cow's planning a coup!
    The chacham cow chews cud bigger than you!
    Woe, woe, woe to you
    Who blow off this warning
    Perhaps you've already been licked
    I, too, was hypnotized
    By those big cow eyes
    The last time I uttered those four little words
    "I deserve better editors!"

    --
    It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    1. Re:with apologies to steve taylor by Anonymous Coward · · Score: 0

      sembla la vaca cega

  24. Re:DOA - the license sucks. by nuzak · · Score: 1

    > Wow, that's the most brain-washed open-source zealot response I've seen in a while.

    No zealot of the GP's stripe would ever consider using the term "open-source", which Lua most certainly is.

    Sometimes even RMS is pragmatic -- I recall when he was advocating that Ogg Vorbis use the BSD license. I really don't know what prompted that change in tune for just that one instance, since as far as I can see, it's yet to be repeated.

    --
    Done with slashdot, done with nerds, getting a life.
  25. languages as tools by Phantom+of+the+Opera · · Score: 2, Interesting

    The 'neat' thing about this language seems to be its easy memoization of functions. That would make it a good choice for programs that do certain kinds of calculations (and by the look of it, calculations that tend to be used in games).

    Any of these 'new language X' are written to tackle a particular problem set. Would you use perl or C do to string munging? Would you use perl or Fortran to do fast and heavy number crunching? Being aware of what languages are out there may save you time when you encounter a particular problem.

    I saw bring the new languages on. At the very least, their useful bits will be incorporated into a future perl release.

    1. Re:languages as tools by radtea · · Score: 3, Interesting

      Would you use perl or Fortran to do fast and heavy number crunching?

      Incredibly, there is a rather good 4th order Runge-Kutta ODE solver available in Perl. I used it once because I wanted something quick and dirty, and expected performance would be terrible, but when I later translated it into C++ I had to squeeze pretty hard to get more than a factor of two speed increase. And the difference between C++ and FORTRAN is less than a factor of two for most applications these days (although I do confess to missing FORTRAN's optimized exponentiation.)

      Furthermore, with decent regex and string classes available for every language under the sun (except FORTRAN, of course...) there is less and less reason to prefer one language over another, and even less reason for people to go mad and write their own. And if you really need the performance of LAPACK in FORTRAN then you can call into it from C++ easily enough.

      If one is writing applications, then it is very hard to beat C++, especially given the number of excellent cross-platform application frameworks (I'm currently very happy with wxWidgets, but have used Qt heavily in the past). For scripting one has a wide range of viable choices: perl, python, Java... These are all well-supported, have large user bases, and while they are unsuitable for serious application development for a number of reasons, they all do the sorts of things we want scripting languages to do: runtime optimization, garbage collection (admittedly broken in many JVMs, but working well in perl and python), and adequate cross-platform support.

      So in this environment, new languages are more of an irritant than anything else, perhaps useful for their experimental value, but if you really want new features in perl or whatever, then the best way to get them there is to work on the development of that language, not re-capitulate everything with an almost-completely-but-not-quite-identically similar syntax. Given that perl 6 is near-as-damnit a new language anyway, this is a particularly auspicious time for such endeavours.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    2. Re:languages as tools by Bastian · · Score: 2, Insightful

      I hate to burst your bubble, but if C++, Perl, Python, and Java are really such solid languages that there's no reason why any programmer would want anything else, then the world is screwed. Furthermore, adding new features to existing languages really isn't the solution - that path leads to madness, to kitchen-sink monstrosities like C++ and Perl. Both of them have traveled so far beyond the pale that their creators have admitted the desire to more or less start over and make a cleaner language that does the same thing.

      While I know this is a strained metaphor, when you're trying to do serious work a box of tools is better than a swiss army knife. That's part of the genius behind .Net and the reason why Mono started - with an environment where you can write different modules in different languages and not have to care quite so much about the boundaries between them, you really are free to use the best tool for the job. This is also why embedded languages are getting so popular - yeah, I can do everything I need to do in ObjC, but damn is it nice to be able to save myself a crapload of time by doing all the "big picture" work in something like Lua or F-Script. Nor do I find either to be an irritant - F-Script produced a drastic improvement in my productivity and the maintainability of my code, and now that I'm learning Lua I'm loving it for similar reasons. I'll probably keep using both because each is best for slightly different things.

    3. Re:languages as tools by JourneyExpertApe · · Score: 1

      (I'm currently very happy with wxWidgets, but have used Qt heavily in the past).

      Have you looked into FLTK? I confess I haven't looked at wxWidgets lately, but when I had to choose a free, cross-platform widget library a couple years ago, I decided FLTK was my best choice. I was a bit put off by its sluggish development, but I liked the API.

      --
      If you can read this sig, you're too close.
    4. Re:languages as tools by radtea · · Score: 1

      Have you looked into FLTK?

      I looked at it many years ago, but it was just Not There in terms of the functionality I wanted. wxWidgets (wxWindows, in those days) wasn't ready for prime time either, which is why I went with Qt. I'm happy with wxWidgets as it stands today, and have enough invested in it to not want to change again.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    5. Re:languages as tools by Anonymous Coward · · Score: 0

      Dude, have you ever looked at the .NET bytecode? Almost every single stinking language that runs under .NET supports identical features; That's for a reason. It's could almost be considered a bloated abstraction layer. There is no best tool for the job under .NET, it's a straightforward syntax rewrite.

    6. Re:languages as tools by radtea · · Score: 1


      Embedded languages certainly have their place--I've used perl as an embedded language in the past and am likely to use python in the future. But using rare languages is problematic--it requires that whoever maintains your code in future is familiar with the same languages you are, and it requires that debuggers support calls across rare language boundaries.

      And while large languages do get bloated, they also get refactored, and from a community perspective we are far better off with people putting time into those refactoring efforts rather than wasting it developing little languages that aren't notably superior to existing toolkits.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    7. Re:languages as tools by Bastian · · Score: 1

      I agree that using rare languages is problematic, but it's not showstopping, and it's not an argument for not using them - after all, if using them were always a bad idea, we'd still all be stuck with nothing more than a few languages like FORTRAN and BCPL.

      I question the idea that programmers not knowing the language is much of an issue - for the most part, all languages use variations of the same C-like syntax with only a few break-aways such as Smalltalk, Lisp, or FORTH. Besides, there are plenty of programmers with minds flexible enough to learn new languages; lots of hackers like to learn them for fun.

      The debugging issue can be a bother, but ideally the border between the bits written in a each language are well-defined enough that you can mostly debug each model separately and use techniques other than stepping through code with a debugger to handle the boudary cases. Besides, I'd argue that a debugger should be the absolute last line of defense in minimizing bugs. In my personal experience, multi-language development tends to be easier to write without bugs in the first place because it demands more careful design, which makes just jumping into the code without much of a plan a lot less tempting, and time spent debugging stuff like this seems to actually be shorter. I'd certainly hope that's the case, because a quick survey of new software and projects suggests that multi-language is rapidly becoming a standard way to handle large projects.

      There's a lot limiting how much a language can really get refactored - for one, there's the urge to maintain backward compatibility. This is a pretty strong pull on languages, to the point that seven years after C99 I'm still not aware of a commonly-available compiler that implements it - and at least in the case of gcc it looks like backward compatibility is one of the major reasons this hasn't happened yet. Also, I'm really not aware of any major language refactorings aside from FORTRAN and Common Lisp. Usually what happens is that someone instead creates a new language that is similar to one or more other languages, but with (what the author thinks are) syntax improvements, and then the whole thing gets pushed as a new language. This is how Sheme relates to Lisp, C to B, Java to C++, etc.

      Also, it's really not fair to characterize all rare languages as not being notably superior to existing languages. In the current case, a quick look around the other comments on this page will give you a long list of things that make Lua really stand out as a language. These comments come from people who actually know Lua, and probably know how to read all the major languages and have written a few lines of code in most of them. Meanwhile, judging from the generalities you're using, I'd be inclined to guess that you don't actually know a whole lot about Lua and therefore are mostly just asuming that its existence is somehow harmful based on nothing more than the observation that it exists.

    8. Re:languages as tools by oohshiny · · Score: 1

      If one is writing applications, then it is very hard to beat C++, especially given the number of excellent cross-platform application frameworks

      Just like junk food is the most popular food in the US, junk programming languages are the most popular languages: cheap, widely available, and many people are "happy" with them. They also cause analogous problems: software obesity and software heart attacks.

      Basically, your entire rant is just reiterating standard stereotypes about languages and just shows that you yourself simply don't know any better. Sad.

  26. The lua language by BentSorenDahl · · Score: 0

    I just discovered Lua and I got my PiL today. Its an fantastic language! It executes faster than perl, php, python and ruby. It is alot smaller, round 200kb, which is less than 1/10 of a minimal php installation and it has a reasonable Licence (MIT).

    The main drawback is the lack of good standard libraries and the build system (for lua 5.1) don't support DSO's on linux. Debian has some patches that uses libtool to build it.

    There is an interesting projocet named haserl that will allow you to embed lua in html pages.

    First Edition of the book is available online

  27. no no no by geekoid · · Score: 1

    You say LUA Guru.
    Then when they question you, look at them as if they are below you in all ways, then write on the board print "Hello world"
    then say "Is testing my knowledge really an indicator? during an interview? I think not."
    The go on as if you got the job and the interview is just a minor inconvience.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  28. Re:DOA - the license sucks. by Curien · · Score: 1

    You apparently wouldn't know "libre" if it bit you in the ass.

    --
    It's always a long day... 86400 doesn't fit into a short.
  29. Pascal by 1000101 · · Score: 1

    The syntax is similar to Pascal. No thanks. Out of all the languages I would be least likely to model a new langauge syntax after, Pascal and Lisp would be near the top.

    1. Re:Pascal by Anonymous Coward · · Score: 0

      I'm not sure why they say the syntax is Pascal-like. It isn't in the slightest. Look on http://www.lua-users.org/ at the Wiki, which has plenty of code examples.

    2. Re:Pascal by Looke · · Score: 1

      Good. Never create anything that resembles Lisp unless it's another Lisp dialect. Lispers love Lisp's syntax (or lack of syntax), as it's vital in making the entire language as extremely flexible as it is. They'd be disappointed to find a Lisp that wasn't Lisp after all.

    3. Re:Pascal by Anonymous Coward · · Score: 0

      "Pascal-like" here means "uses keywords rather than curly braces to group statements".

    4. Re:Pascal by Anonymous Coward · · Score: 0

      The syntax is similar to Pascal. Out of all the languages I would be most likely to model a new langauge syntax after, Pascal and Lisp would be near the top. Funny how there are two kinds of programming cultures, isn't it?

  30. Litestep Lua scripting by Smoke2Joints · · Score: 0, Offtopic

    The freeware windows shell, Litestep, now has a lua scripting module to do those tasks that you could probably have done before, but way faster.

    http://www.shellfront.org/modules-list.php can provide you with the module, for those that are interested.

    1. Re:Litestep Lua scripting by Smoke2Joints · · Score: 1

      That'll teach me to not follow links before I post them. Its not actually at that host.

      However, http://wiki.litestep.com/Modules:LSLua will explain how its used, which is probably all you want anyway.

  31. Lua = moon by Z80a · · Score: 2, Interesting

    in brazil,from where this script language come from,lua = moon

  32. The real reason /. likes LUA is because WoW by DRAGONWEEZEL · · Score: 1

    World of Warcraft's UI system is programmed in LUA & something else, can't remember gotta go raid, kthxbye

    --
    How much is your data worth? Back it up now.
  33. PiL is the best language book I have ever read by raaum · · Score: 2, Insightful

    Even if you have no plans to actually program in Lua, you should get this book as an example of how a technical book can and should be written!

    While the novice programmer can certainly pick this book up and learn to program (and it is perfectly suited to that), the examples, asides, and discussion in each chapter contain gems for the intermediate to advanced programmer. Everytime I look something up I see a new depth to some language feature or example I didn't see the first time around.

    I use Lua because it is incredibly easy to both extend lua with either C or C++ libraries as well as embed lua in my C/C++/ObjC/whatever programs

  34. you want a C/C++-style, Lua-like language? by Andy+Tai · · Score: 1

    Try Squirrel

    --
    Free Software: the software by the people, of the people and for the people. Develop! Share! Enhance! Enjoy!
  35. Re:DOA - the license sucks. by Anonymous Coward · · Score: 0

    Who the fuck cares, you are obviously a communist bastard. Fuck GPL.

  36. What make LUA a very potent scripting language by slonik · · Score: 4, Interesting

    Well, the first reaction of many people might be
    "O no, yet another scripting language finds it way from the obscurity into the lame light". Do we need an extra one if we already have Ruby, Python, Perl, Tcl, Scheme. And I say -- YES, Lua has its place, it is not redundant, it is not "me too" language. And here is why.

    I have been expert Ruby coder for the last 5 years using Ruby for data modelling, extensive scripting, wrote load-balancing scripts, Rails Web development, binding C++ libraries to Ruby using SWIG, you name it.

    Six month ago I got involved in LUA and I totally fell in love with it.
    What does make a beautiful programming language? Lots of features? wealth of libraries? simplicity of it? I think that language design is more art than science and the language beauty is the careful balance of features, simplicity, semantics, uniformity, etc. Like in a masterpiece painting it is the balance of color, shapes, motives and composition.

    C, for example, ia a beautiful language in the category of "portable assemblers". In that category C is powerful thanks to its libraries, simple and easily implementable thanks to its syntax and semantics, portable due to very clever and clean hardware abstraction.

    I think that Lua is to "high level scripting languages" is what C is to "portable assemblers". Lua has both OO and functional programming very naturally represented in its semantics. All objects are first class (including functions). Lua is small, very fast (in fact fastest scripting language according to http://shootout.alioth.debian.org/), has very good Virtual Machine, incremental Garbage Collector. As far as fundamantals are concerned, Lua is light-years ahead of Ruby. It still lags behind in library support, but the recent progress is very encouraging.

    Anyway, give Lua a try. You will love it. Lua is nice, its codebase is tiny (about 10K lines). It runs on anything that support ANSI C compiler including embedded stuff (ARM, Palm, Cell phones, MIPS, x86, etc).

  37. Pretty good, honestly. by scott_karana · · Score: 1

    The best part about this book is how applicable it is to other languages: Even though it doesn't directly touch any others, of course, it introduces things like closures and tail recursion in a very good way for both intermediate programmers and newbs to understand and apply to, say, Perl.

  38. I really recommend this book to anyone by ArcticCelt · · Score: 1
    "...As a disclaimer, let me say that I'm one of the technical reviewers of the book and I have been working with Lua since 1993, most of the time interacting with Roberto Ierusalimschy, even when not working in the same projects as him..." "...I really recommend this book to anyone interested in learning Lua, and also for those who already know how to use Lua but would like to fully master its way of thinking, the so called "Lua way" of doing things. The book has been considered by many as an excellent guide on programming, even if one is not interested in Lua in particular..."

    So in other words, he recommends the book to:
    1 - People who want to learn LUA;
    2 - People who already know LUA but may want to know more about it;
    3 - People who don't want to learn LUA (or simply the rest of the human race).

    After telling us how close to the project he is, the third reason sounds to me like: "Oh and by the way in, case you don't need the book at all here some random reason to try to convince you to buy it anyway." In the same vain he could have said:

    The book has been considered by many as an excellent base ingredient to make"papier-maché" scultures , even if one is not interested in Lua in particular."

    The book has been considered by many as an excellent cockroach crusher, even if one is not interested in Lua in particular."

    The book has been considered by many as an excellent way to make a fire in case you are stranded on a tropical island after a plane crash, even if one is not interested in Lua in particular."

    :)

    --

    Yahh, hiii haaaaa! -Major Kong, from Dr. Strangelove
  39. Brazil by Latent+Heat · · Score: 1

    Brazil? Doesn't everyone know that programming languages come from Denmark?

  40. Re:Lua = moon - Bullshit by Anonymous Coward · · Score: 0

    Lua means "moon". No closer to moron than "lunacy" is to "moon".

  41. Why Another Language? by crucini · · Score: 2, Interesting

    I think Lua's main selling point is ease of embedding. When you write a large C++ application, you frequently end up wanting some embedded scripting language.
    Some interpreters, like Perl, are tricky to embed. Lua is very friendly to embedding. You can call user-defined Lua functions from C and call C functions from Lua.

    The interpreter is small, and the language is sandboxable - for instance, you could have untrusted Lua running in your webserver and it would have no access to I/O or filesystem.

  42. Suggestion by mapkinase · · Score: 1
    Every reference to the language I do not know, should contain a special paragraph stating:
    To mapkinase: The uniqueness of this language is this, that, those and these. You should be using it instead of C, C++ and Perl because ...
    --
    I do not believe in karma. "Funny"=-6. Do good and forbid evil. Yours, Oft-Offtopic Flamebaiting Troll.
  43. You make baby Splutty cry. by splutty · · Score: 1

    I just cringed when you were grouping Perl with Java there... For that matter, I'd cringe if anyone would group any language with Java. It's really hard to make comparisons when you know that Java is pretty much always the worst choice in efficiency, speed and transparacy.

    But oh well :(

    Splut.

    --
    Coz eternity my friend, is a long *ing time.
    1. Re:You make baby Splutty cry. by Bastian · · Score: 1
      I just cringed when you were grouping Perl with Java there... For that matter, I'd cringe if anyone would group any language with Java. It's really hard to make comparisons when you know that Java is pretty much always the worst choice in efficiency, speed and transparacy.

      I have a feeling you're spouting cool-kid party line more than anything. Yeah, Perl has Java on memory consumption. But Java beats Perl hands down on speed. As for transparency, well, I guess there's no accounting for taste, but I think this is far, far more readable than this.
  44. Libre? As long as we have Cuba! by splutty · · Score: 1

    No need for Libre, I'll just go with a Cuba plain, please, possibly over some ice.

    But to get back to licensing, LUA probably has the best licensing for a scripting language of its ilk, considering the fact it's an ideal candidate for full embedding in anything that needs object oriented smart scripting (which applies to pretty much all games with 'mobiles' or XML based UI's), so actually giving it the licensing it has was a brilliant move to get it spread.

    Splut.

    --
    Coz eternity my friend, is a long *ing time.