Live data from Hacker News

Learn Lua in 15 Minutes

tylerneylon.com

91–99 of 99 posts

Re: Learn Lua in 15 Minutes

#92

Earlier quoted context omitted.

If you're playing with love2d you might as well want to check out Zoetrope, I found it very awesome. http://libzoetrope.org/

This looks interesting, can you explain the difference between Zoetrope and LÖVE? The former seems to be built on top of the latter, yes? Are there particular things lacking in LÖVE that Zoetrope fills in? I couldn't find this info quickly on their sites.

Looks like it has collision detection whereas for LÖVE you'd use Hardon Collider, has Tiled level loading whereas you'd need a plugin for LÖVE, etc. Basically, lots of stuff that you'd include in your games anyway.

Looks nice and has better documentation than LÖVE. Thanks for posting it, I didn't know about it before.

Re: Learn Lua in 15 Minutes

#94
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.

Could you tell us anything about why these things are bad?

Regarding the last point (the one that you cannot change), I'm not sure I prefer the behavior of any other language. In Python, for instance, all of the number-like things I tried were falsy iff they were 0, and I found that almost any container is falsy iff it is empty, but Queues are always truthy. This is a weird exception, and I would rather not have to remember it. Collections and numeric types defined in external libraries can easily have the same problem.

Re: Learn Lua in 15 Minutes

#95
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.

Could you tell us anything about why these things are bad? Regarding the last point (the one that you cannot change), I'm not sure I prefer the behavior of any other language. In Python, for instance, all of the number-like things I tried were falsy iff they were 0, and I found that almost any container is falsy iff it is empty, but Queues are always truthy. This is a weird exception, and I would rather not have to r…

Global automatically declared variables is a well-known bad feature of some non-modern languages that gives nothing but an opportunity to make hardly detectable mistakes because of misprints.

Arbitrary nonsensical type casts must be prohibited. The compiler/interpreter/IDE must infer types and help the programmer to catch their mistakes as early as possible.

As a general rule of language design, if something looks unintentional or ambiguous to a human, it should look so to a compiler/interpreter. The more coherent the programming environment is to your conscience, the easier the programming is.

Re: Learn Lua in 15 Minutes

#96
post #95

Earlier quoted context omitted.

Could you tell us anything about why these things are bad? Regarding the last point (the one that you cannot change), I'm not sure I prefer the behavior of any other language. In Python, for instance, all of the number-like things I tried were falsy iff they were 0, and I found that almost any container is falsy iff it is empty, but Queues are always truthy. This is a weird exception, and I would rather not have to r…

Global automatically declared variables is a well-known bad feature of some non-modern languages that gives nothing but an opportunity to make hardly detectable mistakes because of misprints. Arbitrary nonsensical type casts must be prohibited. The compiler/interpreter/IDE must infer types and help the programmer to catch their mistakes as early as possible. As a general rule of language design, if something looks un…

Thanks. I agree that Haskell is a great language, but this is a dynamically typed scripting language. As such, perhaps it would be more useful to compare it to languages that are actually comparable, like Ruby, Perl, your favorite LISP, Javascript, or Python.

This language does not include any nonsensical type casts. You cannot add a table to a string, take the arithmetic negation of a function, or index a number. (Actually, if you wanted to you could write code that permits you to do most of these things. For instance, I usually use some code that adds the ability to index strings.) String concatenation and arithmetic addition are different operators, so unlike in some prominent scripting languages you cannot find a and b such that +(a+b) == 50005 and +(b+a) == 55.

It does, however, include some forms that allow you to branch based on whether or not a value is a member of the set {nil, false}. I suppose that it would be better for the compiler to be able to guarantee that the value was a member of the set {true, false} and to yell at you rather than running your code if it was not, but this is a fairly rare property across all programming languages. I frequently use a programming language called Scala, and it pretends to provide some typechecks, but in reality all reference types are silently nullable, and all method calls are silently of the bottom type.

Re: Learn Lua in 15 Minutes

#97
post #67

Earlier quoted context omitted.

Upon reading this comment had to skim the whole thing looking for more (hadn't yet finished reading). No more maths references than tau found yet. :/

Ramanujan and Hardy are two well-known mathematicians who collaborated in Britain between 1914 and 1920. One day Hardy took taxi number 1729 to visit Ramanujan, and remarked to him that he (Hardy) could think of nothing special about the number (1729). Ramanujan replied that it was in fact the first number expressible as the sum of two cubes in two different ways (1^3 + 12^3 = 9^3 + 10^3). The story has since become…

Haha I'd heard this anecdote before, so it's my own fault for missing it. :)

Thanks for the great article and indeed fun references!

Re: Learn Lua in 15 Minutes

#98
post #6

This is awesome. I will take [a single huge list of self-explanatory example snippets (with a few short comments here and there) for 95% of use cases] over [detailed walls-of-text docs pages spread across a hierarchy of topics] any day.

Thanks. My goal was to write the tutorial I wish I had when I started. Your description also matches my own preferred learning style.

Mine too. If I had found this back when I was learning Lua, I'm certain I'd have bookmarked it and referred to it regularly. I just hope beginners don't absorb the coding style too much >:)

Re: Learn Lua in 15 Minutes

#99
post #57
post #55

Earlier quoted context omitted.

I agree, but can't help but wonder if the "me" from 20 years ago would have found this very confusing while I was learning to program. I learned from books with all that long-winded banter - so now I'm not sure if I actually NEEDED all that stuff in order to learn. Guess I'll never know. This method, however, is PERFECT for anyone who already knows how to program. I love it, and actually came here to say that I wish…

> The brass tax Or the brass tacks, even: http://www.phrases.org.uk/meanings/get-down-to-brass-tacks.h... Sadly, English isn't as logical as Lua.

Well... how about that :) Never even thought about the phrase before. No edits, I'll leave my error for fun and learning.
Post reply on HN