Hacker News new | past | comments | ask | show | jobs | submit login
In Love with LÖVE (ton.io)
110 points by replicatorblog on Jan 27, 2013 | hide | past | favorite | 72 comments



I am confused by the fact that this blog post seems to link to all the competing frameworks he discusses, but never links to LÖVE itself. Seems an odd choice given that the word is going to produce a bunch of unrelated google search results...

For reference: https://love2d.org/


Sorry about that. I was clearly so proud of myself for getting my keyboard to do the two dot thing on top of the Ö that I forgot the most basic link of all. Updated now.


for the curious - Option+u (for umlaut) then the letter you want, so in this case O. result: Ö

If you're new to OSX I highly recommend playing about seeing which characters are possible. Hold Option and try each key, then Option+Shift and each key. Comes in handy for typing things like ©2013, 20˚, 2π and LÖVE


Or, just hold down the O key and check out the variations available to you.


on iOS, yes, that's correct. Try it on OSX however and all you get is a line of Os :)


Not in Lion - by default holding down a key will bring up the accent menu. You can turn it off by following this http://osxdaily.com/2011/08/04/enable-key-repeat-mac-os-x-li... (though I've found it more useful to keep it on).


cool, thanks, didn't know that :) Unfortunately I'm stuck on 10.6 here as this machine's too old to upgrade. Tested it and everything before I replied, just in case I was wrong.


Yeah, for the record:

https://www.love2d.org/

although i recommend just skipping to the wiki https://www.love2d.org/wiki/Main_Page

Edit: HA simul-post and a ninja edit.

Still I recommend the wiki, the docs are well done.


Here's the link for anybody that doesn't want to search it:

https://love2d.org/


Does Lua have "crappy scoping"? My understanding is that it has full lexical scoping. And somebody normally liking Python is in no position to complain about bad scoping rules!

I haven't used Lua myself, but I'm impressed by the design: it seems like an elegant version of JavaScript minus most of the really obnoxious JavaScript warts.

The tables and metatables seem particularly great: they look like a simple, elegant version of prototype-based inheritance without some of the problems JavaScript suffers. It's certainly simpler and more expressive than a class-based system.

Also, Lua is well known for having coroutines that are done correctly. That's probably not immediately useful for complete beginners, but it's certainly a nice feature when you get to it.


It does have full lexical scoping, however "global by default" is good for scripting, questionable for standalone programming.

I general yes Lua is a great language, I have a lot of fun writing in it. But it does have its warts (though fewer than Javascript).


For what it's worth, you can use the local keyword to limit the scope of variables.

http://www.lua.org/pil/4.2.html


Have you heard of moonscript[1]? It is a bit quirky but makes var declarations local by default.

[1] http://moonscript.org/


I had learned Lua a few years before learning JavaScript. While learning JavaScript, I always felt like it was a dirty, warty version of Lua.


[deleted]


Basically, I personally take issue with the way Python handles global variables and, until Python 3, completely fails to handle non-local variables.

Let's take a trivial example that would work in JavaScript or Scheme. Often, I want to keep track of how many times a particular function gets called (usually for debugging). I would expect to be able to do something like this:

    counter = 0
    def foo(bar, baz):
      counter += 1
      ...
This does not work in Python. You could use the global keyword to work around this:

    counter = 0
    def foo(bar, baz):
      global counter
      counter += 1
      ...
This is something of an ugly hack in the language design. Moreover, this falls apart if counter is not in the global scope itself--for example, if foo is defined inside another function. Python 3 introduces the nonlocal keyword to deal with this.

Fundamentally, this problem stems from the fact that Python conflates two fundamentally different operations: defining a variable and mutating it. I personally really like how Scheme handles this: defining and setting are two different actions, and trying to set a variable that has not been defined is an error. This makes the intentions of the programmer much clearer.

