Installing Lua

Before ever starting, y’all can hate me because I installed Lua for Windows. From a binary. Yes, I should build it for myself. And my computer does dual boot into Linux. Well, tough. That’s not what we’re here to do today. (Maybe when there’s “Seven Operating Systems in Seven Weeks?”)

(For those who don’t automatically think a binary build of Lua for Windows is a bad idea, you can find it at .)

One nice thing about Lua for Windows is it comes with a really quick “tutorial.” Okay, it’s more like a bunch of examples, but it’s a fast way to see what Lua looks like.

Anyway, there are (at least) three syntax things that drive me crazy about programming languages:

  • how to mark comments
  • how to indicate “not equal”
  • how to handle else if

So far, Lua does not disappoint. It does have single line double hyphen comments. Good, fine, I’ve seen those before in Ada. But ah, the multiline comment is a thing of Lua beauty.

Here's that multiline comment,
folks! ]]

Yeah. Hyphen, hyphen, square bracket, square bracket. Ended of course with two close square brackets. And no hyphens.

And the not equal is almost as much fun.

a ~= b

Tilde! And it doesn’t mean match. Dammit.

It makes the else if, elseif, downright disappointing.

But if I’d wanted more of the C/C++/Java/C# family, I wouldn’t be working through this book!

Along with the Seven More Languages book, the first edition of Programming in Lua is available on line (at, so I figured I’d read that as well. There’s a sample factorial program in the first chapter:

-- defines a factorial function
function fact (n)
   if n == 0 then
      return 1
      return n * fact(n-1)

print("enter a number:")
a ="*number") -- read a number

I figured I’d try it out, so I entered it (okay, cut and pasted it) and ran it from the iExecutor that comes with the Windows version of Lua. And it failed. Damn, had the language changed so much since the first edition that this program no longer worked?

Poking around a bit, I realized that the problem was that the input line was not working. My first impulse was there had to be a typo. a ="*number") ? Really? Surely the quotes didn’t belong there; it should be more C scanf-ish line:*number) and then we’ll use number in the next line.

Wrongo. The input line is in fact correct (and I realized again that Lua is going to be fun). The problem was iExecutor. While it did run code with no input just fine, there seem to be problems in reading input. As soon as I ran the program from the command line, it was just fine. Fortunately, Notepad++ does recognize Lua and it’s easy to run programs edited in Notepad++, so all is well.

I guess I should read more about iExecutor. But Lua seems like more fun for now.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: