Live data from Hacker News

Learn Lua in 15 Minutes

tylerneylon.com

71–80 of 99 posts

Re: Learn Lua in 15 Minutes

#72

I'm going to be "that guy": -- These are the same: -- ...snip... local function g(x) return math.sin(x) end local g = function (x) return math.sin(x) end According to the Lua Reference Manual [1], this example isn't correct. Rather, this is the correct translation: local function g(x) return math.sin(x) end local g; g = function (x) return math.sin(x) end From the manual: "This only makes a difference when the body o…

You're right; I fixed that part.

you also miss a couple of "local newObj" in constructors.

Re: Learn Lua in 15 Minutes

#73
post #62

Great sheet. -- Variables are global by default. thisIsGlobal = 5 -- Camel case is common. -- Undefined variables return nil. -- This is not an error: foo = anUnknownVariable -- Now foo = nil. -- Only nil and false are falsy; 0 and '' are true! Didn't read further. Bad language design. Must die.

Bah! Why is it bad and why must it die? Please add content to this discussion - I don't agree with you, but maybe you can convince me. Try it.

Re: Learn Lua in 15 Minutes

#74

I would like to say that the easiest way for me to learn lua really fast was to build games with Corona using lua. Having a great tool that gives great feedback right away makes learning a language more fun IMO.

Likewise! For me, it was MOAI: http://getmoai.com/

Since I became a Lua programmer, I really can't stand any other languages, and I've rapidly switched to it for my scripting needs. Tables are just soooo lovely. ;)

Re: Learn Lua in 15 Minutes

#75
post #18
post #9

Earlier quoted context omitted.

Well, it helps a lot that Lua is by design a very small language :) Python is actually much bigger nowadays -- I would challenge someone to come up with something this simple that doesn't leave out a lot of stuff you will encounter in real code. The extra features ("bloat") do matter. I like the idea of Lua a lot, but when I started programming in it, it unfortunately felt like a less capable Python to me.

I'm sure you're aware of Penlight, which does a very nice job of providing a "batteries included" library similar to Python's for Lua.

I definitely wasn't, thanks for the tip!

Re: Learn Lua in 15 Minutes

#78
This is great! I wish every language had an intro like that :)

It was interesting to find resemblance of Lua's classes to Perl's blessing. Always meant to look into the language and this tutorial made me do it.

I also learned about the LÖVE game engine, which I'm going to play with this week. Thank you!

http://love2d.org/

Re: Learn Lua in 15 Minutes

#79

Earlier quoted context omitted.

What do you want to do that you cannot do because of the lack of Unicode support?

I'd imagine internationalized gamed would be a big one, although I'm not a games programmer or a lua user myself.

I had hoped that someone would mention what specific thing was missing, because as far as I know it's trivial to do anything one would want to do when making games already. That is, it is very easy to accept UTF-8 input, output UTF-8, munge UTF-8 strings together prior to outputting them, compare UTF-8 strings for equality, and so on. If the game needs UTF-8-aware strlen (for limiting the length of a field or alphabetizing things), it is like 10 lines of code.

Re: Learn Lua in 15 Minutes

#80
post #22

Having a font size of 25.33pt makes the website impossible to read without zooming out 3 steps. I would be happy if people stopped using tiny and huge default font sizes.

Well, it looks very good and reads very good on my ipad and on my tiny screen on my notebook. Otherwise I would've to zoom in, not a big deal though, do you think?
Post reply on HN