A very common pattern in Scheme and JavaScript (as well as other languages I don't use, no doubt) is to use closures to encapsulate state. Thanks to Python's scoping model, this is at best a pain and certainly unnatural.

There are also some minor annoyances. One that gave me problems recently (although it has been fixed in Python 3, I believe), was with list comprehensions:

    [i * i for i in range(1, 10)]
    print i # gives you 9!


> A very common pattern in Scheme and JavaScript (...) is to use closures to encapsulate state. Thanks to Python's scoping model, this is at best a pain and certainly unnatural.

It is also unnecessary. Python has normal classes, so you can contain your state within objects rather than stackframes.


I don't like either of your examples. Your first example should have been a generator and used a yield rather than a global counter. Your second example is simply bad practice (what do you even expect to happen? It's ambiguous, but i having the value 9 seems to make a reasonable amount of sense).


In my second example, I expect i to not be in the scope. The variable i only makes sense inside the list comprehension and should not be randomly introduced into the outer scope.

For the first example, I don't see how you could replace it with yield, especially if the function foo has to normally return a value when it's used. The core idea is to count how many times foo is called without altering the call site at all. Also, this is an entirely trivial example to illustrate the scoping issue; in practice, there are more complicated reasons to want to set non-local variables, especially from things like helper functions.


This scope-leaking was fixed in Python 3 afair (I don't have a Python 3 to verify just now).


The examples don't have to be idiomatic Python to demonstrate Python's weaknesses. In fact, one would expect mature idiomatic forms to skirt language limitations more-or-less by design.


Not a python expert, but python3 has had to add unlocal to let you create a non local variable. Lua requires explicit local, else things are global (which has different problems but seems a more logical choice).

Lua also makes all loop indexes local to the loop which is very clean. Python has difficulty with this.


Another area where Lua excels is interacting with C code. It's very easy to bind, and it runs really fast to boot, making it perfect for a scripting language in an engine that uses C for the heavy lifting.


For the folks who struggle with Lua's language design: try thinking of it like Crockford's Good Parts of Javascript with a slightly different syntax (and arrays/objects rolled into one, the table). Generally speaking, once you've moved past the default indexing from 1, that analogy works out pretty well -- even down to how to set up more object oriented designs (js prototypes and Lua metatables/metamethods are rather closely related ideas).

LÖVE is a very fun engine, much easier than PyGame to get going - in both setup and development terms.


Indexing from 1 and 0 seem to me to reflect two different equally valid viewpoints. Offsets against a base address in memory (the C family) versus labels for boxes (Lua and friends). Naturally, stating from a base address, the offset is 0. Equally naturally, if you're labelling boxes with numbers, you number the first one "1". For Lua, given the tables are also at the same time hashes (with explicit labels), treating them as numbered boxes makes sense.


I think also the construction of the for loop makes it more natural. Lua is "for i = i, n" vs the more complex and off-by-1 prone "for (i = 1; i < n; i++)" where you need the less than vs an equality.


The unintuitive thing about this choice is that "for i = n,m" calls the loop body "m-n+1" times. The "for (i = n; i < m; i++)" does it "m-n" times.

A more elaborate argument: http://www.cs.utexas.edu/~EWD/transcriptions/EWD08xx/EWD831....


If your for loop is for a 0-based language, it's wrong because it starts with 1.

If it's for a 1-based language, it's wrong because it compares with "<" and not "<=".

So, I guess that proves your point that it's error-prone. :)

In C, the idiomatic way is (as you surely know) "for(i = 0; i < n; ++i)".


typo, the second one was supposed to be 0 based... although that shows how off by 1 errors occur.


The only problem and it's really a very tiny problem, is that the library community has settled on a fairly... purile naming convention.

Beyond that it's a fantastically easy way to get started writing a game.


I don't know if I would call it tiny; looking at the library naming convention it doesn't seem to be far from the controversy around 'pantyshot' a while back: http://www.zdnet.com/blog/violetblue/when-software-offends-t...

Though I would assume most library authors are not necessarily attempting to be offensive, not the greatest culture to construct around your toolset regardless.


As biased as I am (very), I'm not sure how this applies, none of the library names I know suggest anything sexist, or otherwise offensive. Now, as for whether naming libraries after sex acts, and possibly body parts, is a good idea, well, does it matter? Worst case it makes your conversations more fun.


Asking a co-worker about the AnAl library could elicit a chuckle, or it could be an example of what alienates female programmers from the game industry. It isn't inherently a big deal, but in the hands of the immature and can easily go from funny to uncomfortable.


> alienates female programmers from the game industry

Also males such as myself that are just tired of peurile humour when they witness the darker side of their peers so frequently?


If the sexual funniness stems from the library the team is using, then the awkwardness can be addressed in a team meeting well in advance. Perhaps resulting in a only-one-joke-a-day policy or changed pronunciation (e.g. AnAl like "analgesic").


You can turn everything uncomfortable, or nothing at all, it's up to the one using the name, not the name itself.


That was business software; this is games. I'd expect the gaming community to be a bit more lenient.


I don't think the gaming community as it exists now would complain, no. However, opinions differ on whether that's a good thing:

http://www.giantbomb.com/news/eight-women-eight-responses-an...

among other examples - what counts as acceptable behavior in the gaming community is a pretty hot topic right now. there is a strong argument to be made that anything that isn't acceptable in the business community should be discouraged in gaming.


damn... yeah fair enough.


"fair enough" is something you say when someone you initially disagreed with makes a point. I don't see any disagreement here. http://en.wiktionary.org/wiki/fair_enough


In Australia the context is different and implies that you agree that someone is making a point which is fair enough to be valid, in other words that you agree with it.


"I don't know if I would" is something you say when you disagree.


Come on, they're basically just tongue-in-cheek names to evoke a chuckle or two.

'HardonCollider' collision system, 'Lube' networking library etc, I can hardly see anyone being offended unless they _really_ want to be.

Apart from that I fully agree, despite doing lots of coding in Python, I, just like the author find löve a better choice than pygame for quickly developing/prototyping games, YMMV and all that.


"Offended" may be too harsh a word, but "annoyed" would certainly apply to me and "uncomfortable" to a number of professional software developers I know. I don't know many shrinking violets, but that doesn't mean you want to be hit over the head with (stupid) sexual metaphors when you're working just because the library developers are incapable of reining in childishness.

Like, by itself, not a gamebreaker or anything (for me that would be a weakly typed language--though I've encouraged my little brother to play with Moai, another Lua environment, in the past), but given the choice I'd probably go with tools with a culture that encourages a bit better judgment.


Except, the original article is talking about finding a framework suitable for 7- and 10-year-old boys. Which might change the context of the jokes for some people :o


When I was 8, I insisted on buying a little book containing a collection of toilet stall graffiti sayings. I didn't get half of them, yet merrily recited them.

And look where I am now, happily employed software developer with >=1000 karma.

So I wouldn't worry too much.


For those not familiar with what libraries have been developed see here:

https://love2d.org/wiki/Category:Libraries


I love Löve as well, but yeah, the 3rd party library names are pretty infantile. It would probably have been hilarious when I was 12 though...


> I had seen this about 6 months ago but dismissed it because the programming language, Lua, looked weird and I’d never heard of it.

This what surprised me most about the post. Lua is not especially strange, by any means, and also fairly well known. Obviously, its hard to compare my experience with his experience, but nonetheless I was quite surprised he said something like that.


It is not alas that well known, although much more so in the last few years. It has reached number 20 on github though now. A lot of people use it but do not really talk about it much, eg in game development.


Probably doesn't help that most of the code is tied up in scripts for games, and public development is hosted in places like curseforge and wowinterface.


I was extremelly surprised, especially when Lua is actually famous as a game scripting language!

«a language which may not please the purists»

I would have stopped reading here, but the article was already over...


Just going to link one of my favorite libraries for LÖVE.

https://github.com/kikito/middleclass


What makes it your favorite?


Not the favorite, just one that I enjoy. When looking for a simple OO implementation, middleclass works.


Something else, that while not a game engine, was built to bring the the BASIC experince to modner machines is Hackety Hack http://hackety.com/


This isn't directly related to the blog post as it's about stuff available on OS X, but if you're on Windows I can very much recommend checking out Construct 2 by Scirra[1]. They have a pretty fantastic HTML5 game engine and an editor (and the whole "no programming required" is really just marketing - even though it uses a "visual" event system you still need to understand programming concepts like loops, conditions and such in order to make effective use of it). They have a feature-limited (no other limits though) free edition available for it too.

[1] http://scirra.com


My 12 year old (going on 13) also started with Mindstorm. Then we dabbled in MIT battlecode (Java). I taught him some Python and he did Udacity Python intro class on his own. Then he discovered Ogre (C++) and has been obsessed with it ever since. I remember giving him an 20 minutes intro to HTML a couple of years ago and that was all he needed to start playing with web pages. A young mind seems particularly adept at absorb ing artificial languages. Don't underestimate your children.


Take a look at http://defold.se - It uses LUA (I'm not the biggest fan) but offers a nice editor that is very useful for most 2d games.


It's too bad he doesn't do a thorough comparison, I'd love to hear what he likes so much about Pythonista, for instance.

With regards to the "crappy scoping", I can only assume he didn't read up properly, especially since both the globals and locals mentioned right after do exist.


Wait until he tries out MOAI. If he loves LÖVE, he's going to be falling over himself to have an affair with MOAI .. ;)

http://getmoai.com/


One of the great benefits of Love, in my opinion, and something that sets it apart from a lot of comparable game frameworks, is the open source and free nature. It really encourages sharing and open (not obfuscated) code by having the default packaging for your games just a zip file of the source and assets.

Moai, compared, is probably a richer framework but seems fairly closed. I'm also slightly confused by the paid for cloud component. Is this necessary for making games? What part, or how much of Moai is free or open?


MOAI is open source under the CPAL license, and contributions from the community are folded back into mainline regularly.

Check out the license here: http://opensource.org/licenses/cpal_1.0

The cloud is an additional service, which you are not required to use - but is there if you do need it. Its one small point of confusion in the MOAI world, that people think that MOAI Cloud is MOAI itself, but thats not the case. Its just an additional service that can be utilized by users of the MOAI SDK, if they want it ..


Thanks for information. Yes, the Moai is slightly confusing, it's not obvious to me that there is a full SDK available and usable without paying for the cloud component. I might check it out in fact, I have been looking for a cross platform game toolkit, I skipped over Moai before because I thought I would have to pay to use it.



I already love moai without even using it; theirs is the only mongodb lua driver at http://github.com/moai/luamongo


Polycode is about to get released: http://www.polycode.org/


his comment on gosu made me sad. as a big ruby fan, i run into the "framework looks wonderful, but due to installation issues i cannot in good conscience recommend it to a beginner" far too often. the one-click installer projects for windows and osx are going a long way towards fixing this, though.


I cannot recommend ruby for any desktop applications that you intend to distribute to non-tech-savvy users.

Sure there are ways it can be done, jruby + swing and shooes or monkeybars etc but they all have big drawbacks compared to "Just Works" languages.

[EDIT] Having said that, the releasey gem used by gosu looks interesting.


I found out about LÖVE about 2 weeks ago. It looks a bit like "flash done right". I haven't done anything with it yet, but it looks cool for interactive multimedia content.


Yes, unfortunately there doesn't seem to be any easy way to run the games in a browser which would probably be the killer app for this.


A talented hacker, ghoulsblade on GitHub, cobbled together a web player for LOVE: https://github.com/ghoulsblade/love-webplayer

Here are some demo applications converted to HTML5/WebGL: http://ghoulsblade.schattenkind.net/love-webplayer/


awesome!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: